query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
returns an array of [year, times_played] for the year with the lowest nonzero of occurrences | def calculate_least_common_year
self.calculate_plays_by_year.select{ |year,times_played| times_played > 0 }.sort_by{ |year, times_played| times_played }.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_most_common_year\n self.calculate_plays_by_year.sort_by{ |year, times_played| times_played }.last\n end",
"def year_array\n return ['x'] +(@earliest_year..@latest_year).to_a\n end",
"def yearly_play_chart_data\n self.yearly_play_data.map do |year, times_played|\n {name: year, plays: times_played}\n end\n end",
"def sort_by_year(array)\n array.sort! { |a, b| a.year <=> b.year }\n end",
"def puppy_golden_age(years_array)\n golden_index = []\n for idx in 0...years_array.length\n if years_array[idx].to_i > years_array[idx+1].to_i\n golden_index.push(idx) #Creates an array with index with greatest years between 2 consecutive years\n end\n end\n [golden_index[0], golden_index[(golden_index.length - 1)]]\n end",
"def sorting(array)\n #variable sorted by release is equal to the array movie data and sorting it by the year of earliest to now\n sorted_by_release = array.sort_by {|year| year[:year]}\n #outputs the array list sorted by release\n puts sorted_by_release\nend",
"def parse_year(time)\n year = time.strftime(\"%Y\").to_i\n sounds_for_number(year / 100) + sounds_for_number(year % 100)\n end",
"def get_years\n year = slice_year\n till_year = year.to_i - @past_years\n years = []\n year.to_i.downto(till_year) { |y| years << y }\n years\n end",
"def artist_years\n self.artists.reduce(0) do |accumulator, artist|\n accumulator += artist.years_active\n end\n end",
"def silly_years(year)\n result = []\n while result.length < 10\n result << year if silly_year?(year)\n year += 1\n end\n result\nend",
"def solution(x, a)\n # write your code in Ruby 2.2\n min_occurance = {}\n earliest_time = -1\n\n # loop over a and calculate min occurance\n (0..a.length-1).each do |i|\n if(min_occurance[a[i]].nil?)\n min_occurance[a[i]] = i\n end\n end\n\n\n # loop for x\n (1..x).each do |x_i|\n if(min_occurance[x_i].nil?)\n earliest_time = -1\n break\n else\n if earliest_time.to_i < min_occurance[x_i].to_i\n earliest_time = min_occurance[x_i]\n end\n end\n end\n earliest_time\nend",
"def online_participation_by_year\n year = @online_enrollment.map { |hash| hash.fetch(:timeframe).to_i }\n data = @online_enrollment.map { |hash| hash.fetch(:data) }\n Hash[year.zip(data.map { |num| truncate(num) })]\n end",
"def get_earliest_latest\n @output.each do |key, value|\n value.each do |k, v|\n year = k.to_i\n @earliest_year = year if year < @earliest_year\n @latest_year = year if year > @latest_year\n end\n end\n @earliest_year = @start_year if @start_year > @earliest_year\n end",
"def first_year\n record.records.order(:year).first&.year\n end",
"def get_year_array\n accurate_range = Timesheet.used_range( true )\n\n # Does the range's start date lie within a commerical week which actually\n # starts in the previous year?\n\n first_date = accurate_range.first\n first_day_of_week = Timesheet.date_for( first_date.year, first_date.cweek, TimesheetRow::FIRST_DAY, true )\n start_year = first_day_of_week.year\n\n # Similar logic for the range's last date.\n\n if ( accurate_range.last > Date.today ) # Implies no work packets => Timesheet.used_range returned an allowed range instead.\n last_date = Date.today\n else\n last_date = accurate_range.last\n end\n\n last_day_of_week = Timesheet.date_for( last_date.year, last_date.cweek, TimesheetRow::LAST_DAY, true )\n end_year = last_day_of_week.year\n\n years = []\n year_range = ( start_year..end_year )\n\n # Build the years array backwards so newer dates are encountered\n # first - a user is more likely to be interested in current data\n # than in ancient history.\n\n year_range.each do | year |\n years.unshift( ReportYear.new( year, accurate_range ) )\n end\n\n return years\n end",
"def no_repeats(year_start, year_end)\n\n\tyear = year_start\n\tresults = []\n\n\twhile year <= year_end\n\t\tresults << year if no_repeat?(year)\n\t\tyear += 1\n\tend\n\n\tresults\nend",
"def season_with_fewest_games\n seasons = @games.group_by { |game| game.season }\n seasons.min_by { |season, games| games.count }.first\n end",
"def get_year_ary\n (Date.today.year-99..Date.today.year).inject([]){|x,y| x << y}.reverse\n end",
"def count_first_authors_over_time(publications)\n # Get a list of first authors for each year\n year_author_list = Hash.new(0)\n publications.each do |publication|\n\t first_author = publication.authors.split()[0]\n\t year_key = publication.publication_year.to_s\n\t if not year_author_list.key?(year_key)\n\t year_author_list[year_key] = []\n\t year_author_list[year_key] << first_author\n\t elsif not year_author_list[year_key].include? first_author\n\t year_author_list[year_key] << first_author\n\t end\n \tend\n \t# Count number of unique first authors for each year\n \tlast_year = Time.new.year - 1\n year_range = (1990..last_year)\n \tcategories = []\n values = []\n \tyear_range.each do |year|\n \t categories << year.to_s\n \t if year_author_list.key? year.to_s\n \t values << year_author_list[year.to_s].count\n \t else\n values << 0\n \t end\n \tend\n \treturn categories, values\n end",
"def my_min2(arr)\n timestart = Time.now\n smallest = arr[0]\n (1...arr.length).each do |idx|\n smallest = arr[idx] if smallest > arr[idx]\n end\n p (Time.now - timestart) * 1000\n smallest\nend",
"def next_happy_year(year)\n loop do\n year += 1\n return year if year.digits.uniq == year.digits\n end\nend",
"def associated_years\n years = \"\"\n \n\t start_date = event_start\n\t start_date = entry_deadline if is_opportunity?\n\t \n years << start_date.year.to_s if !start_date.blank?\n years << ' '\n years << event_finish.year.to_s if !event_finish.blank?\n \n #remove duplicates and trim off spaces\n unique_years = years.strip.split(' ').uniq.sort\n result = unique_years\n if unique_years.length > 1\n result = []\n for y in unique_years[0]..unique_years[1]\n result << y\n end\n end\n result\n #now we have the 2004-2008 case to deal with, we wish to create [2004,2005,...2008]\n \n end",
"def previous_year_sub_group_for_solr\n result_array = []\n #Get the groupings for the current year\n year_groups = FacetHelper.event_facet_previous_years(Time.now.year)\n years = associated_years\n logger.debug \"YEARS TO CHECK:#{years.join(',')}\"\n for year in years\n logger.debug \"CHECKING:#{year}\"\n #check the year against the \n for key in year_groups.keys\n logger.debug \" CHECKING:key #{key}\"\n ruby_statement = year_groups[key]\n y = year.to_i\n evaluation = eval(ruby_statement) \n logger.debug \" EVALUATION: #{y} against #{ruby_statement} = *#{evaluation}*\"\n if evaluation == true\n result_array << key\n break\n end\n end\n end\n \n result_array.uniq.sort.join(', ')\n end",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).reduce([]) do |arr, year|\n if not_repeat_year?(year)\n arr << year\n else\n arr\n end\n end\nend",
"def min_year\n 2015\n end",
"def score_term word, year_hash, year\n min_norm_count = 0.000001\n curr_nc = 0.0\n prev_nc = 0.0\n (year-GROUPSIZE+1).upto(year) do |y|\n begin\n curr_nc += year_hash[y][word][:nc] || 0.0\n rescue\n curr_nc += 0.0\n end\n end\n (year-GROUPSIZE*2+1).upto(year-GROUPSIZE) do |y|\n begin\n prev_nc += year_hash[y][word][:nc] || 0.0\n rescue\n prev_nc += 0.0\n end\n end\n\n if prev_nc > 0.0\n growth = curr_nc / prev_nc\n else\n growth = 0.0\n end\n\n if growth > 1.0\n return growth\n else\n return 1.0\n end\nend",
"def earliest_year(date_el_array, method_sym)\n poss_results = {}\n date_el_array.each { |el|\n result = DateParsing.send(method_sym, el.content)\n poss_results[result] = el.content if result\n }\n earliest = poss_results.keys.sort.first if poss_results.present?\n return earliest, poss_results[earliest] if earliest\n end",
"def makeYearList(entries)\n # Find the range of the years\n years = entries.map {|entry| entry.year}\n entriesList = []\n years.max.downto(years.min) { |year|\n yearEntries = matchEntries(entries, \"year\", year)\n next if yearEntries.size == 0\n entriesList << [year, yearEntries]\n }\n entriesList\nend",
"def score_term word, year_hash, year\n # Must exceed this usage floor\n min_norm_count = 0.000001\n curr_nc = 0.0\n prev_nc = 0.0\n # Get total normalized usage counts over current period\n (year-GROUPSIZE+1).upto(year) do |y|\n begin\n curr_nc += year_hash[y][word][:nc] || 0.0\n rescue\n curr_nc += 0.0\n end\n end\n # Get total normalized usage counts over previous period\n (year-GROUPSIZE*2+1).upto(year-GROUPSIZE) do |y|\n begin\n prev_nc += year_hash[y][word][:nc] || 0.0\n rescue\n prev_nc += 0.0\n end\n end\n\n # Check to prevent divide y zero\n if prev_nc > 0.0\n growth = curr_nc / prev_nc\n else\n growth = 0.0\n end\n\n # Can balance growth with normalized usage; currently\n # only using growth.\n return growth #+ Math.log(nc*1000000)\nend",
"def repetition_stats\n fastest_laps = completed_repetition_rounds\n .group(:repetition_level_id)\n .minimum(:elapsed_time_ms)\n .map do |repetition_level_id, elapsed_time_ms|\n [\n RepetitionLevel.find_by(id: repetition_level_id),\n Time.at(elapsed_time_ms / 1000).strftime(\"%M:%S\").gsub(/^0/, '')\n ]\n end.sort_by {|level, _| level.number }\n end",
"def no_repeats(first_year, year_end)\n result = []\n (first_year..year_end).each do |year| if repeat?(year) == true\n result.push(year) end\n end\n\n return result\nend",
"def year_with_maximum_population(data)\n # Get a calenader with unique years\n calendar = data.flatten.uniq.sort\n delta_memo = Hash.new(0)\n\n # Save the delta for each year\n data.each_with_index do |person, i|\n delta_memo[person[0]] += 1\n delta_memo[person[1]] -= 1\n end\n\n # Associate calendar year with delta\n calendar.each_with_index do |year, i|\n calendar[i] = [year, delta_memo[year]]\n end\n\n max_pop_year = calendar[0][0]\n current_population = 0\n max_population = 0\n\n # Running sum of max population\n # Set year on max_population\n calendar.each do |year|\n current_population += year[1]\n\n if current_population > max_population\n max_population = current_population\n max_pop_year = year[0]\n end\n end\n\n max_pop_year\nend",
"def year_with_maximum_population(data)\n memo = {}\n\n data.each do |p1|\n current_birth_year = p1[0]\n next if memo[current_birth_year]\n\n count = 0\n # Person is alive in that year if they were born before the current year\n # and they died after the current year\n data.each do |p2|\n if p2[0] <= current_birth_year && current_birth_year <= p2[1]\n count +=1\n end\n end\n\n memo[current_birth_year] = count\n end\n\n year_of_max = nil\n current_population = 0\n memo.each do |k, v|\n if v > current_population\n current_population = v\n year_of_max = k\n end\n end\n\n year_of_max\nend",
"def silly_years(year)\n silly_years = []\n year = year + 1\n\n while silly_years.length != 10\n year_str = year.to_s\n if year_str[0..1].to_i + year_str[2..3].to_i == year_str[1..2].to_i\n silly_years.push(year)\n end\n year += 1\n end\n\n return silly_years\nend",
"def count_plays(year)\n s = get_shakey[\"William Shakespeare\"]\n .select { |k, v|\n v[\"finished\"] == year\n }.each { |key, val|\n puts val[\"title\"]\n }.count\nend",
"def silly_years(year)\n result_arr = []\n # retrieves first two digits\n first_half = year.to_s.split('')[0..1].join('').to_i\n while result_arr.length < 10\n first_half += 1\n mid = first_half%10\n next if mid*10 - first_half < 0\n \n mid = mid*10 + (((mid*10) - first_half)/10)\n second_half = mid - first_half\n year = first_half.to_s\n if second_half.to_s.length == 1\n year += \"0\" + second_half.to_s\n else\n year += second_half.to_s\n end\n \n \n result_arr << year.to_i\n end\n\n result_arr\nend",
"def nb_year(p0, percent, aug, p)\n count = 0\n while p0 < p\n p0 = p0 + (p0 * percent * 0.01).to_i + aug\n count += 1\n end\n \n return count\nend",
"def no_repeats(year_start, year_end)\nanswer = []\n\n for year in year_start..year_end do\n if no_repeat?(year)\n answer << year\n end\n end\n return answer\nend",
"def start_of_year(year)\n date_calc.start_of_year(year)\n end",
"def osu_score_array win_condition\n score_array = @game_objects.map{|game| game_meets_win_cond?(win_condition, game) ? game.score_osu.to_i : -1}\n score_array.delete(-1)\n score_array\n end",
"def competition_by_year\n \tresult = CompetitionResult.group_by_year(:created_at, format: '%Y').count\n \trender json: [{ name: 'Count', data: result}]\n end",
"def metrics_by_year(program = {})\n metrics = quantity_deliverables(program.deliverables)\n .map(&:metrics)\n .reduce([]) { |array, n| array.concat(n) }\n\n return [] unless metrics.any?\n\n metric_array = []\n year_metrics(metrics).each_pair { |key, value| metric_array << { year: key, metric: value } }\n\n metric_array\n end",
"def checking_for_no_wins_results_frequency_for_each_nominee\n losing_count = losing_results_frequency_for_each_nominee\n winning_arr = get_wins_results_array_frequency_for_each_nominee\n no_wins_arr = []\n\n losing_count.each do |key, value|\n if winning_arr.include?(key) == false\n no_wins_arr << key\n end\n end\n\n return no_wins_arr\n end",
"def participation_by_year\n year = @pupil_enrollment.map { |hash| hash.fetch(:timeframe).to_i }\n data = @pupil_enrollment.map { |hash| hash.fetch(:data) }\n Hash[year.zip(data.map { |num| truncate(num) })]\n end",
"def silly_years(year)\n years = []\n\n until years.length == 10\n year += 1\n digits = year.to_s\n\n first_two, middle_two, last_two = [\n digits[0..1], digits[1..2], digits[2..-1]\n ].map { |pair| pair.to_i }\n\n years << year if (first_two + last_two) == middle_two\n\n end\n\n years\nend",
"def worst_movie(array)\n #variable movie gross will be a new array of all the gross for all the movies\n movie_gross = array.map {|movie|\n #converting movie gross into an integer\n movie[:gross].delete('$').split(',').join.to_i\n }\n #variable bad movie is taking the new array of movie gross and looking for the min grossing movie\n bad_movie = movie_gross.min\n # the worst grossing bond variable is a new array filtering for movies that gross only matches the bad movie gross\n worst_grossing_bond = array.select {|movie| movie[:gross].delete('$').split(',').join.to_i == bad_movie}\n # this outputs the array with the has of the worst grossing bond movie\n puts worst_grossing_bond\nend",
"def generate_top_tracks(year)\n weeklycharts = lastfm.user.get_weekly_chart_list(\"pulleasy\")\n weeklycharts.each do |weekly_chart|\n charts = []\n if weekly_chart[\"from\"] > year.to_time.to_i && weekly_chart[\"to\"] < year.next_year.to_time.to_i\n charts << weekly_chart\n end\n end\nend",
"def year\n return self.to_a[IDX_YEAR]\n end",
"def rate_stock_price_dev_one_year(stock_price_dev_one_year)\n now = stock_price_dev_one_year.compare\n past = stock_price_dev_one_year.value\n perf = Util.perf(now, past)\n case\n when perf > 5\n score = 1\n when perf < -5\n score = -1\n else\n score = 0\n end\n stock_price_dev_one_year.perf = perf\n stock_price_dev_one_year.score = score\n return score\n end",
"def heaviest_rock(rock_array)\n max_rock = 0\n\n rocks.each do |rock|\n max_rock = rock if max_rock < rock \n end\nend",
"def no_repeat_years(first_yr, last_yr)\n result = []\n (first_yr..last_yr).each do |num|\n if not_repeat_year?(num)\n result << num\n end\n end\n result\nend",
"def game_week\n now = DateTime.now\n all_games = NflSchedule.where(year: Date.today.year)\n .order(:start_time)\n week_started = 0\n all_games.each { |game|\n if (week_started < game.week) && (now > game.start_time)\n week_started = game.week\n end\n }\n return week_started\n end",
"def oldest_metric(metrics = [], label = '')\n min_year = selected_year(metrics, 0)\n filtered_metrics = metrics.select { |metric| metric[:year].to_i == min_year }\n\n return nil unless filtered_metrics.any?\n filtered_metrics.first.fetch(label.to_sym)\n end",
"def call(year)\n previous_year = Population.previous_known(year)\n\n return previous_year.population if previous_year.year == year # year entered is known\n\n next_year = Population.next_known(year)\n\n # there is no next year - unable to calculate\n return nil if next_year.nil? \n\n # calculate the percentage that year is between next and previous years\n mod_percentage = (year - previous_year.year).to_f / (next_year.year - previous_year.year).to_f\n delta_population = next_year.population - previous_year.population\n\n (delta_population * mod_percentage).to_i + previous_year.population\n end",
"def ordered_year_count\n \tFishCount.for_year(Date.today.year).order(count_date: :desc)\n end",
"def YearCodes(year)\n\tif year =~ /freshman/\n\t\treturn 1\n\telsif year =~ /sophomore/\n\t\treturn 2\n\telsif year =~ /junior/\n\t\treturn 3\n\telsif year =~ /senior/\n\t\treturn 4\n\telse\n\t\treturn 0\n\tend\nend",
"def faith_years\n (Time.now.year - 1991).ordinalize\n end",
"def no_repeats(start_year, end_year)\n (start_year..end_year).to_a.select { |year| no_repeat?(year) }\nend",
"def find_min_value(array)\n min = 0\n array.length.times do |count|\n if count == 0\n min = array[count]\n else\n if array[count] < min\n min = array[count]\n end\n end\n end\n min\nend",
"def year_int(date_el_array)\n result = date_parsing_result(date_el_array, :year_int_from_date_str)\n return result if result\n\n year_int, _ignore = self.class.earliest_year_int(date_el_array)\n year_int if year_int\n end",
"def years\n use_date = params[:dt] || \"created_at\"\n @age_limit = (params[:years] || \"2\").to_i.years.ago\n date_format = \"'%Y-%m'\"\n @dates = AudioMessage.active\n .where(\"audio_messages.#{use_date} > ?\",@age_limit)\n .group(\"date_format(audio_messages.#{use_date},#{date_format})\")\n .order(\"audio_messages.#{use_date} DESC\")\n .count\n @speakers_by_date = {}\n @dates.keys.each do |date|\n @speakers_by_date[date] =\n generate_speaker_list_with_counts_for_date(date,date_format,use_date)\n end\n # Peek at most recent load date\n @latest_addition_date = AudioMessage.maximum('created_at')\n end",
"def silly_years(year)\n years = []\n until years.length == 10\n year_str = year.to_s\n if (year_str[0..1].to_i + year_str[2..3].to_i == year_str[1..2].to_i)\n years << year\n end\n year += 1\n end\n\n years\nend",
"def find_most_played_songs\n top_songs_with_play_count_pair = self.lib.songs.reject do |song|\n #this line is describing records it will get rid of\n (!song.metadata.has_key?('play_count')) or (song.metadata['play_count'] == nil)\n end\n\n top_songs_played_sorted = top_songs_with_play_count_pair.sort do |a, b| \n b.metadata['play_count'].to_i <=> a.metadata['play_count'].to_i\n end\n\n top_songs_played = top_songs_played_sorted.first(5)\n song_names_of_top_played = top_songs_played.collect {|song| song.metadata['name']} \n end",
"def no_repeat_years(first_yr, last_yr)\n array = []\n (first_yr..last_yr).each do |year|\n array << year if not_repeat_year?(year)\n end\n array\nend",
"def no_repeats(year_start, year_end)\n return if year_start > year_end\n results = []\n \n (year_start .. year_end).each do |year|\n results << year if no_repeat?(year) \n end\n \n results\nend",
"def tie_breaker\n all_ranks.find{|truth| truth != 2014}\n end",
"def years(tech=nil) \n if tech\n tdata = nil\n @techs.each do |t|\n if t.name == tech\n tdata = t\n end\n end\n if tdata\n return tdata.years\n else\n return 0\n end\n # TODO: return just the time we worked with that technology\n end\n return (@to - @from).to_i / 365\n end",
"def get_coding_score(teamArr)\n response = []\n teamArr.each do |x|\n response << @preferences_hash[x][:codingProficiency]\n end\n response.uniq()\n \n return (response.size/5.0)\n #[0.2 - 1.0]\n end",
"def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end",
"def actor_movie_list(array)\n actor_in_bond = array.map {|movie| movie[:actor]}\n list = actor_in_bond.uniq\n #movies per actor variable is a new array of objects listing the key value of actor name and movie number count per actor\n movies_per_actor = list.map {|movie| {actor_name: movie, movie_num: actor_in_bond.count(movie)}}\n #movies per variable gives an array of just the number of movie numbers\n movies_per = movies_per_actor.map {|movie| movie[:movie_num]}\n #variable least num gives us the lowest number of movie num\n least_num = movies_per.min\n #lowest acting num variable gives us a array, filtering throught the hashes of movies per actor and looking at\n #the movie num and matching it with the least num of movie an actor has been in and returning that hash\n lowest_acting_num = movies_per_actor.select{|actors| actors[:movie_num] == least_num}\n # this outputs the hash of the actor with the lowest acting number role\n puts lowest_acting_num\nend",
"def get_project_fiscal_years project\n if project.blank?\n []\n elsif project.multi_year?\n a = []\n (current_fiscal_year_year..current_fiscal_year_year + 49).map{ |y| [fiscal_year(y), y] }.each do |fy|\n if fy[1] < project.fy_year\n next\n else\n a << fy\n end\n end\n a\n else\n [[project.fiscal_year, project.fy_year]]\n end\n end",
"def year_guaranteed_cashflows(year)\n guaranteed_cashflow_components\n .map{ |c| c.generators[year].gen_cashflows }\n .transpose\n .map { |month| month.delete_if(&:nil?) }\n end",
"def puppy_golden_age(arr)\r\n puppies = 0 # set the var for puppies born for later comparison\r\n years = [] # set empty array to later push the results of the comparison\r\n\r\n arr.each_with_index do |x, i| # looping through entire array. could have used #each_index without x.\r\n for i2 in i + 1...arr.length # set up loop for i2 which is needed to compare all elements in array above i1 and for return of second index. i + 1 protects against the return of the same index twice. see written test 3.\r\n if puppies < arr[i..i2].reduce(&:+) # comparison of the value puppies with the sum of the elements in arr where index > i.\r\n puppies = arr[i..i2].reduce(&:+) # if the net gain between these two indices is > the previous value for puppies, the new gain becomes the value\r\n years = [i, i2] # sets the indicies for the larger gain compared here: puppies < arr[i..i2].reduce(&:+)\r\n end\r\n end\r\n end\r\n\r\n years # when the loop is complete, the largest gain and their indicies will be set for the variables puppies/ years. question asks for the index of the years.\r\nend",
"def sort_scores(unsorted_scores, highest_possible_score)\n\n # array of 0s at indices 0..highest_possible_score\n score_counts = [0] * (highest_possible_score+1)\n\n # populate score_counts\n unsorted_scores.each do |score|\n score_counts[score] += 1\n end\n\n # populate the final sorted array\n sorted_scores = []\n\n # for each item in score_counts\n score_counts.each_with_index do |count, score|\n\n # for the number of times the item occurs\n (0...count).each do |time|\n\n # add it to the sorted array\n sorted_scores.push(score)\n end\n end\n\n return sorted_scores\nend",
"def school_years\n load_school_years\n @school_years.sort { |s1, s2| s1.start_date.year <=> s2.start_date.year } \n end",
"def nb_year(p0, percent, aug, p)\n years = 0\n while p >= p0 do\n p0 += (percent/100.0 * p0) + aug\n years += 1\n end\n p years\nend",
"def one_week_wonders(songs)\n new_arr = songs.select {|song| no_repeats?(song, songs)}\n return new_arr.uniq\nend",
"def years_since_beginning_of_solar_system\n @planets.each do |planet|\n days_since_formation = @formation_year / 365.26\n local_year_of_planet = days_since_formation * planet.rate_of_solar_rotation\n puts \"On #{planet.name}, the current year is #{local_year_of_planet.round(0)}.\"\n end\n end",
"def total_years\n all_years = artists.map do |artist|\n artist.years_active\n end\n all_years.inject(:+)\n end",
"def get_winners\n json = get_json('http://oscars.yipitdata.com/')\n json.results.collect do |films_array|\n find_winner(films_array.films).tap do |winner|\n winner[:year] = films_array.year[0,4]\n end\n end\n end",
"def cumulative_years\n if deleted_at && deleted_at.year > created_at.year\n (created_at.year...deleted_at.year).to_a\n elsif deleted_at\n []\n else\n (created_at.year..Date.today.year).to_a\n end\n end",
"def no_repeat_years(first_yr, last_yr)\n (first_yr..last_yr).reduce([]) do |output, el|\n if not_repeat_year?(el)\n output << el\n else\n output\n end\n end\nend",
"def odd_years(array)\n #the variable movies is a new array of the filter array movie data\n the_movies = array.select {|movie|\n #it is filtering if the movie year is odd\n if movie[:year].odd?\n #if it is odd it will give the hash movie\n movie\n end\n }\n #this will output the new array of movies that are in odd number of years\n puts the_movies\nend",
"def no_repeats(year_start, year_end)\n no_repeats = []\n (year_start..year_end).each do |yr|\n no_repeats << yr if no_repeat?(yr)\n end\n\n no_repeats\nend",
"def roster_needed_entries_present(year: Time.now.year)\n needed = roster_entries_needed(year: year)\n\n roster_entries = acao_roster_entries.joins(:roster_day).where('acao_roster_days.date': (\n DateTime.new(year).beginning_of_year..DateTime.new(year).end_of_year\n ))\n\n roster_entries_high = roster_entries.where('acao_roster_days.high_season')\n\n roster_entries.count >= needed[:total] && roster_entries_high.count >= needed[:high_season]\n end",
"def calculate_score\n #example of array frames [5, 10, 20 , 35, 58]\n array_frames = generate_frames\n array_frames.reduce(0) {|memo, value| memo + value }\n end",
"def real_study_years\n if finished?\n end_date = finished_on.to_time\n elsif absolved?\n end_date = disert_theme.defense_passed_on.to_time\n else\n end_date = Time.now\n end\n return (end_date - enrolled_on.to_time).div(1.year) + 1\n end",
"def find_min_value(array)\n answer = array.sort!\n answer[0]\nend",
"def kindergarten_participation_by_year\n year = @kindergartners.map { |hash| hash.fetch(:timeframe).to_i }\n data = @kindergartners.map { |hash| hash.fetch(:data) }\n Hash[year.zip(data.map { |num| truncate(num) })]\n end",
"def acceptable_years_in_school\n Array(min_year_in_school..max_year_in_school)\n end",
"def get_wins_results_array_frequency_for_each_nominee\n winning_count = winning_results_frequency_for_each_nominee\n winning_arr = []\n\n winning_count.each do |key, value|\n winning_arr << key\n end \n\n return winning_arr\n end",
"def no_repeats(year_start, year_end)\n result = []\n (year_start..year_end).each do |yr|\n result << yr if no_repeat?(yr)\n end\n result\nend",
"def year_ranking\n ranked_albums = SortCollection.sort_albums('year')\n render json: ranked_albums.sort_by(&:last).reverse[0...5].to_h, status: 200\n end",
"def extract_years(dates)\n dates.flat_map{ |date| extract_year(date) }.uniq\n end",
"def graduation_rate_by_year\n year = @graduation_rate.map { |hash| hash.fetch(:timeframe).to_i }\n data = @graduation_rate.map { |hash| hash.fetch(:data) }\n Hash[year.zip(data.map { |num| truncate(num) })]\n end",
"def no_repeats(year_start, year_end)\n (year_start..year_end).to_a.select do |year|\n if year.to_s.split(\"\").uniq == year.to_s.split(\"\")\n year\n end\n end\nend",
"def count_publications_over_time(publications)\n annual_counts = publications.annual_counts\n last_year = Time.new.year - 1\n year_range = (1970..last_year)\n categories = []\n values = []\n updated_count = 0\n year_range.each do |year|\n categories << year.to_s\n if annual_counts.key?(year)\n updated_count += annual_counts[year]\n values << updated_count\n else\n values << updated_count\n end\n end\n return categories, values\n end",
"def most_successfull(nth, year, file)\n filepath = File.dirname(__FILE__) + file\n csv_options = {col_sep:',',quote_char:'\"', encoding: \"ISO8859-1\"}\n\n films = []\n date = CSV.foreach(filepath, csv_options) do |row|\n films << { name: row[0], year: row[1].to_i, earnings: row[2].to_i }\n end\n\n\n films_before_year = films.select { |film| film[:year] < year }\n film_before_year_best_sales = films_before_year.sort_by { |film| - film[:earnings]}\n film_most_successfull = film_before_year_best_sales.take(nth)\nend",
"def what_rank\n 10 - all_ranks.find_index{ |truth| truth != 2014} \n end",
"def raw_year\n start_on.year\n end"
] | [
"0.6881578",
"0.5795251",
"0.56842947",
"0.5610372",
"0.554224",
"0.54979396",
"0.54905206",
"0.5441946",
"0.54223555",
"0.5408078",
"0.5386826",
"0.5365788",
"0.5328362",
"0.53281355",
"0.53271276",
"0.52850235",
"0.5254471",
"0.5221472",
"0.52045083",
"0.51985264",
"0.51767117",
"0.51622516",
"0.51502866",
"0.5150005",
"0.5142544",
"0.51372504",
"0.5116191",
"0.51056063",
"0.5100617",
"0.5098115",
"0.5097149",
"0.50815254",
"0.50777406",
"0.50751567",
"0.5070672",
"0.5050568",
"0.50349325",
"0.5034445",
"0.50342876",
"0.50296825",
"0.50238913",
"0.5020077",
"0.50157565",
"0.5012489",
"0.5005472",
"0.499857",
"0.49928352",
"0.4976382",
"0.49696746",
"0.49523988",
"0.49475712",
"0.49472532",
"0.4945315",
"0.49450043",
"0.49439123",
"0.49363562",
"0.49327835",
"0.49249664",
"0.49166396",
"0.49114946",
"0.4904926",
"0.49045497",
"0.4897271",
"0.48971337",
"0.48909712",
"0.48878315",
"0.48862487",
"0.48839056",
"0.48831135",
"0.4877506",
"0.48765537",
"0.48765466",
"0.48721662",
"0.48674726",
"0.48664436",
"0.4863487",
"0.48569813",
"0.4856136",
"0.4855604",
"0.48494527",
"0.48447773",
"0.4844537",
"0.48346415",
"0.4821861",
"0.48205554",
"0.4819181",
"0.48181438",
"0.48109365",
"0.48079893",
"0.480768",
"0.4804252",
"0.48021808",
"0.48002288",
"0.47981575",
"0.47975543",
"0.4790087",
"0.47894943",
"0.47860008",
"0.47843528",
"0.4779908"
] | 0.7741517 | 0 |
Don't display if the :if option passed says so Don't display if the link isn't real, we have children, and none of the children are being displayed. | def display?(context = nil)
return false unless render_in_context(context, @should_display)
return false if !real_url?(context) && @children.any? && !items(context).any?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_in_child_list?\n\t\t\ttrue\n\t\tend",
"def is_link?\n !child_question.nil?\n end",
"def visible_navigation_children\n children.select { |c| c.published? and c.display_in_navigation? }\n end",
"def menu_item_display_if\n menu_options[:if] || proc { true }\n end",
"def useless?\n content.nil? and children.empty?\n end",
"def has_no_admin_link?\n all('.main-navigation-item', text: 'Admin').empty?\n end",
"def has_children?\n false\n end",
"def show\n if should_skip_to_first_child?\n redirect_to refinery.url_for(first_live_child.url) and return\n elsif page.link_url.present?\n redirect_to page.link_url and return\n elsif should_redirect_to_friendly_url?\n redirect_to refinery.url_for(page.url), :status => 301 and return\n end\n\n render_with_templates?\n end",
"def show\n if should_skip_to_first_child?\n redirect_to refinery.url_for(first_live_child.url) and return\n elsif page.link_url.present?\n redirect_to page.link_url and return\n elsif should_redirect_to_friendly_url?\n redirect_to refinery.url_for(page.url), :status => 301 and return\n end\n\n render_with_templates?\n end",
"def link_to_unless(condition, name, options = {}, html_options = {}, &block) # :nodoc:\n condition ? content_tag(:span, name, html_options) : link_to(name, options, html_options, &block)\n end",
"def hidden_div_unless(condition, attributes = {}, &block)\n unless condition\n attributes[\"style\"] = \"display: none;\"\n end\n content_tag(\"div\", attributes, &block)\n end",
"def has_no_admin_link?\n find('.navigation-toggle').click\n all('.navigation-item', text: 'ADMIN').empty?\n end",
"def check_if_has_children\n self.lookups.count == 0\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def custom_link_to_unless(*args,&block)\n args.insert 1, capture(&block) if block_given?\n link_to_unless *args\n end",
"def render_children_for_page?(page, depth)\n depth.succ <= @_options[:depth].to_i && children_of(page).any?\n end",
"def show_hide_my_messages_tree\n self.div(:id=>\"lhnavigation_container\").link(:text=>\"My messages\").click\n end",
"def show_maybe(opts={})\n return if hide_content?(opts)\n yield\n end",
"def sub_menu?\n items && (items.empty? ? false : true)\n end",
"def visible?\n parent.nil?\n end",
"def hidden_div_if(condition, attributes = {}, &block)\n if condition\n attributes[\"style\" ] = \"display: none\"\n end\n content_tag(\"div\" , attributes, &block)\n end",
"def invisible_link_to(options = {}, html_options={}, *parms)\n link_to('', options, html_options.merge(:style=>\"display:none;\"), *parms) \n end",
"def hidden_div_if(condition, attributes = {}, &block)\n if condition\n attributes[\"style\"] = \"display: none\"\n end\n content_tag(\"div\", attributes, &block)\n end",
"def hidden_div_if(condition, attributes= {}, &block)\n if condition\n attributes[\"style\"] = \"display:none\"\n end\n content_tag(\"div\", attributes, &block)\n end",
"def intend_children\n children.select { |child| !child.has_class :hidden }\n end",
"def intend_children\n children.select { |child| !child.has_class :hidden }\n end",
"def cobrand_render_or_parent_only(opts)\r\n cobrand_render opts.merge({ :vp_parent_only => true })\r\n end",
"def include_in_menu?\n menu_options[:display] != false\n end",
"def show_relation?(object)\n\t\t\tif not @show_if\n\t\t\t\ttrue\n\t\t\telse\n\t\t\t\tbegin\n\t\t\t\t\t@show_if.call(object)\n\t\t\t\trescue StandardError => e\n\t\t\t\t\tlogger.error(\"show_relation? monkey patch function crashed. this might be okay if the lambda-function doesn't check intensively on classes or such. error was: #{e}\")\n\t\t\t\t\tlogger.error(e.backtrace.join(\"\\n\"))\n\t\t\t\t\tfalse\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def link_to_if(condition, element, link)\n if condition\n link_to(element, link)\n else\n element\n end\n end",
"def hide_if(condition)\n hide(:if => condition)\n end",
"def hidden?\n return false if parent.tag == :root\n return true if parent.open == false\n parent.hidden?\n end",
"def list_children(taxons_collection)\n taxons_collection.sort_by {|p| p.hierarchy}\n html_var = \"\"\n taxons_collection.each do |t|\n if not t.children.empty?\n html_var << \"<li><i class='icon-plus'> </i>\" << link_to(t.name, t) << \"<ul>\" << list_children(t.children) << \"</ul>\"\n else\n html_var << \"<li><i class='icon-white' style='visibility: hidden;'> </i>\" << link_to(t.name, t)\n end\n html_var << \"</li>\\n\"\n end\n return html_var.html_safe\nend",
"def preserve_children?\n false\n end",
"def has_children?\n !leaf?\n end",
"def valid_links\n\t\tself.links.select {|l| l.parent_id != nil && l.child_id != nil}\n\tend",
"def is_only_child?\n return call_ancestry_method(:is_only_child?) if use_ancestry?\n\n relationships.all?(&:is_only_child?)\n end",
"def parent_has_constraints_on_children?\n parent_tag[:definition][:only_allow] != nil\n end",
"def sidebar_required?\n @menu_elements = []\n if @page.parent_id.present?\n @menu_elements = @page.parent.children.reject{|c| !c.in_menu?}\n end\n unless @page.children.blank?\n @menu_elements = @page.children.reject{|c| !c.in_menu?}\n end\n return !@menu_elements.empty?\n end",
"def show_pages\n false\n end",
"def info_page_will_display_details\n if info_page_can_display_details && link.details_text_markup.to_s != ''\n true\n end\n end",
"def is_child?\n !is_parent?\n end",
"def child?\n false\n end",
"def link_tree\n ''.html_safe.tap do |content|\n content << toggle_link\n\n unless leaf?\n content << h.content_tag(:ul) do\n h.content_tag_for(:li, children) do |c|\n c.decorate.link_tree\n end\n end\n end\n end\n end",
"def has_child?\n [email protected]?\n end",
"def has_children?\n !children.empty?\n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def child_check\n if @children.nil? or @children.empty?\n get_children unless @already_fetched_children\n @already_fetched_children = true\n end\n end",
"def children?\n !children.empty?\n end",
"def scaffold_show_association_links?(association)\n !(scaffold_habtm_with_ajax && scaffold_association_type(association) == :edit)\n end",
"def link_to_remote_unless(condition, name, options = {}, html_options = nil, &block)\n link_to_remote_if !condition, name, options, html_options, &block\n end",
"def each_hidden_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf unless leaf.visible\n end\n end",
"def parentable?\n false\n end",
"def hide_edit_links?\n not @hide_edit_links.nil?\n end",
"def hide_edit_links?\n not @hide_edit_links.nil?\n end",
"def has_children?\n !self.children.empty?\n end",
"def draw_if_sidebar\n Link.sidebar_from_link(request.original_fullpath)\n end",
"def children?\n !children.empty?\n end",
"def children?\n !children.empty?\n end",
"def no_display?(library)\n library[:no_display].is_a?(FalseClass) || library[:label].blank?\n end",
"def hide_edit_links?\n !@hide_edit_links.nil? && @hide_edit_links == true \n end",
"def hierarchical?\n false\n end",
"def have_children?\n children.count != 0\n end",
"def hide_unless(condition)\n hide(:unless => condition)\n end",
"def possibly_include_hidden?; end",
"def link_4menu(item) #:nodoc:\n html = ''\n link = item.link\n link = \"/#{@site.route_name}/#{item.page_id}\" #if link.blank?\n# \n html << @parent.link_to(item.picture, link) unless item.picture.blank?\n html << if !item.caption.blank?\n # TODO Translation\n @parent.link_to(item.caption, link)\n end\nend",
"def link_if(condition, name, options = {}, html_options ={}, &block)\n if !condition\n if block_given?\n block.arity <= 1 ? yield(name) : yield(name, options, html_options)\n else\n \"\"\n end\n else\n link_to(name, options, html_options)\n end\n end",
"def is_childless?\n return call_ancestry_method(:is_childless?) if use_ancestry?\n\n relationships.all?(&:is_childless?)\n end",
"def affiliate_link?\n !current_user.try(:admin?)\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def filterable?\n !linked_category?\n end",
"def hidden_div_if(condition, options = {}, &block)\n hidden_tag_if(:div, condition, options, &block)\n end",
"def show\n @page = Page.find(\"#{params[:path]}/#{params[:id]}\".split('/').last)\n\n if @page.try(:live?) || (refinery_user? && current_user.authorized_plugins.include?(\"refinery_pages\"))\n # if the admin wants this to be a \"placeholder\" page which goes to its first child, go to that instead.\n if @page.skip_to_first_child && (first_live_child = @page.children.order('lft ASC').live.first).present?\n redirect_to first_live_child.url and return\n elsif @page.link_url.present?\n redirect_to @page.link_url and return\n end\n else\n error_404\n end\n end",
"def show\n @page = Page.find(\"#{params[:path]}/#{params[:id]}\".split('/').last)\n\n if @page.try(:live?) || (refinery_user? && current_user.authorized_plugins.include?(\"refinery_pages\"))\n # if the admin wants this to be a \"placeholder\" page which goes to its first child, go to that instead.\n if @page.skip_to_first_child && (first_live_child = @page.children.order('lft ASC').live.first).present?\n redirect_to first_live_child.url and return\n elsif @page.link_url.present?\n redirect_to @page.link_url and return\n end\n else\n error_404\n end\n end",
"def hide_style_if(condition)\n condition ? 'display:none;' : ''\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def link_to_visibility_toggle(options = {})\r\n options[:of] ||= '$(this.parentNode).next()'\r\n options[:default_visible] = true if options[:default_visible].nil?\r\n\r\n link_text = options[:default_visible] ? 'hide' : 'show'\r\n link_to_function as_(link_text), \"e = #{options[:of]}; e.toggle(); this.innerHTML = (e.style.display == 'none') ? '#{as_('show')}' : '#{as_('hide')}'\", :class => 'visibility-toggle'\r\n end",
"def children_exist?\n\tend",
"def has_preview?\n\t\tnot parents.map(&:visitable).include?(false)\n\tend",
"def display?\n text? and super\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def link_if(condition, name, options = {}, html_options = {})\n if condition\n link_to(name, options, html_options)\n end\n end",
"def link_breadcrumb_or_not(menu)\n # path for the breadcrumb menu item\n path_method = \"breadcrumb_#{menu}_path\"\n path = send(path_method) if respond_to?(path_method.to_sym, include_private=true)\n path = '#' if path and current_page?(path) # if the current request is this path then stub it out with #\n path ||= '#'\n link_breadcrumb(menu, path)\n end",
"def has_children?\n children.size > 0\n end",
"def has_children?\n children.size > 0\n end",
"def child?\n !root?\n end",
"def link_to_visibility_toggle(options = {})\r\n options[:of] ||= '$(this.parentNode).next()'\r\n options[:default_visible] = true if options[:default_visible].nil?\r\n\r\n link_text = options[:default_visible] ? 'hide' : 'show'\r\n link_to_function as_(link_text), \"e = #{options[:of]}; e.toggle(); this.innerHTML = (e.style.display == 'none') ? '#{as_('show')}' : '#{as_('hide')}'\", :class => 'visibility-toggle'\r\n end",
"def children?\n [email protected]?\n end",
"def no_child?\n body.kind_of?(NullNode)\n end",
"def root_relation?; !parent end"
] | [
"0.5980648",
"0.5868918",
"0.5747552",
"0.56405133",
"0.56344247",
"0.5629681",
"0.562275",
"0.5553639",
"0.5553639",
"0.54415756",
"0.5419465",
"0.5416317",
"0.5359356",
"0.5351475",
"0.5351475",
"0.5351475",
"0.5290461",
"0.52603334",
"0.5225555",
"0.5225033",
"0.52004814",
"0.51803386",
"0.51741076",
"0.516909",
"0.5168311",
"0.5166292",
"0.5155075",
"0.5155075",
"0.514796",
"0.5146859",
"0.51462185",
"0.5144139",
"0.51361483",
"0.512251",
"0.5119157",
"0.50981104",
"0.5092788",
"0.50832677",
"0.5081506",
"0.5077693",
"0.5061461",
"0.50497276",
"0.5046782",
"0.50271094",
"0.50105155",
"0.5002942",
"0.49993747",
"0.49985427",
"0.49969798",
"0.49969798",
"0.49969798",
"0.49969798",
"0.49933833",
"0.4983865",
"0.49833724",
"0.4980685",
"0.4980081",
"0.49754393",
"0.49734908",
"0.49734908",
"0.49720994",
"0.49532694",
"0.49469393",
"0.49469393",
"0.4946615",
"0.4940204",
"0.49347517",
"0.492677",
"0.4912286",
"0.490956",
"0.49054816",
"0.49045834",
"0.48993894",
"0.48973486",
"0.48951247",
"0.48951247",
"0.48951247",
"0.48951247",
"0.4888959",
"0.48830718",
"0.488295",
"0.488295",
"0.48703086",
"0.48698103",
"0.48698103",
"0.48682845",
"0.4867158",
"0.48646384",
"0.4861021",
"0.4857973",
"0.4857973",
"0.485581",
"0.48551223",
"0.48525023",
"0.48525023",
"0.48420274",
"0.48419946",
"0.484124",
"0.48407936",
"0.48362875"
] | 0.6391599 | 0 |
Returns an array of the ancestry of this menu item. The first item is the immediate parent of the item. | def ancestors
parent ? [parent, parent.ancestors].flatten : []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_array\n parents = []\n\n top_array = [self]\n c_arr = top_array\n\n self.class.base_class.each_with_level(descendants.includes(:link => :linkable)) do |menu, level|\n case level <=> parents.count\n when 0 # same level\n # set current array as new sibling array containing menu\n c_arr = [menu] \n\n # and push current array (the new sibling array) to current parent\n parents.last[1] << c_arr \n\n when 1 # descend\n # push a child array if the current level does no thave one\n c_arr << [] if c_arr.length == 1\n \n # and push the sibling array into that array\n c_arr[1] << [menu]\n\n # push the current array to be the current parent\n parents << c_arr\n\n # and reset the current as the new child array\n c_arr = c_arr[1].last\n\n when -1 # ascend\n # pop parents up to the parent of the new menu\n parents.pop while parents.count > level\n\n # and proceed to add new sibling as though level had been 0\n c_arr = [menu]\n parents.last[1] << c_arr\n end\n end\n\n top_array\n end",
"def hierarchy\n parents = []\n parent = self.parent\n\n while parent && !parent.parent_id.nil?\n parents << parent\n parent = parent.parent\n end\n\n return parents.reverse\n end",
"def self_and_parent_menus(options={})\n\t\t\tarr = [self]\n\t\t\tfather = self.parent\n\t\t\twhile father.present?\n\t\t\t\tarr << father\n\t\t\t\tfather = father.parent\n\t\t\tend\n\n\t\t\treturn arr.reverse\n\t\tend",
"def path\n return @path_array if @path_array\n parent_category = self\n @path_array = [parent_category]\n while (parent_category = parent_category.parent) != nil do\n @path_array.insert(0, parent_category) \n end\n @path_array\n end",
"def ancestors\n []\n end",
"def ancestors\n parents = []\n\n this_parent = self.parent\n\n while this_parent != nil\n parents << this_parent\n this_parent = this_parent.parent\n end\n parents\n end",
"def get_children_array\n\t\t\tarr = []\n\t\t\tself.children.get_active.each do |child_1|\n\t\t\t\tarr << {menu: child_1, class: 'parent'}\n\t\t\t\tchild_1.children.get_active.each do |child_2|\n\t\t\t\t\tarr << {menu: child_2, class: 'child'}\n\t\t\t\tend\n\t\t\tend\n\t\t\tarr\n\t\tend",
"def crumb_parents\n []\n end",
"def ancestors\n if parent.nil?\n []\n else\n parent.ancestors + [parent]\n end\n end",
"def parent_categories\n c = self\n categories = []\n until c.parent.blank? do\n c = c.parent\n categories.unshift c\n end\n categories\n end",
"def breadcrumb current\n return [] if current.nil?\n result = Array.new\n result << current\n while current = current.parent\n result << current\n end\n return result.reverse\n end",
"def hierarchy\n p = self\n h = []\n while(p.parent != nil)\n h = [p] + h\n p = p.parent\n end\n h = [p] + h\n \n h\n end",
"def path\n result = []\n obj = self\n while obj\n result.unshift(obj.__parent_name)\n obj = obj.__parent_struct\n end\n result.shift # we alwas add a nil for one-after-the-root\n result\n end",
"def ancestors\n itr = self\n res = []\n until itr.top_level?\n itr = itr.parents.first\n res << itr\n end\n res\n end",
"def ancestors\n []\n end",
"def menu\n if self.has_parent?\n menu = self.parent.menu\n else\n menu = {:levels=>0,:items=>Array.new}\n end\n\n if !self.menu_items.empty?\n menu[:items][ menu[:levels] ] = self.menu_items\n menu[:levels] = menu[:levels]+1\n end\n\n return menu\n end",
"def ancestors\n return [] if root?\n tree_search_class.find(self[tree_path_field])\n end",
"def ancestors\n parent ? [parent, *parent.ancestors].reverse : []\n end",
"def ancestors\n \tif parent_name.blank?\n\t \tancestors = [] \n \telse\n \t\tp = Category.where(name: parent_name).first\n \t\tancestors = p.ancestors\n \t\tancestors << parent_name\n \tend\n \tancestors\n end",
"def ancestors\n self.root? ? [] : self.parent.ancestors_and_self\n end",
"def parents\n @parents ||= parent ? parent.parents + Array(parent) : []\n end",
"def parents\n unless @parents\n @parents = []\n object = self\n while object.respond_to?(:parent) && object.parent\n @parents << object.parent\n object = object.parent\n end\n end\n @parents\n end",
"def menu_path()\n path, parent = [], self\n while parent\n path << parent.id\n parent = parent._parent\n end \n path.reverse\nend",
"def get_parents\n return @parents\n end",
"def parents\n if parent.nil?\n [self]\n else\n parent.parents + [self]\n end\n end",
"def category_tree\n cats = []\n categories.each do |cat|\n cats << cat\n cats = cats + cat.ancestors\n end\n return cats\n end",
"def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end",
"def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end",
"def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end",
"def ancestors\n parents + parents.map(&:ancestors).flatten\n end",
"def ancestors\n ancestors = []\n current_ancestor = self\n \n while !current_ancestor.nil?\n \n if current_ancestor.respond_to?(:parent)\n ancestors << current_ancestor\n current_ancestor = current_ancestor.parent\n else\n current_ancestor = nil\n end\n \n end\n \n ancestors\n end",
"def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end",
"def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end",
"def parents\n page, parents = self, Array.new\n while page.parent\n page = page.parent\n parents << page\n end\n parents\n end",
"def ancestors\n node_ancestors.map(&:ancestor)\n end",
"def parents\n @key.nil? ? [] : [@group.parents, @group].compact.flatten\n end",
"def ancestors \n \t\tres=parents\n \t\tparents.each {|c| res += c.ancestors}\n \t\treturn res.uniq\n \tend",
"def parents_and_self\n ret = []\n ret.concat(parent.parents_and_self) if parent\n ret << self\n ret\n end",
"def parent_menu_item_name\n menu_options[:parent]\n end",
"def ancestors\n @ancestors ||= parent ? parent.ancestors + [parent] : []\n end",
"def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end",
"def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end",
"def ancestors\n TreeNode.find(:all,\n :from => \"cms_treenode_ancestors(#{self.id}, #{AuthenticationModel.current_user}) tree_nodes\") rescue []\n end",
"def branches\n if ancestor_ids.empty? then\n nil\n else\n read_attribute(self.base_class.ancestry_column).to_s.split(',')\n end\n end",
"def parent parent\n @menu.parent parent\n end",
"def breadcrumbs\r\n\t\t\tself.parent.nil? ? [] : self.parent.breadcrumbs + [self]\r\n\t\tend",
"def ancestors\n @ancestors ||= [self] + (self.parent.try(:ancestors) || [])\n end",
"def root_menu_item_names\r\n root_menu_items.collect {|menu_item| menu_item.name}\r\n end",
"def get_parents\n parents = Array.new\n seen = Hash.new\n\n current = self.id\n \n while current\n role = Role.find(current)\n if role \n if not seen.has_key?(role.id)\n parents << role\n seen[role.id] = true\n current = role.parent_id\n else\n current = nil\n end\n else\n current = nil\n end\n end\n\n return parents\n end",
"def ancestors\n return @ancestors unless @ancestors.nil?\n # Stop if this is already the root node\n return @ancestors = [self] if File.basename(tree).empty?\n # Path for parent is blank if parent is root node\n parent_path = if File.dirname(tree) == '.'\n \"\"\n # Otherwise it is the directory in which this node is located\n else\n File.dirname tree\n end\n parent = git_flow_repo.working_file parent_path\n @ancestors = parent.ancestors + [ self ]\n end",
"def parent_rel_ids\n rel = relationships\n if rel.kind_of?(Array) || rel.try(:loaded?)\n rel.reject { |x| x.ancestry.blank? }.collect(&:parent_id)\n else\n rel.where.not(:ancestry => [nil, \"\"]).select(:ancestry).collect(&:parent_id)\n end\n end",
"def full_ancestry\n return id.to_s unless ancestry\n path_ids.join('/')\n end",
"def grand_children\n []\n end",
"def parent_hierarchy\n [\n parentADM4,\n parentADM3,\n parentADM2,\n parentADM1,\n parentCountry\n ].reject(&:empty?)\n end",
"def menu_ancestors\n # NOTE Root level menus are not links, shift it off. \"Home\" crumb is handled in app controller\n @menu_ancestors ||= (master_menu.try(:ancestors) || []).tap {|m| m.shift }\n end",
"def menus\n @_menus ||= nodes.map(&:root)\n end",
"def main_menu\n main_menu = parent\n return main_menu if main_menu.present?\n\n parent_menu = parent_item\n parent_menu.main_menu if parent_menu.present?\n end",
"def getAllParents\n parents = []\n parent = self.getParentRec\n self_code = self.code.split('.')\n self_code.pop(1)\n while self_code.length > 0 do\n puts \"self_code: #{self_code}\"\n if parent.present?\n parents << parent\n parent = parent.getParentRec\n self_code.pop(1)\n else\n parents << nil\n self_code.pop(1)\n parent = Tree.where(\n tree_type_id: self.tree_type_id,\n version_id: self.version_id,\n subject_id: self.subject_id,\n grade_band_id: self.grade_band_id,\n code: self_code.join(\".\")\n ).first\n end\n end\n Rails.logger.debug(\"*** tree parents: #{parents.inspect}\")\n return parents\n end",
"def categories\n categories = Array.new\n unless self.category.nil?\n categories << self.category\n categories += self.category.ancestors\n end # unless\n categories.reverse\n end",
"def ancestors_ids\n node, nodes = self, []\n while node.parent\n node = node.parent\n nodes << node.id\n end\n nodes\n end",
"def self_and_parents\n p = [self]\n parent = self.parent \n \n while parent do\n p << parent\n parent = parent.parent \n end\n p\n end",
"def ancestors\n @ancestors ||=\n begin\n x = [ self ]\n if ss = superstate\n x.push(*ss.ancestors)\n end\n NamedArray.new(x.freeze, :state)\n end\n end",
"def current_children\n children.map {|c| c.current }\n end",
"def submenu\n children.select { |item| item.shown_in_menu? }.sort\n end",
"def tree_path\n root = Category.root\n parent = self.parent\n path = self.name\n\n while !parent.nil? && parent != root do\n path = \"#{parent.name} > #{path}\"\n parent = parent.parent\n end\n\n return path\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def ancestors\n @cache[:ancestors]\n end",
"def ancestors\n self_and_ancestors - [self]\n end",
"def children\n []\n end",
"def children\n []\n end",
"def name_path_to_parent\n path = []\n p = parent\n while p do\n path.unshift p\n p = p.parent\n end\n path\n end",
"def parent_ids\n []\n end",
"def compute_ancestry(node)\n\n\t\t# compute ancestry and ancestry links\n\t\tif node.nav_level > 0\n\t\t\n\t\t\tancestors = node.link.split(\"/\")\n\t\t\tancestors.pop\n\t\t\tancestors_links = []\n\t\n\t\n\t\t\talink = node.link.dup\n\t\t\twhile alink.index(\"/\")\n\t\t\t\tancestors_links << alink.dup\n\t\t\t\talink = alink[0..(alink.rindex(\"/\") - 1)]\n\t\t\tend\t\t\t \n\t\t\tancestors_links << alink.dup\n\t\n\t\t\tancestors_links.reverse!.pop\n\t\n\t\tend\n\t\n\t\tnode.ancestors = ancestors.uniq if ancestors\n\t\tnode.ancestors_links = ancestors_links.uniq if ancestors\n\t\n\t\treturn node\n\tend",
"def child_ancestry\n # New records cannot have children\n raise Ancestry::AncestryException.new('No child ancestry for new record. Save record before performing tree operations.') if new_record?\n v = \"#{self.send \"#{self.base_class.ancestry_column}_was\"}\"\n return id.to_s if v.blank?\n v.split(',').map{|x| x + '/' + id.to_s}.join(',')\n end",
"def depth_first\n result = [self]\n if child_ids.empty?\n return result\n else\n children.sort.each do |child|\n result += child.depth_first\n end \n end\n return result \n end",
"def children\n []\n end",
"def ancestors\n end",
"def tree\n return [self] if @children.empty?\n\n @children.each_with_object([self]) do |child, tree|\n tree.concat(child.tree)\n end\n end",
"def lineage\n\t\tparents = []\n\t\tlist = self\n\t\twhile list.parentlist_id\n\t\t\tlist = List.find(list.parentlist_id)\n\t\t\tparents << list\n\t\tend\n\t\t\n\t\tif parents.length > 0\n \t\tparents.reverse!.slice(1..-1)\n else\n parents\n end\n end",
"def parents\n respond_to?(:collectionHasParent) ? collectionHasParent : []\n end",
"def ancestors(options={})\n return [] if top_level?\n objects = self.class.ancestors_of(self).scoped(options).group_by(&:id)\n index_path.map { |id| objects[id].first }\n end",
"def parent_list\n self.parent_lists[0]\n end",
"def ancestors_r(*args)\n # fetch all parents\n pending = [self]\n ans = []\n while !pending.empty?\n e = pending.pop\n e.parents(*args).each do |p|\n if !ans.include?(p)\n ans << p\n pending.push(p)\n end\n end\n end\n ans\n end",
"def ancestors\n (parent ? parent.ancestors : []) << self\n end",
"def parents\n options['parents'] || []\n end",
"def all_parents\n parents(all: true)\n end",
"def depth\n self.parents.size\n end",
"def self_and_ancestors\n \t\tres = [self] + self.ancestors\n \t\treturn res.uniq\n \tend",
"def children\n Array.new\n end",
"def ancestors; end",
"def ancestors; end",
"def ancestors; end",
"def ancestors; end",
"def path\n element = self\n items = [element.tag]\n while element.parent\n items.unshift element.parent.tag\n element = element.parent\n end\n items.join ' '\n end",
"def parent_resources\n @parent_resources ||= []\n end",
"def parents\n check_commit\n @parents \n end",
"def parent_ids\n if ancestor_ids.empty? then\n []\n else\n branches.map { |branch| cast_primary_key(branch.split('/').last) }.uniq\n end\n end",
"def category_menu_items(aRootCategory, aOptions={})\n\t\t\taBaseUrl = (aOptions[:base_url] || '')\n\t\t\taIdPrefix = (aOptions[:id_prefix] || '')\n\t\t\tcategory = aOptions[:category]\n\t\t\tcategory = category.name.urlize('+') if category.is_a?(Category)\n\t\t\ttree_nodes = construct_category_tree(aRootCategory)\n\t\n\t\t\t# now turn tree_nodes into menu items, still as array of levels\n\t\t\ttree_items = []\n\t\t\tlast_lvl = nil\n\t\t\ttree_nodes.each do |lvl|\n\t\t\t\titem_level = []\n\t\t\t\tlvl.each do |node|\n\t\t\t\t\tname = (node.name.index('/') ? File.basename(node.name) : node.name)\n\t\t\t\t\titem = {:id => aIdPrefix+node.id.to_s, :name => name }\t\n\t\t\t\t\titem[:node] = node\n\t\t\t\t\tif last_lvl && parent_item = last_lvl.find {|i| i[:node].id == node.parent_id}\n\t\t\t\t\t\tparent_item[:children] ||= []\n\t\t\t\t\t\tparent_item[:children] << item\n\t\t\t\t\t\titem[:url] = parent_item[:url]\n\t\t\t\t\t\titem[:url] += '+' unless item[:url]=='' || item[:url].ends_with?('/') || item[:url].ends_with?('+')\n\t\t\t\t\t\titem[:url] += name.urlize('-')\n\t\t\t\t\telse\n\t\t\t\t\t\titem[:url] = File.join(aBaseUrl,name.urlize('-'))\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\titem[:selected] = true if category && (category==node.name.urlize('+'))\n\t\t\t\t\titem[:order] = aOptions[:order_proc].call(item) if aOptions.has_key?(:order_proc)\n\t\t\t\t\titem_level << item\n\t\t\t\tend\n\t\t\t\ttree_items << item_level\n\t\t\t\tlast_lvl = item_level\n\t\t\tend\n\t\t\t# clean\n\t\t\ttree_items.each do |lvl|\n\t\t\t\tlvl.each do |i| \n\t\t\t\t\ti.filter_include!([:url,:selected,:id,:name,:children,:order])\n\t\t\t\t\ti[:children].sort! {|a,b| a[:order].to_i <=> b[:order].to_i} if i[:children].is_a?(Array)\n\t\t\t\tend\n\t\t\tend\n\t\t\ttree_items.first.sort! {|a,b| a[:order].to_i <=> b[:order].to_i}\n\t\t\ttree_items.first\n\t\tend"
] | [
"0.7125935",
"0.7011374",
"0.6952093",
"0.67846286",
"0.67312145",
"0.6708124",
"0.6677817",
"0.6674809",
"0.6640444",
"0.66075045",
"0.65922",
"0.6557865",
"0.6514077",
"0.6510032",
"0.6480869",
"0.64710355",
"0.6464979",
"0.6457203",
"0.6448548",
"0.6439901",
"0.64003",
"0.6396861",
"0.63846123",
"0.63790303",
"0.6375672",
"0.6356763",
"0.63422394",
"0.63422394",
"0.63373035",
"0.6299552",
"0.62883615",
"0.6273498",
"0.62730145",
"0.62720746",
"0.62514824",
"0.6207396",
"0.61703366",
"0.6162592",
"0.6156697",
"0.614613",
"0.6130283",
"0.6130283",
"0.6130215",
"0.60839826",
"0.60640424",
"0.6048485",
"0.60413015",
"0.6034592",
"0.6024494",
"0.6022117",
"0.60125464",
"0.5998061",
"0.5992259",
"0.598789",
"0.5974093",
"0.5972142",
"0.59477687",
"0.59016114",
"0.58943635",
"0.5877581",
"0.58137274",
"0.5808009",
"0.57998276",
"0.5793742",
"0.5787096",
"0.57805616",
"0.57805616",
"0.57805616",
"0.57767415",
"0.57669884",
"0.5763737",
"0.5763737",
"0.5761047",
"0.5759282",
"0.575765",
"0.57568705",
"0.5750119",
"0.57475215",
"0.57435113",
"0.57420266",
"0.5730456",
"0.572761",
"0.5723168",
"0.5722799",
"0.5722226",
"0.57144773",
"0.5704465",
"0.57009304",
"0.57001853",
"0.5695932",
"0.568784",
"0.5684159",
"0.5684159",
"0.5684159",
"0.5684159",
"0.56822497",
"0.56728786",
"0.56655496",
"0.5659208",
"0.565003"
] | 0.6418504 | 20 |
URL is not nil, empty, or '' | def real_url?(context = nil)
url = url context
url.present? && url != '#'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_provided?\n @url = params[:url]\n @url.present? && @url.strip\n end",
"def url_filled?\n !url.blank?\n end",
"def url?\n !url.nil?\n end",
"def real_url?\n url && url.present? && url != \"#\"\n end",
"def url?\n !urn?\n end",
"def valid_url?\n !Sailpoint.config.url.blank?\n end",
"def url_is(url = nil)\n url_is_empty if url.nil? && url_attribute.nil?\n url_is_empty if url.nil? || url.empty?\n @url = url\n end",
"def url_must_be_valid\n url.blank? ||\n (url_is_remote? and url_has_suffix? and url_matches?) ||\n errors.add(:url, :invalid)\n end",
"def has_website?\n !url.blank?\n end",
"def is_valid_url?\n (@url =~ URI::DEFAULT_PARSER.make_regexp) != nil\n end",
"def valid_url?\n\t\t# http:// or not http://\n\t\tx = self.long_url.start_with?(\"http://\", \"https://\")\n\t\tif x == false\n\t\t\treturn \"http://\" + self.long_url\n\t\telse\n\t\t\treturn self.long_url\n\t\tend\n\tend",
"def invalid_url?(url)\n url.include? 'hurl.it'\n end",
"def website?; website.to_s != \"\" end",
"def validate_full_url\n if self.full_url.nil?\n return\n end\n\n if((self.full_url =~ URI::regexp(\"http\")) == nil && (self.full_url =~ URI::regexp(\"https\")) == nil)\n self.errors.add(:full_url, \"Full url is not a valid url\")\n end\n end",
"def valid_link(link)\n\t\t!link.nil? and !link.empty?\n\tend",
"def valid_uri?\n !self.contentable.blank? || !self.uri_path.blank?\n end",
"def valid_url?\n # Not sure if we should make a change in the user initial data, we could just return as invalid.\n my_target_url = target_url.match(/http/) ? target_url : target_url.prepend(\"http://\")\n\n response = HTTParty.get(my_target_url) rescue nil\n\n return if response&.code == 200\n\n errors.add(:short_url)\n end",
"def value_url_valid?\n begin\n uri = URI.parse(value)\n uri = URI.parse(\"http://#{url}\") if uri.scheme.nil?\n if uri.scheme.downcase != 'http' and uri.scheme.downcase != 'https'\n @errors_data << 'validate_no_http_s_url'\n return false\n end\n value = uri.to_s\n return true\n rescue\n @errors_data << 'validate_invalid_url'\n return false\n end\n end",
"def valid?\n value.present? && uri.present?\n end",
"def absolute_url?(string); end",
"def proper_url? \n\t\tif !(self.long_url.start_with?('http://') || self.long_url.start_with?('https://'))\n\t\t\terrors.add(:long_url, \"is in invalid format.\")\n\t\tend \n\tend",
"def url_exist?\n\t\tbegin\n\t\t\turi = URI.parse(valid_url?)\n\t\t\tresponse = Net::HTTP.get_response(uri)\n\t\trescue \n\t\t\terrors.add(:long_url,\"is invalid url\")\n\t\t\t# in AR, error is a class by itself already \n\t\t\t# go to static.rb to check the errors\n\t\tend\n\tend",
"def url?(uri)\n /\\w+\\:\\/\\// =~ uri\n end",
"def normalize_url\n return if self.url.blank?\n normalized = self.url.normalize\n if normalized.blank?\n self.errors.add(:url, \"is invalid\")\n return false\n elsif normalized.match(\"archiveofourown.org/users\")\n self.errors.add(:url, \"cannot be ao3 user\")\n return false\n elsif normalized.match(\"(.*)/collections/(.*)/works/(.*)\")\n normalized = $1 + \"/works/\" + $3\n elsif normalized.match(\"archiveofourown.org/collections\")\n self.errors.add(:url, \"cannot be an ao3 collection\")\n return false\n end\n self.url = normalized\n end",
"def valid_url?\n @url =~ URI::regexp\n end",
"def url?(uri)\n /\\w+\\:\\/\\// =~ uri\n end",
"def url_ok(url)\n return url =~ URI::ABS_URI\n end",
"def url_is_valid\n errors.add(:url, \"url is not valid\") unless is_http_url? || is_spotify_url?\n end",
"def valid_url?(url)\n return false if url.nil? || url.strip.empty?\n\n URI(url)\n true\n rescue URI::InvalidURIError\n false\n end",
"def is_valid_url?(url)\n if (url =~ /\\A#{URI::DEFAULT_PARSER.make_regexp}\\z/) == 0\n return true\n else\n return false\n end\n end",
"def clean_url\n #use try instead for nil?\n unless self.url.nil?\n parsed_url = URI.parse(self.url).host.sub(/\\Awww\\./, '')\n else\n nil\n end\n end",
"def check_if_link_is_valid\n uri = URI.parse(self.url.split(\" \")[0])\n self.url = uri\n if !%w( http https ).include?(uri.scheme)\n self.url = nil\n end\n end",
"def clean_url\n return # Not yet implemented\n end",
"def validate_uri(url)\n !!URI.parse(url)\n end",
"def is_url?\n path =~ URL_PATHS\n end",
"def valid?\n (uri.host =~ LINK_REGEX || uri.host =~ LINK_IP_REGEX) ? true : false\n end",
"def validate_uri(url)\n !!URI.parse(url)\n end",
"def scraped?\n !url.blank?\n end",
"def is_unknown_url? url\n @urls.count_documents(url:url) == 0\n end",
"def validate\n needs :http_url unless http_url\n end",
"def facebook_url_exists?\n return false if facebook == \"\" || twitter == nil\n return true\n end",
"def valid?\n Wgit::Url.valid?(self)\n end",
"def usable_link?(type, url)\n case type\n when :twitter\n # twitter users starting with _ (like _NapervilleIl) are weatherbugs\n # if the username does not start with _ it is a valid username\n (url.match(/^http:\\/\\/(?:www\\.)?twitter.com[^\\/]*\\/[^_]/)) && (! url.match(/\\/share|\\/goodies/))\n when :facebook\n url.match(/^http:\\/\\/(?:www\\.)?facebook.com/)\n else\n true\n end\n end",
"def good_resource?(url)\n if rx_url\n !(url.to_s !~ rx_url)\n else\n true\n end\n end",
"def fake_url?\n url =~ /^\\d\\d\\d\\d-/\n end",
"def valid_feed?(item)\n !item['url'].to_s.strip.empty?\n end",
"def url?(string)\n return false unless string.to_s =~ url_pattern\n return false if string.to_s =~ @@placeholder\n true\n end",
"def test_non_url_value_gives_empty_string\n assert_equal( '', @incomplete[ :url ] )\n end",
"def off_site?(url)\n url !~ /^\\// # urls not starting with a /\n end",
"def valid_url?(url)\n resp = Curl.get url\n\n if resp.body_str.include? @invalid_text\n return false\n else\n return true\n end\nend",
"def validate_url_format\n valid_url = false\n begin\n uri = URI.parse(url)\n valid_url = uri.scheme.present? || uri.host.present?\n rescue URI::InvalidURIError\n valid_url = false\n end\n errors.add(:url, 'format is invalid') unless valid_url\n end",
"def automatic_url\n\t\t\t\t\treturn !self.nature.blank? && !config(:natures, self.nature.to_sym, :url).blank?\n\t\t\t\tend",
"def is_url_valid\n\t\tunless self.long_url.starts_with?(\"http://\", \"https://\")\n\t\t\terrors.add(:long_url, \"invalid format\")\n\t\tend\n\tend",
"def no_valid_url?(arr)\n #debugger\n options = [\".com\", \".net\", \".io\", \".org\"]\n arr.none? do |url|\n options.any?{|suffix| url.end_with?(suffix)} \n end\nend",
"def check_params(longurl)\n if longurl==\"\"\n return false\n else \n short_domain = ShortDomain.where(domain: Domainatrix.parse(longurl).domain + '.' + Domainatrix.parse(longurl).public_suffix).first\n if short_domain == nil\n return false\n else\n return true\n end\n end\n end",
"def render_url(url)\n url.blank? ? 'link not available' : absolutize_url(url)\n end",
"def check_uri_build\n\n end",
"def ensure_params_url\n if !params[:url]\n render json: ['No URL has been provided.'], status: 422 \n else \n render json: ['Url format is Improper.'], status: 422 unless ShortURL.validate_url_format(params[:url])\n end\n end",
"def is_static?\n self.url.blank?\n end",
"def valid_download?\n @download_url != \"\"\n end",
"def link?\n !link.nil? && !link.empty?\n end",
"def link?\n !link.nil? && !link.empty?\n end",
"def is_url?\n self =~ /^#{URI::regexp}$/\n end",
"def validate_url\n self.url = ExternalWork.format_url(self.url)\n errors.add_to_base(t('invalid_url', :default => \"Not a valid URL\")) unless self.url_active?\n end",
"def check_submissions(url)\n url = url.downcase\n if url.include?(\"http://www.\")\n valid_url?(url) ? url : false\n elsif url.include?(\"www.\")\n valid_url?(url.insert(0,\"http://\")) ? url : false\n else\n valid_url?(url.insert(0,\"http://www.\")) ? url : false\n end\nend",
"def check_url_validation\n errors.add(:url, I18n.t('url_not_proper')) unless UrlShort.is_valid? (url)\n end",
"def validate_url\n url = params[:url] || params[:program][:url]\n begin\n URI.parse(url) if url\n rescue URI::InvalidURIError\n raise ExceptionTypes::BadRequestError.new(\"Invalid characters used in URL: #{url}\")\n end\n end",
"def invalid_uri?(uri)\n uri.grep(/^(#{PROTOCOLS.join('|')}):\\/\\/\\w/).empty?\n end",
"def validates_presence_of_urls\n if provider_media_id.blank?\n !( source_url.blank? || thumbnail_url.blank? || content_url.blank? )\n else\n true\n end\n end",
"def url?\n children[0] && children[0].is_a?(Url)\n end",
"def location_empty?( attr )\n attr[ 'uri' ].blank? &&\n attr[ 'file_name' ].blank? &&\n attr[ 'doc_code' ].blank? &&\n attr[ 'doc_version' ].blank?\n end",
"def validate_url\n return head(:bad_request, content_type: 'application/json') unless params[:shorten][:url]\n end",
"def is_a_real_url?\n begin\n URI.parse(long_url)\n rescue URI::InvalidURIError\n errors.add(:message, \"must be a valid URL\")\n end \n end",
"def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end",
"def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end",
"def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end",
"def url?(link)\n true if link =~ /\\Ahttps?:\\/\\//\nend",
"def url; (page.url rescue ''); end",
"def url; (page.url rescue ''); end",
"def url_has_a_dot_in?\n (external_resource_url =~ /\\./ )\n end",
"def is_url?( path )\n path =~ URI::ABS_URI\nend",
"def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end",
"def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end",
"def url_valid?(url)\n url = URI.parse(url) rescue false\n url.kind_of?(URI::HTTP) || url.kind_of?(URI::HTTPS)\n end",
"def validate_target_url(item)\n error(msg: 'Invalid URL', item: __method__.to_s) unless item =~ URI::DEFAULT_PARSER.make_regexp\n end",
"def assert_url\n begin\n URI.parse(url)\n return true\n rescue URI::InvalidURIError => e\n errors.add(\"url\", \"has invalid format\")\n return false\n end\n end",
"def valid_url?(url)\n uri = URI.parse(url)\n\n uri.absolute?\n rescue\n false\n end",
"def valid_target_url?\n return false unless cloud_info = cloud_info()\n return false unless cloud_info[:name]\n return false unless cloud_info[:build]\n return false unless cloud_info[:support]\n return false unless cloud_info[:version]\n true\n rescue\n false\n end",
"def valid_url\n unless UrlValidator.valid_entry_url? self.url\n errors.add :url, \"URL #{self.url} is not a valid http, https or protocol-relative URL\"\n end\n end",
"def absolute_url?\n (self.include?('://') || self.start_with?('/')) ? true : false\n end",
"def validate(url)\n if url && url.is_a?(String) && url.match(/(^$)|(^(http|https):\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(([0-9]{1,5})?\\/.*)?$)/ix)\n return true\n else\n raise InvalidURL\n end\n end",
"def links_valid_params(params)\n if params[:link_name].strip == \"\" || params[:link_description].strip == \"\" || params[:category_name].strip == \"\"\n false\n else\n true\n end\n end",
"def url\n self[:url].blank? ? \"/\" : self[:url]\n end",
"def validate_uri(uri)\n validate_text(Net::HTTP.get(URI.parse(uri)))\n end",
"def image_url_provided?\n !self.image_url.blank?\n end",
"def validate\n unless self.uri.blank?\n self.uri = \"http://#{self.uri}\" unless URI.parse(self.uri).absolute? \n end\n rescue\n errors.add(:uri, \"malformed uri -- please check it\")\n end",
"def needs_seo (url)\n if url.description.nil? || url.keywords.nil?\n return true\n else\n return false\n end\nend",
"def url_valid?\n uri = URI(full_url)\n Net::HTTP.start(uri.host, uri.port, :use_ssl => full_url.start_with?(\"https\")) do |http|\n response = http.request_get(full_url)\n return response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPRedirection)\n end\n end",
"def is_valid_description?(description)\n description && !description.include?('http://')\n end",
"def is_url? string\n uri = URI.parse(string)\n %w( http https ).include?(uri.scheme)\n rescue URI::BadURIError\n false\n rescue URI::InvalidURIError\n false\n end"
] | [
"0.8212927",
"0.8135746",
"0.7999424",
"0.77198297",
"0.76626205",
"0.7600492",
"0.7549009",
"0.74865544",
"0.7419769",
"0.7349313",
"0.7157547",
"0.7145534",
"0.71327543",
"0.70180345",
"0.7016414",
"0.69954807",
"0.69872063",
"0.69795066",
"0.6971648",
"0.6949966",
"0.6940145",
"0.6913143",
"0.68678373",
"0.6853644",
"0.681383",
"0.68085665",
"0.68073857",
"0.6803106",
"0.67846435",
"0.6781147",
"0.6777503",
"0.6771571",
"0.67666686",
"0.6764788",
"0.67586267",
"0.67584085",
"0.67452943",
"0.67169726",
"0.6715749",
"0.670905",
"0.66845924",
"0.66637635",
"0.6661226",
"0.66543627",
"0.6654348",
"0.6648918",
"0.66424125",
"0.6622436",
"0.6600761",
"0.6592337",
"0.65906453",
"0.65905267",
"0.65891314",
"0.65591353",
"0.65566355",
"0.6543603",
"0.65260595",
"0.65220976",
"0.652014",
"0.6519674",
"0.651299",
"0.651299",
"0.65107316",
"0.6497852",
"0.64833254",
"0.648283",
"0.64765096",
"0.6469626",
"0.6456213",
"0.643069",
"0.64306086",
"0.6427171",
"0.64263386",
"0.6412883",
"0.6412883",
"0.6412883",
"0.64118004",
"0.64115417",
"0.64115417",
"0.6410189",
"0.6404605",
"0.64014703",
"0.64014703",
"0.64014703",
"0.6390251",
"0.6381813",
"0.63701385",
"0.6356183",
"0.6351275",
"0.6348126",
"0.63440114",
"0.63413924",
"0.63203686",
"0.6318306",
"0.63112324",
"0.63100135",
"0.62968016",
"0.6295526",
"0.62954444",
"0.6294116"
] | 0.6732138 | 37 |
Functions Library move card from deck to stack | def move_card(draw, play)
if play.empty? && draw.any?
play << draw.shift
elsif draw.any? && (within_one?(draw[0].rank.to_i, play[-1].rank.to_i))
play << draw.shift
else
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal_into_new_stack(deck)\n deck.reverse\nend",
"def take_card\n @deck.shift\n end",
"def return_card( card )\n @deck.unshift( card )\n end",
"def deal_card\n @deck.pop\n end",
"def deal\r\n @deck_of_cards.shift\r\n end",
"def push(card)\n error_unless_param_is_a_card card, \"push\"\n @stack.push(card)\n end",
"def deal\n @deckOfCards.shift\n end",
"def move_card(card, destination)\n card.location = destination\n card.save\n end",
"def move_card( card, places )\n \n n = places\n card_locus = @deck.index( card )\n while (n != 0) do\n \n if (card_locus + 1 < @deck.length )\n @deck[card_locus], @deck[card_locus +1] = @deck[card_locus+1], @deck[card_locus]\n card_locus = card_locus+1\n else\n card = @deck.slice!(card_locus)\n @deck.insert(1, card)\n card_locus = 1\n \n end\n # subtract 1 from n\n n -= 1\n \n end\n \n end",
"def movedeck_to(direction)\r\n @log.debug \"gfx: Move deck to #{direction}\"\r\n model_canvas_gfx = @gfx_res.model_canvas_gfx\r\n \r\n img_coperto = @gfx_res.get_cardsymbolimage_of(:coperto)\r\n #img_opponent_deck = @image_gfx_resource[:card_opp_img]\r\n \r\n x_deck_start = model_canvas_gfx.info[:canvas][:width] - (img_coperto.width + 30)\r\n y_deck_start = 10\r\n if direction == :sud\r\n y_deck_start = (model_canvas_gfx.info[:canvas][:height] - (img_coperto.height)) \r\n end\r\n \r\n model_canvas_gfx.info[:deck_info][:position] = {:x_deck_start => x_deck_start, :y_deck_start => y_deck_start }\r\n \r\n \r\n end",
"def hit(hand, deck)\n hand.push(deck.pop)\nend",
"def deal_card\r\n\t\tcards.pop\r\n\tend",
"def drawcard\n @deck.pop\n end",
"def push(card)\n @pile.push(card)\n card.arm!\n end",
"def add_card(card)\n @deck.add(card, :back)\n end",
"def deal\r\n @cards.shift\r\n end",
"def deal_card\n @deck.remove(:front)\n end",
"def hit\n @cards.push @deck.shift\n end",
"def drawCard\n\t\t@hand = @hand.push(@deck.pop)\n\tend",
"def deal\n @deck.shift\n end",
"def deal_card(game_deck,player)\n card = game_deck.deck.pop\n ace_checker(card,player)\n player.hand.push(card)\n puts\"#{player.player_name} received #{card.identify}\"\n puts \"Current hand: #{player.display_hand}\"\n win_or_bust(player)\n hit_or_stay(player)\nend",
"def place(card)\n end",
"def remove_card\n @cards.shift\n\n end",
"def choose_card \n\n @cards.shift\n end",
"def get_card\n @deck.pop\n end",
"def deal_post_flop\n # Burns the top card of the deck.\n @deck.cards.shift\n # Moves the top card of the deck into the community table cards array.\n @community_cards.push(@deck.cards.shift)\n print 'The community cards are: '\n puts \"\"\n card_output(@community_cards)\n puts \"\"\n sleep(3)\nend",
"def remove_card\n @cards.shift\n end",
"def deal(card)\n\t\[email protected](card)\n\tend",
"def take!\n\t\[email protected]\n\tend",
"def lay_card\n @hand.shift\n end",
"def move_card_down(card, num_spots)\n card_index = @cards.index(card)\n new_index = (card_index + num_spots)\n if new_index > 53\n new_index = (new_index % 54) + 1 # The plus 1 prevents it from becoming the first card\n end\n @cards.delete_at(card_index)\n @cards.insert(new_index, card)\n end",
"def deal_card\n @cards.pop\n end",
"def take_card\n @store.pop\n end",
"def remove_card_from_deck (card)\n\t\t@deck -= [card]\n\tend",
"def create_card(deck)\n card = deck.shuffle.pop\nend",
"def card10(player)\n player.position -= 3\n end",
"def hit!(deck)\n @dealt << deck.cards.shift\n end",
"def move(from, card, to)\n from_pile = parse_pile(from)\n to_pile = parse_pile(to)\n result = from_pile.move(card, to_pile)\n puts ascii\n result\n end",
"def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end",
"def pop_card_top\n @cardList.pop\n end",
"def move_joker_b\n b_pos = $deck.find_index('B')\n $deck.delete('B')\n if b_pos == 51\n $deck << 'B'\n else\n $deck.insert (b_pos + 2) % 53, 'B'\n end\nend",
"def draw_card\n #change for chapel if no card to draw\n if ! (top_card = deckcards.find_by(library_position: 1))\n shuffle\n top_card = deckcards.find_by(library_position: 1)\n end\n top_card.status = \"hand\"\n top_card.library_position = nil\n top_card.save\n library.each do |library_member|\n library_member.library_position -=1\n library_member.save\n end\n top_card\n end",
"def move_joker_a\n a_pos = $deck.find_index('A')\n if a_pos == 53\n $deck.delete 'A'\n $deck.insert 1, 'A'\n else\n temp = $deck[a_pos + 1]\n $deck[a_pos + 1] = $deck[a_pos]\n $deck[a_pos] = temp\n end\nend",
"def pull_from(index)\n error_unless_index_is_in_bounds index\n\n card = @stack[index]\n @stack.delete_at index\n card\n end",
"def add_card_to_top(card)\n unless self.id.nil? or (card.deck_id == self.id and card.card_order == get_top_order)\n #Update order of card's current deck\n if card.deck_id\n card.deck.cards.where(\"card_order > ?\", card.card_order).each do |r|\n r.update_attributes(card_order: (r.card_order-1) )\n end\n end\n # Add the card to the top of the new deck\n card.update_attributes(deck_id: id, card_order: (get_top_order+1) )\n end\n end",
"def turn_card(guess)\n @board[guess].reveal\n @player.store_cards(guess, @board[guess].value)\n p @player.store\n end",
"def draw\n @deck.shift\n end",
"def add_cards_to_deck(card)\n @game_deck.deck << card\n end",
"def deal_flop\n # Burns the top card of the deck.\n @deck.cards.shift\n # Moves the top three cards of the deck into the community table cards array.\n @community_cards = @deck.cards.shift(3)\n puts ''\n print 'The flop is: '\n card_output(@community_cards)\n puts \"\"\n sleep(3)\nend",
"def remove_card\n cards.shift\n return cards\n end",
"def draw_into(deck)\n card = draw\n deck << card\n card\n end",
"def deal\n puts @deck.first\n @deck.shift\n end",
"def take_card(card)\n @cards << card\n end",
"def take_card\n raise OutOfCardsError if empty?\n @cards.pop\n end",
"def deal_card(hand)\n #hand is a string whose valid values are 'player_cards' and 'dealer_cards' \n\n if !['player_cards','dealer_cards'].include?(hand)\n raise \"Unknown hand #{hand}\"\n end \n\n #Check for an empty deck and reshuffle if necessary\n if (session['game_cards'].length == 0) \n\n session['game_cards'] = session['discard']\n session['game_cards'].shuffle!\n session['discard'] = []\n append_message(\"Dealer shuffled the cards.\") \n\n end \n\n #Move the card\n session[hand] << session['game_cards'].pop \n\n end",
"def deal\n # pack cards past the default 12 into the begining\n if @cards.length > 12\n # cards still in play past the standard 12 positions\n extra = @cards.last(@cards.length - 12).compact\n # move what can be moved into the standard 12 positions\n @cards = @cards.take(12).map! { |c| c || extra.pop }\n # hopefully extra is empty now, but maybe not\n @cards += extra\n end\n\n # sets is still valid as we haven't modified the combinaion of cards in play\n # do we need to expand the cards in play?\n if(@sets && @sets.none?)\n @cards += Array.new(3)\n end\n \n ## fill any gaps from the deck\n @cards.map! { |x| x || @deck.pop }\n\n # recompute sets\n #@sets = []\n @sets = IsASet.sets @cards.compact\n end",
"def flip_to_next_card\n @flashcard_deck.next_card\n @current_card = @flashcard_deck.current_card\n end",
"def deal()\n card = self.cards.shift()\n raise \"Cannot deal more than 52 cards.\" unless card\n return card\n end",
"def move_down( index )\r\n if index == @deck.length - 1\r\n @deck[1..1] = @deck[index], @deck[1]\r\n @deck.pop\r\n else\r\n @deck[index], @deck[index + 1] = @deck[index + 1], @deck[index]\r\n end\r\n end",
"def draw\n @cards.shift\n end",
"def deal_one\n cards.pop\n end",
"def add_top (card)\n @cards.push(card);\n end",
"def add_card card\n card.deck = self\n @cards[card.id] = card\n end",
"def reset_discard_pile(deck)\n @cards = []\n @cards << deck.take_card\n while @cards[0].color == 'Wild' || @cards[0].number.is_a?(String)\n deck.cards.unshift(@cards.pop)\n @cards << deck.take_card\n end\n @cards\n end",
"def discard(card)\n discard_pile << card\n end",
"def get_card_and_put_in_hand(which_hand)\n the_card = @deck_current.delete_at(rand(@deck_current.length))\n\n if which_hand === \"dealer\"\n @hand_dealer.push(the_card)\n\n elsif which_hand === \"player\"\n @hand_player.push(the_card)\n\n end\n \nend",
"def redeal\n # take all current cards in play and add to deck\n @deck.concat(@cards_in_play)\n @cards_in_play = Array.new\n\n #shuffle cards \n @deck.shuffle!\n\n #deal 12 more new cards\n @cards_in_play.concat(@deck.pop(12))\nend",
"def deal_cards\n\t\t\tend",
"def draw_card\n #suit = Card::SUITS.sample\n #rank = Card::RANKS.sample\n #Card.new(suit: suit, rank: rank)\n @cards.pop\n end",
"def give_new_card_from_deck(token, player)\n raise 'Only Game or action resolvers should call this method' if token != @action_token\n player.receive_cards(@main_token, [@deck.shift])\n end",
"def deal_turn\n @pokerdeck.pop\n turn = @pokerdeck.pop\n @communal_cards << turn\n return turn\n end",
"def action_useCard(pockerCard_id)\n\n if check_cardOwn(pockerCard_id) and check_currentTurn()#only owner can play card and current turn on\n if check_usableNumShape(pockerCard_id) #check bottom number and shape\n\n sourcePlayer_id = Game.last.players.by_user(current_user).id\n destPlayer_id = Game.last.players.dummy.id # destPlayer_id = 2 (dummy) \n\n action_moveCard(dest_id: destPlayer_id, source_id: sourcePlayer_id, card_id: pockerCard_id)\n\n #check effect of cards\n card_effect = Pockercard.find(pockerCard_id).effect\n action_addDummyList(pockerCard_id)\n action_putBottomCard(pockerCard_id)\n if card_effect == \"none\"\n action_endTurn(1) #move to next player=[\n elsif card_effect == \"back\" \n Game.last.toggle_order!\n action_endTurn(1) #skip next player\n elsif card_effect == \"jump\" \n action_endTurn(2) #move to next next player\n elsif card_effect == \"attack\"\n action_attackCard(pockerCard_id)\n action_endTurn(1) #move to next next player\n elsif card_effect == \"change\"\n action_setBottomCardStep()\n elsif card_effect == \"onemore\" \n else\n action_endTurn(1) #skip next player\n end\n check_winOrLose() \n end\n end\n\n\n\n end",
"def deal_card!(cards)\n\nend",
"def deal\n\n @first_card = @cards.shift\n\n return @first_card\n\n end",
"def deal_cards (num_cards, deck)\n dealt_cards = []\n num_cards.times {dealt_cards << deck.pop}\n dealt_cards\nend",
"def pick\n raise NoMoreCardsException.new(\"Deck is empty\") if cards_left == 0\n @deck.shift\n end",
"def move_card(card_id, options)\n unless options.is_a?(Hash) && ([:board_id, :list_id, :pos].any? { |key| options.key? key })\n raise ArgumentError, \"Required option: :pos, :board_id and/or :list_id\"\n end\n update_card(card_id, options)\n end",
"def hit!\n\t\t@cards << @deck.take!\n\tend",
"def hit \n card = self.cards_deck.pop\n return card\n end",
"def deal_cards(cards)\n @players.each do |player|\n player.hand += @deck.cards.pop(cards)\n end\n end",
"def pile_cards\n if type == :basic\n @spoils_of_war << @player1.deck.cards[0]\n @spoils_of_war << @player2.deck.cards[0]\n @player1.deck.cards.shift\n @player2.deck.cards.shift\n elsif type == :war\n @spoils_of_war << @player1.deck.cards[0]\n @spoils_of_war << @player1.deck.cards[1]\n @spoils_of_war << @player1.deck.cards[2]\n @spoils_of_war << @player2.deck.cards[0]\n @spoils_of_war << @player2.deck.cards[1]\n @spoils_of_war << @player2.deck.cards[2]\n @player1.deck.cards.shift(3)\n @player2.deck.cards.shift(3)\n else\n @player1.deck.cards.shift(3)\n @player2.deck.cards.shift(3)\n p \"MUTALLY ASSURED DESTRUCTION\"\n end\n end",
"def move_cards(list_from_name, list_to_name)\n\tfrom_list = get_list(list_from_name)\n\tto_list = get_list(list_to_name)\n\n # if from_list == nil || to_list == nil\n # p \"nil list error, check list names\"\n # return \n # end\n cards = get_cards(from_list)\n cards.each do |card|\n \tif card.badges[\"checkItems\"] == card.badges[\"checkItemsChecked\"]\n \t\tcard.move_to_list(to_list)\n \tend\n end\nend",
"def pull(card)\n card = self.cards.delete(card)\n raise \"Cannot find card. May already have been dealt\" unless card\n return card\n end",
"def flip_deck\n if @deck.empty?\n if @recycle_count < @recycle_limit\n @deck = @discard.reverse.collect {|c| c.flip}\n @discard = CardArray.new\n @recycle_count += 1\n else\n nil\n end\n else\n @discard.push @deck.pop\n end\n @discard.first.flip\n end",
"def create_52_card_deck\n\n end",
"def deal_card\n if @unshuffled_deck[-1] == nil\n @unshuffled_deck = @addhand\n @addhand = @emptyarray\n @x = 0\n end\n card = @unshuffled_deck[@x]\n @unshuffled_deck[@x] = nil\n @x+=1\n return card\n end",
"def return(cards)\n @deck += cards\n end",
"def hand_over_player \r\n puts \"Player getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @player_deck[@random_card] = random_card_val # to player\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@player_deck = #{@player_deck}\"\r\n\r\n end",
"def shuffle_the_deck(params)\n stack = CardStack.new\n card_data = params[:deck]\n\n card_data.split(\",\").each do |datum|\n card_hash = Card.convert_short_string_to_hash datum\n stack.push Card.new(card_hash)\n end\n\n Shuffler.send(@shuffle_type, stack)[:shuffled_stack]\n end",
"def draw_card\n self.cards.pop\n end",
"def deal_a_card(players_hand, deck_final)\n players_hand << deck_final.pop\n return players_hand, deck_final\nend",
"def replace_card_with_new(player, card)\n @deck << card\n @deck.shuffle!\n new_card = @deck.shift\n return if new_card == card\n # This will raise if player didn't have the old card\n player.replace_cards(@main_token, [card], [new_card])\n @output_streams.each { |os| os.new_cards(player.user) }\n end",
"def draw\n raise \"not enough cards\" if @cards.empty?\n @cards.shift\n end",
"def deal_card(player)\n if !self.is_empty?\n player.hand << cards.pop\n else\n self.initialize(1)\n end\n end",
"def get_cards(deck)\n\n end",
"def player_push_shuffle(event)\n if (event.x > 580 && event.x < 780 && event.y > 640 && event.y < 690) \n @card_id_on_table.each_index { |i| @card_on_table[i].remove_top }\n @deck.concat(@card_id_on_table).shuffle\n @card_id_on_table = @deck[0,12]\n @deck = @deck[12,@deck.length-1]\n @card_id_on_table.each_index { |i| @card_on_table[i] = Card.new(@card_id_on_table[i], i) }\n @card_id_on_table.each_index { |i| @card_on_table[i].draw_top }\n end\n end",
"def add_deck_to_top(add_deck)\n if add_deck.cards and add_deck.id != self.id and add_deck.cards.size > 0\n orig_count = self.cards.size\n add_deck.cards.each do |c|\n c.update_attributes(deck_id: id, card_order: (c.card_order + orig_count))\n end\n end\n end",
"def get_card(deck, n)\n new_card = deck.cards.pop(n)\n cards << new_card\n cards.flatten!\n new_card\n end",
"def give_card_to_player(card,player)\n\t\t#player is another player object\n\t\t@cards[card].times do\n\t\t\tplayer.add_card(card)\n\t\tend\n\n\n\t\t#remove cards from hand if selected by another player\n\t\tself.remove_set_from_hand(card)\n\tend",
"def deal_dealer_card\n\n card = @deck.delete_at(0)\n @dealer_hand << card\n\n end"
] | [
"0.766868",
"0.74520534",
"0.7253454",
"0.72173864",
"0.7151119",
"0.7108545",
"0.70602274",
"0.7041853",
"0.70294833",
"0.697316",
"0.6908366",
"0.69046754",
"0.6884878",
"0.68825686",
"0.6877643",
"0.68770814",
"0.68652296",
"0.68631244",
"0.68462694",
"0.68100035",
"0.6803084",
"0.67744523",
"0.6768475",
"0.67324454",
"0.6728005",
"0.67234755",
"0.67230576",
"0.6670616",
"0.6657027",
"0.6656323",
"0.6651943",
"0.66123486",
"0.66054845",
"0.6581602",
"0.657425",
"0.65691775",
"0.6543795",
"0.6521124",
"0.6514614",
"0.6513716",
"0.65001476",
"0.6500026",
"0.6470196",
"0.6463249",
"0.64545316",
"0.645148",
"0.64466906",
"0.64452404",
"0.6438793",
"0.64210105",
"0.6413426",
"0.64126676",
"0.6406503",
"0.6404737",
"0.63820225",
"0.6372919",
"0.6370651",
"0.63555044",
"0.6352878",
"0.63401204",
"0.6312575",
"0.6289475",
"0.6285945",
"0.6281087",
"0.6271725",
"0.62674063",
"0.62624556",
"0.62529826",
"0.6248845",
"0.62482333",
"0.62477994",
"0.6243391",
"0.623791",
"0.6223822",
"0.6214976",
"0.6205627",
"0.62021106",
"0.6199569",
"0.6199532",
"0.6192563",
"0.61871666",
"0.6183169",
"0.61818045",
"0.61811775",
"0.61769956",
"0.6171972",
"0.61679465",
"0.61646223",
"0.61554885",
"0.61436737",
"0.61436635",
"0.61218417",
"0.6120091",
"0.61074466",
"0.61045474",
"0.6097214",
"0.60960937",
"0.6076457",
"0.6074855",
"0.6074458"
] | 0.66227645 | 31 |
move card from stack to stack def move_pile(play1, play2) if play2.empty? play2.concat(play1) play1.clear elsif (within_one?(play1[0].rank.to_i, play2[1].rank.to_i) && (within_one?(play1[0].rank.to_i, play2[1].rank.to_i))) print "front or back?" side=gets.chomp if side == "front" play1.concat(play2) play2.clear elsif side == "back" play2.concat(play1) play1.clear else end elsif (within_one?(play1[0].rank.to_i, play2[1].rank.to_i)) play1.concat(play2) play1.clear elsif (within_one?(play1[0].rank.to_i, play2[0].rank.to_i)) play1.concat(play2) play1.clear else end end Move pile of cards Experimental | def move_pile(play1, play2)
if play2.empty?
play2.concat(play1)
play1.clear
elsif (within_one?(play1[0].rank.to_i, play2[-1].rank.to_i))
play2.concat(play1)
play1.clear
else
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_card(draw, play)\n if play.empty? && draw.any?\n play << draw.shift\n elsif draw.any? && (within_one?(draw[0].rank.to_i, play[-1].rank.to_i))\n play << draw.shift\n else\n end\nend",
"def pile_cards\n if type == :basic\n @spoils_of_war << @player1.deck.cards[0]\n @spoils_of_war << @player2.deck.cards[0]\n @player1.deck.cards.shift\n @player2.deck.cards.shift\n elsif type == :war\n @spoils_of_war << @player1.deck.cards[0]\n @spoils_of_war << @player1.deck.cards[1]\n @spoils_of_war << @player1.deck.cards[2]\n @spoils_of_war << @player2.deck.cards[0]\n @spoils_of_war << @player2.deck.cards[1]\n @spoils_of_war << @player2.deck.cards[2]\n @player1.deck.cards.shift(3)\n @player2.deck.cards.shift(3)\n else\n @player1.deck.cards.shift(3)\n @player2.deck.cards.shift(3)\n p \"MUTALLY ASSURED DESTRUCTION\"\n end\n end",
"def pile_cards\n players = [@player1, @player2]\n if type == :basic\n players.each do |player|\n @spoils_of_war << player.deck.cards[0]\n player.deck.remove_card\n end\n elsif type == :war\n players.each do |player|\n @spoils_of_war << player.deck.cards[0..2]\n 3.times do\n player.deck.remove_card\n end\n @spoils_of_war = @spoils_of_war.flatten\n end\n elsif type == :mutually_assured_destruction\n players.each do |player|\n 3.times do\n player.deck.remove_card\n end\n end\n # replace 'No Winner' with nil so it can be tested in award_spoils\n @turn_winner = nil\n end\n end",
"def play_card(pile, card)\n fail 'cannot play card outside your hand' unless cards.include?(card)\n\n if card.value == :eight\n pile.play_eight(card, favorite_suit)\n else\n pile.play(card)\n end\n\n cards.delete(card)\n end",
"def move(from, card, to)\n from_pile = parse_pile(from)\n to_pile = parse_pile(to)\n result = from_pile.move(card, to_pile)\n puts ascii\n result\n end",
"def test_reshuffle_discard_into_draw\n # drain the draw pile into the discard pile\n while [email protected]_pile.is_empty?\n @manager.discard_top_card\n end\n assert_equal([], @manager.draw_pile.cards)\n assert_not_equal([], @manager.discard_pile.cards)\n\n @manager.reshuffle_discard_into_draw\n\n # draw pile should have cards and discard pile should be empty again\n assert_equal([], @manager.discard_pile.cards)\n assert_not_equal([], @manager.draw_pile.cards)\n end",
"def play(hand,playTo)\n\t\n\tplayedCards = Array.new\n\t\n\t#push the correct number of cards to the cards played\n\tfor i in 0...playTo\n\t\tplayedCards.push(hand[i])\n\tend\n\n\t#remove played cards from hand\n\thand.shift(playTo)\n\n\t#returns hand for player and played cards for the game\n\treturn {\"handBack\" => hand, \"playedCards\" => playedCards}\n\nend",
"def computer_move(p1)\n\t\t index_set = Array.new\n\n\t\t #found = 0 for wrong output, 1 for right output, 2 for still trying\n\t\t found = 0\n\n\t\t if @playing_cards.length > 3\n\t\t #generates 3 card index values\n\t\t win_or_lose = rand 0..@game_settings.cpu_difficulty\n\t\t # Easy mode: 50% chance of correct answer\n\t\t # Medium mode: 80% chance of correct answer\n\t\t # Hard mode: 100% chance of correct answer\n\t\t #will always return 3 values that form a set\n\t\t if @game_settings.cpu_difficulty == 10\n\t\t index_set = valid_table @playing_cards\n\t\t elsif win_or_lose == 0\n\t\t index_set = (0...@playing_cards.length).to_a.sample 3\n\t\t else\n\t\t index_set = valid_table @playing_cards\n\t\t end\n\n\t\t card1 = @playing_cards[index_set[0]]\n\t\t card2 = @playing_cards[index_set[1]]\n\t\t card3 = @playing_cards[index_set[2]]\n\n\n\t\t if(is_a_set? [card1, card2, card3])\n\t\t @hint.clear\n\t\t found = 1\n\t\t @playing_cards.delete card1\n\t\t @playing_cards.delete card2\n\t\t @playing_cards.delete card3\n\t\t p1.clean_slate\n\t\t @computer_signal.score += 1\n\t\t else\n\t\t found = 0\n\t\t @computer_signal.score -= 1\n\t\t end\n\t\t #determines if false or still trying should print\n\t\t if found == 0 && rand(0..2) == 0\n\t\t found = 2\n\t\t @computer_signal.score += 1\n\t\t end\n\t\t end\n\t\t return found\n\t\tend",
"def hanoi\n disks = (1..3).to_a.reverse\n stacks = [disks, [], []]\n until stacks[0].empty? && stacks[1..2].any?(&:empty?)\n max_height = stacks.map(&:count).max\n render_string = (max_height - 1).downto(0).map do |height|\n stacks.map do |stack|\n stack[height] || \" \"\n end.join(\"\\t\")\n end.join(\"\\n\")\n puts render_string\n move_hash = { \"a\" => 0, \"b\" => 1, \"c\" => 2 }\n while true\n print \"Move From: \"\n from_stack_num = move_hash[gets.chomp]\n break unless from_stack_num.nil?\n puts \"Invalid move!\"\n end\n while true\n print \"Move To: \"\n to_stack_num = move_hash[gets.chomp]\n break unless to_stack_num.nil?\n puts \"Invalid move!\"\n end\n from_stack, to_stack = stacks.values_at(from_stack_num, to_stack_num)\n raise \"cannot move from empty stack\" if from_stack.empty?\n unless (to_stack.empty? || to_stack.last > from_stack.last)\n raise \"cannot move onto smaller disk\"\n end\n to_stack.push(from_stack.pop)\n end\n puts \"You did it!\"\nend",
"def play_move(from, to)\n #create duplicate of board, to correct pass by reference error\n #add top disk on from tower to the top of to tower\n to_dup = @board[to].dup\n to_dup.unshift(@board[from][0]) \n @board[to] = to_dup\n @board[from].shift\n \n if won?\n render\n puts \"congratulations you won!\\n\\n\"\n else\n get_move\n end\n end",
"def move_card( card, places )\n \n n = places\n card_locus = @deck.index( card )\n while (n != 0) do\n \n if (card_locus + 1 < @deck.length )\n @deck[card_locus], @deck[card_locus +1] = @deck[card_locus+1], @deck[card_locus]\n card_locus = card_locus+1\n else\n card = @deck.slice!(card_locus)\n @deck.insert(1, card)\n card_locus = 1\n \n end\n # subtract 1 from n\n n -= 1\n \n end\n \n end",
"def play_for_trick \n if @player1.deal == true && @player2.deal == false && [email protected]?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player1.lead_card\n @player1.remove_card_from_hand(leading_card)\n puts @player1.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player2.respond(leading_card)\n @player2.remove_card_from_hand(response_card)\n puts @player1.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player2.name + \" plays the \" + response_card.card_to_string\n \n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n if winning_card == leading_card \n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n else\n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n\n if @player1.deal == false && @player2.deal == true && [email protected]?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player2.lead_card\n @player2.remove_card_from_hand(leading_card)\n puts @player2.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player1.respond(leading_card)\n @player1.remove_card_from_hand(response_card)\n puts @player2.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player1.name + \" plays the \" + response_card.card_to_string\n\n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n\n if winning_card == leading_card \n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n else\n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n end",
"def player_turn\n\t\tputs \"^^^^^^^^^^^^^^^^ Your turn ^^^^^^^^^^^^^^^^\"\n\t\t\n\t\tputs \"Which pile will you pick from: 1, 2 or 3?\"\n\t\tplayer_pile = gets.chomp.to_i\n\n\t\t# keep looping until player picks 1, 2 or 3\n\t\twhile (player_pile != 1 && player_pile != 2 && player_pile != 3)\n\t\t\tputs \"Please pick from 1, 2 or 3!\"\n\t\t\tplayer_pile = gets.chomp.to_i\n\t\tend\n\n\t\t# keep looping until player picks a non zero pile\n\t\twhile choose_pile(player_pile) == 0\n\t\t\tputs \"Pile #{player_pile} is empty, please select a different pile\"\n\t\t\tplayer_pile = gets.chomp.to_i\n\t\tend\n\n\t\t# retrieve the pile value based on which pile user chooses\n\t\tselected_pile_value = choose_pile(player_pile)\n\n\t\t# player turn to choose how many to select from chosen pile\n\t\tputs \"Please pick a number less than or equal to #{selected_pile_value}\"\n\t\tplayer_choice = gets.chomp.to_i\n\n\t\t# keep looping until player selects number less than or equal to pile\n\t\twhile player_choice > selected_pile_value\n\t\t\tputs \"No! That doesn't work\"\n\t\t\tputs \"Please choose a number LESS THAN OR EQUAL TO #{selected_pile_value}\"\n\t\t\tplayer_choice = gets.chomp.to_i\t\t\t\n\t\tend\n\n\t\t# update the pile after player turn\n\t\tselected_pile_value -= player_choice\n\t\tupdate_pile(player_pile,selected_pile_value)\n\n\t\t# print out a new game stack showing updated piles\n\t\tprint \"Game stack now at #{current_score} \\n\"\n\n\t\treturn selected_pile_value # not used\n\tend",
"def play_turn(pile, deck)\n chosen_card = choose_card(pile)\n\n until chosen_card || deck.empty?\n draw_from(deck)\n chosen_card = choose_card(pile)\n end\n\n play_card(pile, chosen_card) if chosen_card\n end",
"def pile_cards\n if type == :basic\n basic_pile\n elsif type == :war\n war_pile\n elsif type == :mutally_assured_destruction\n destruction_pile\n end\n end",
"def push(card)\n @pile.push(card)\n card.arm!\n end",
"def move_player2 (choice_case)\n symbole_player2 = @player2.symbole\n @board.move_player2(choice_case, symbole_player2) \n @@game_count+=1\n end",
"def opponent_turn\n #set variables\n game = Game.find(self.game_id)\n player = Player.find(game.players.last)\n draw_card = Card.where(player_id: -2).first\n opponent_cards = Card.where(player_id: self.id)\n possible_plays = []\n colors = [\"blue\", \"green\", \"red\", \"yellow\"]\n\n #determine eligible cards in hand.\n opponent_cards.each do |card|\n if card.color == draw_card.color || card.number == draw_card.number || (card.card_action != nil && card.card_action == draw_card.card_action)\n possible_plays.push(card)\n end\n end\n #starts decision logic for card to play, otherwise draws a card and looks for possible plays\n if possible_plays.any?\n #discard current draw pile card\n draw_card.player_id = -1\n draw_card.save\n\n #determines card to be played, sets card to be the new draw pile card\n selected_card = possible_plays.sample\n selected_card.player_id = -2\n selected_card.save\n\n #determines if card has special action, and executes action if it does.\n if selected_card.card_action != nil\n\n if selected_card.card_action === \"skip\" || selected_card.card_action === \"reverse\"\n self.opponent_turn\n elsif selected_card.card_action === \"draw\"\n draw_two = Card.where(player_id: 0).sample(2)\n draw_two.each do |card|\n card.player_id = game.players.first.id\n card.save\n end\n self.opponent_turn\n elsif selected_card.card_action === \"draw_four\"\n draw_four = Card.where(player_id: 0).sample(4)\n draw_four.each do |card|\n card.player_id = player.id\n card.save\n end\n self.opponent_turn\n elsif selected_card.card_action === \"wild_color\"\n selected_card.color = colors.sample\n selected_card.save\n end\n\n else\n #switches current turn once card has been selected and played\n if game.current_turn = self.id\n game.current_turn = player.id\n game.save\n else\n game.current_turn = self.id\n game.save\n end\n\n end\n\n else\n #draws a card from the draw pile and repeats opponent_turn process.\n drawn_card = Card.where(player_id: 0).sample\n drawn_card.player_id = self.id\n drawn_card.save\n self.opponent_turn\n end\n end",
"def card7(player)\n player.position = 15 if player.position == 7\n player.position = 25 if player.position == 22\n player.position = 5 if player.position == 36\n end",
"def move_joker_a\n a_pos = $deck.find_index('A')\n if a_pos == 53\n $deck.delete 'A'\n $deck.insert 1, 'A'\n else\n temp = $deck[a_pos + 1]\n $deck[a_pos + 1] = $deck[a_pos]\n $deck[a_pos] = temp\n end\nend",
"def move_cards(list_from_name, list_to_name)\n\tfrom_list = get_list(list_from_name)\n\tto_list = get_list(list_to_name)\n\n # if from_list == nil || to_list == nil\n # p \"nil list error, check list names\"\n # return \n # end\n cards = get_cards(from_list)\n cards.each do |card|\n \tif card.badges[\"checkItems\"] == card.badges[\"checkItemsChecked\"]\n \t\tcard.move_to_list(to_list)\n \tend\n end\nend",
"def reset_discard_pile(deck)\n @cards = []\n @cards << deck.take_card\n while @cards[0].color == 'Wild' || @cards[0].number.is_a?(String)\n deck.cards.unshift(@cards.pop)\n @cards << deck.take_card\n end\n @cards\n end",
"def playCard()\n if (@hand.length == 0)\n puts \"#{@name} RAN OUT OF CARDS\"\n return false\n end\n topCard = @hand.shift\n return topCard\n end",
"def card10(player)\n player.position -= 3\n end",
"def play_card(discard_pile, color, number)\n @cards.length.times do |i|\n unless @cards[i].color == color && @cards[i].number == number\n next\n end\n\n discard_pile.cards << @cards[i]\n @last_action = number\n if number == \"Pickup 2\"\n discard_pile.pickup_2_count += 2\n end\n if number == \"Pickup 4\"\n discard_pile.pickup_4_count += 4\n end\n @cards.delete_at(i)\n return true\n end\n puts \"unexpected error, didn't play card\" # given validation, this should not be seen\n self\n end",
"def move_player1 (choice_case)\n symbole_player1 = @player1.symbole\n @board.move_player1(choice_case, symbole_player1)\n @@game_count+=1\n end",
"def move(board)\n if @players == \"X\" && board.cells[0] == \"X\" && (board.cells[1] == \"O\"|| board.cells[3] == \"O\"|| board.cells[4] == \"O\")\n ai_move = [\"3\", \"5\", \"6\", \"8\"]\n ai_move.sample\n elsif @players == \"X\" && board.cells[1] == \"X\" && (board.cells[0] == \"O\"|| board.cells[2] == \"O\"|| board.cells[3] == \"O\" || board.cells[4] == \"O\" || board.cells[5] == \"O\")\n ai_move = [\"4\", \"5\", \"6\", \"8\"]\n ai_move.sample\n elsif @players == \"X\" && board.cells[2] == \"X\" && (board.cells[1] == \"O\"|| board.cells[4] == \"O\"|| board.cells[5] == \"O\")\n ai_move = [\"1\", \"5\", \"7\", \"9\"]\n ai_move.sample\n elsif @players == \"X\" && board.cells[3] == \"X\" && (board.cells[0] == \"O\"|| board.cells[1] == \"O\"|| board.cells[4] == \"O\" || board.cells[6] == \"O\" || board.cells[7] == \"O\")\n ai_move = [\"4\", \"5\", \"6\", \"8\"]\n ai_move.sample\n elsif @players == \"X\" && board.cells[4] == \"X\" && (board.cells[0] == \"O\"|| board.cells[1] == \"O\"|| board.cells[2] == \"O\" || board.cells[3] == \"O\" || board.cells[5] == \"O\" || board.cells[6] == \"O\" || board.cells[7] == \"O\" || board.cells[8] == \"O\")\n ai_move = [\"1\", \"3\", \"7\", \"9\"]\n ai_move.sample\n elsif @players == \"X\" && board.cells[5] == \"X\" && (board.cells[1] == \"O\"|| board.cells[2] == \"O\"|| board.cells[4] == \"O\" || board.cells[7] == \"O\" || board.cells[8] == \"O\")\n ai_move = [\"3\", \"4\", \"5\", \"9\"]\n ai_move.sample\n elsif @players == \"X\" && board.cells[6] == \"X\" && (board.cells[3] == \"O\"|| board.cells[4] == \"O\"|| board.cells[7] == \"O\")\n ai_move = [\"1\", \"3\", \"5\", \"9\"]\n ai_move.sample\n elsif @players == \"X\" && board.cells[7] == \"X\" && (board.cells[3] == \"O\"|| board.cells[4] == \"O\"|| board.cells[5] == \"O\" || board.cells[6] == \"O\" || board.cells[8] == \"O\")\n ai_move = [\"2\", \"5\", \"7\", \"9\"]\n ai_move.sample\n elsif @players == \"X\" && board.cells[8] == \"X\" && (board.cells[4] == \"O\"|| board.cells[5] == \"O\"|| board.cells[7] == \"O\")\n ai_move = [\"1\", \"3\", \"5\", \"6\"]\n ai_move.sample\n\n elsif @players == \"O\" && board.cells[0] == \"O\" && (board.cells[1] == \"X\"|| board.cells[3] == \"O\"|| board.cells[4] == \"O\")\n ai_move = [\"3\", \"5\", \"6\", \"8\"]\n ai_move.sample\n elsif @players == \"O\" && board.cells[1] == \"O\" && (board.cells[0] == \"X\"|| board.cells[2] == \"X\"|| board.cells[3] == \"X\" || board.cells[4] == \"X\" || board.cells[5] == \"X\")\n ai_move = [\"4\", \"5\", \"6\", \"8\"]\n ai_move.sample\n elsif @players == \"O\" && board.cells[2] == \"O\" && (board.cells[1] == \"X\"|| board.cells[4] == \"X\"|| board.cells[5] == \"X\")\n ai_move = [\"1\", \"5\", \"7\", \"9\"]\n ai_move.sample\n elsif @players == \"O\" && board.cells[3] == \"O\" && (board.cells[0] == \"X\"|| board.cells[1] == \"X\"|| board.cells[4] == \"X\" || board.cells[6] == \"X\" || board.cells[7] == \"X\")\n ai_move = [\"4\", \"5\", \"6\", \"8\"]\n ai_move.sample\n elsif @players == \"O\" && board.cells[4] == \"O\" && (board.cells[0] == \"X\"|| board.cells[1] == \"X\"|| board.cells[2] == \"X\" || board.cells[3] == \"X\" || board.cells[5] == \"X\" || board.cells[6] == \"X\" || board.cells[7] == \"X\" || board.cells[8] == \"X\")\n ai_move = [\"1\", \"3\", \"7\", \"9\"]\n ai_move.sample\n elsif @players == \"O\" && board.cells[5] == \"O\" && (board.cells[1] == \"X\"|| board.cells[2] == \"X\"|| board.cells[4] == \"X\" || board.cells[7] == \"X\" || board.cells[8] == \"X\")\n ai_move = [\"3\", \"4\", \"5\", \"9\"]\n ai_move.sample\n elsif @players == \"O\" && board.cells[6] == \"O\" && (board.cells[3] == \"X\"|| board.cells[4] == \"X\"|| board.cells[7] == \"X\")\n ai_move = [\"1\", \"3\", \"5\", \"9\"]\n ai_move.sample\n elsif @players == \"O\" && board.cells[7] == \"O\" && (board.cells[3] == \"X\"|| board.cells[4] == \"X\"|| board.cells[5] == \"X\" || board.cells[6] == \"X\" || board.cells[8] == \"X\")\n ai_move = [\"2\", \"5\", \"7\", \"9\"]\n ai_move.sample\n elsif @players == \"O\" && board.cells[8] == \"O\" && (board.cells[4] == \"X\"|| board.cells[5] == \"X\"|| board.cells[7] == \"X\")\n ai_move = [\"1\", \"3\", \"5\", \"6\"]\n ai_move.sample\n\n else\n ai_move = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]\n ai_move.sample\n# def move(board)\n# ai_move = [\"2\", \"4\", \"6\", \"8\"]\n# ai_move.sample\n# elsif (board.cells[1] || board.cells[3] || board.cells[5] || board.cells[7]) == \"X\"\n# ai_move = [\"1\", \"3\", \"5\", \"7\", \"9\"]\n# ai_move.sample\n# elsif (board.cells[0] || board.cells[2] || board.cells[4] || board.cells[6] || board.cells[8]) == \"O\"\n# ai_move = [\"2\", \"4\", \"6\", \"8\"]\n# ai_move.sample\n# elsif (board.cells[1] || board.cells[3] || board.cells[5] || board.cells[7]) == \"O\"\n# ai_move = [\"1\", \"3\", \"5\", \"7\", \"9\"]\n# ai_move.sample\n# else\n# ai_move = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]\n# ai_move.sample\n end\n end",
"def play_as_master_second\r\n card_avv_s = @card_played[0].to_s\r\n card_avv_info = @deck_info.get_card_info(@card_played[0])\r\n max_points_take = 0\r\n max_card_take = @cards_on_hand[0]\r\n min_card_leave = @cards_on_hand[0]\r\n min_points_leave = @deck_info.get_card_info(min_card_leave)[:points] + card_avv_info[:points]\r\n take_it = []\r\n leave_it = []\r\n # build takeit leaveit arrays\r\n @cards_on_hand.each do |card_lbl|\r\n card_s = card_lbl.to_s\r\n bcurr_card_take = false\r\n card_curr_info = @deck_info.get_card_info(card_lbl)\r\n if card_s[2] == card_avv_s[2]\r\n # same suit\r\n if card_curr_info[:rank] > card_avv_info[:rank]\r\n # current card take\r\n bcurr_card_take = true\r\n take_it << card_lbl\r\n else\r\n leave_it << card_lbl\r\n end\r\n elsif card_s[2] == @briscola.to_s[2]\r\n # this card is a briscola \r\n bcurr_card_take = true\r\n take_it << card_lbl\r\n else\r\n leave_it << card_lbl\r\n end\r\n # check how many points make the card if it take\r\n points = card_curr_info[:points] + card_avv_info[:points]\r\n if bcurr_card_take\r\n if points > max_points_take\r\n max_card_take = card_lbl\r\n max_points_take = points\r\n end\r\n else\r\n # leave it as minimum\r\n if points < min_points_leave or (points == min_points_leave and\r\n card_curr_info[:rank] < @deck_info.get_card_info(min_card_leave)[:rank] )\r\n min_card_leave = card_lbl\r\n min_points_leave = points\r\n end\r\n end\r\n end\r\n #p min_points_leave\r\n #p min_card_leave\r\n curr_points_me = 0\r\n @team_mates.each{ |name_pl| curr_points_me += @points_segno[name_pl] }\r\n tot_points_if_take = curr_points_me + max_points_take\r\n curr_points_opp = 0\r\n @opp_names.each{ |name_pl| curr_points_opp += @points_segno[name_pl] }\r\n \r\n #p take_it\r\n #p leave_it\r\n #p max_points_take\r\n #p min_points_leave\r\n if take_it.size == 0\r\n #take_it is not possibile, use leave it\r\n @log.debug(\"play_as_master_second, apply R1 #{min_card_leave}\")\r\n return min_card_leave \r\n end\r\n max_card_take_s = max_card_take.to_s\r\n if tot_points_if_take >= @target_points\r\n # take it, we win\r\n @log.debug(\"play_as_master_second, apply R2 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n if @pending_points > 0\r\n card_to_play = best_taken_card(take_it)[0]\r\n @log.debug(\"play_as_master_second, apply R2-decl #{card_to_play}\")\r\n return card_to_play \r\n end\r\n if max_card_take_s[2] == @briscola.to_s[2]\r\n # card that take is briscola, pay attention to play it\r\n if max_points_take >= 20\r\n @log.debug(\"play_as_master_second, apply R3 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n elsif max_points_take >= 10\r\n # take it, strosa!\r\n @log.debug(\"play_as_master_second, apply R4 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n best_leave_it = nil\r\n if leave_it.size > 0\r\n best_leave_it = best_leaveit_card(leave_it)\r\n end\r\n if best_leave_it == nil\r\n card_to_play = best_taken_card(take_it)[0]\r\n @log.debug(\"play_as_master_second, apply R9 #{card_to_play} - force taken\")\r\n return card_to_play\r\n end\r\n points_best_leave = @deck_info.get_card_info(best_leave_it)[:points]\r\n if card_avv_info[:points] == 0 and points_best_leave == 0\r\n @log.debug(\"play_as_master_second, apply R10 #{best_leave_it} \")\r\n return best_leave_it\r\n end\r\n if take_it.size > 0\r\n w_and_best = best_taken_card(take_it)\r\n # we can take it\r\n if curr_points_opp > 29 and max_points_take > 0 and take_it.size > 1\r\n # try to take it\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R5 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n if curr_points_opp > 36 and (card_avv_info[:points] > 0 or points_best_leave > 0)\r\n # try to take it\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R11 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n if points_best_leave > 2 or min_points_leave > 3 and w_and_best[1] < 320\r\n # I am loosing too many points?\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R6 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n end \r\n # leave it\r\n if best_leave_it\r\n @log.debug(\"play_as_master_second, apply R7 #{best_leave_it}\")\r\n return best_leave_it\r\n end\r\n \r\n @log.debug(\"play_as_master_second, apply R8 #{min_card_leave}\")\r\n return min_card_leave \r\n #crash\r\n end",
"def move2(position, curr_player, other_player, path = 0)\n posibles = []\n \n #add [-2,0]\n other = false\n curr = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] - 2, position[1]] || piece.position == [position[0] - 1, position[1]]\n other = true\n end\n end\n curr_player.pieces.each do |piece|\n if piece.position == [position[0] - 2, position[1]] || piece.position == [position[0] - 1, position[1]]\n curr = true\n end\n end\n if (!other && !curr) && @path == 0\n posibles << [-2, 0]\n end\n \n #add [-1,0]\n other = false\n curr = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] - 1, position[1]]\n other = true\n end\n end\n curr_player.pieces.each do |piece|\n if piece.position == [position[0] - 1, position[1]]\n curr = true\n end\n end\n if !other && !curr\n posibles << [-1, 0]\n end\n \n #add [-1,1]\n other = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] - 1, position[1] + 1]\n other = true\n end\n end\n if other\n posibles << [-1, 1]\n end\n \n #add [-1, -1]\n other = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] - 1, position[1] - 1]\n other = true\n end\n end\n if other\n posibles << [-1, -1]\n end\n select_moves(position, posibles)\n end",
"def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end",
"def deal_into_new_stack(deck)\n deck.reverse\nend",
"def move(source, destination)\n if isLegal?(source,destination)\n if source==1\n disk_to_move = @@tower_1.pop\n elsif source==2\n disk_to_move = @@tower_2.pop\n elsif source==3\n disk_to_move = @@tower_3.pop\n else\n puts(\"the source should be 1,2,or 3.\")\n end\n \n if destination ==1 \n @@tower_1.push(disk_to_move)\n elsif destination == 2 \n @@tower_2.push(disk_to_move)\n elsif destination == 3 \n @@tower_3.push(disk_to_move)\n end \n else\n puts(\"Sorry that was an incorrect move. Please review the rules and try again.\")\n end\n end",
"def discard(card)\n discard_pile << card\n end",
"def playcard\n @cards.shuffle.slice!(0,2)\n end",
"def hit(hand, deck)\n hand.push(deck.pop)\nend",
"def player_push_shuffle(event)\n if (event.x > 580 && event.x < 780 && event.y > 640 && event.y < 690) \n @card_id_on_table.each_index { |i| @card_on_table[i].remove_top }\n @deck.concat(@card_id_on_table).shuffle\n @card_id_on_table = @deck[0,12]\n @deck = @deck[12,@deck.length-1]\n @card_id_on_table.each_index { |i| @card_on_table[i] = Card.new(@card_id_on_table[i], i) }\n @card_id_on_table.each_index { |i| @card_on_table[i].draw_top }\n end\n end",
"def move\n puts \"The computer is playing...\".cyan\n sleep(0.5) #computer \"thinks\" for half a second, this seemed more realistic\n return if @game.game_over?\n space = (@game.available_moves & [1,3,5,7,9]).first\n if space.nil? \n space = @game.available_moves.first\n end\n @game.place_piece(space, @piece)\n end",
"def pop_cards(num_pops)\r\n #p @deck_todisp.size\r\n num_pops.times{|ix| @deck_todisp.pop}\r\n if @briscola and @card_briscola_todisp and @deck_todisp.size == 0\r\n #if @card_briscola_todisp and @realgame_num_cards == 0\r\n # no more cards on deck, pick the briscola\r\n @card_briscola_todisp.visible = false\r\n end\r\n #p @deck_todisp.size\r\n end",
"def move_joker_b\n b_pos = $deck.find_index('B')\n $deck.delete('B')\n if b_pos == 51\n $deck << 'B'\n else\n $deck.insert (b_pos + 2) % 53, 'B'\n end\nend",
"def deal_flop\n # Burns the top card of the deck.\n @deck.cards.shift\n # Moves the top three cards of the deck into the community table cards array.\n @community_cards = @deck.cards.shift(3)\n puts ''\n print 'The flop is: '\n card_output(@community_cards)\n puts \"\"\n sleep(3)\nend",
"def test_discard_top_card\n top_card = @manager.draw_pile.cards[0]\n assert_not_equal(top_card, @manager.discard_pile.cards[0])\n @manager.discard_top_card\n assert_equal(top_card, @manager.discard_pile.cards[0])\n end",
"def action_useCard(pockerCard_id)\n\n if check_cardOwn(pockerCard_id) and check_currentTurn()#only owner can play card and current turn on\n if check_usableNumShape(pockerCard_id) #check bottom number and shape\n\n sourcePlayer_id = Game.last.players.by_user(current_user).id\n destPlayer_id = Game.last.players.dummy.id # destPlayer_id = 2 (dummy) \n\n action_moveCard(dest_id: destPlayer_id, source_id: sourcePlayer_id, card_id: pockerCard_id)\n\n #check effect of cards\n card_effect = Pockercard.find(pockerCard_id).effect\n action_addDummyList(pockerCard_id)\n action_putBottomCard(pockerCard_id)\n if card_effect == \"none\"\n action_endTurn(1) #move to next player=[\n elsif card_effect == \"back\" \n Game.last.toggle_order!\n action_endTurn(1) #skip next player\n elsif card_effect == \"jump\" \n action_endTurn(2) #move to next next player\n elsif card_effect == \"attack\"\n action_attackCard(pockerCard_id)\n action_endTurn(1) #move to next next player\n elsif card_effect == \"change\"\n action_setBottomCardStep()\n elsif card_effect == \"onemore\" \n else\n action_endTurn(1) #skip next player\n end\n check_winOrLose() \n end\n end\n\n\n\n end",
"def test_award_spoils_pile_to_winner_in_basic_turn_type\n # for basic type turn\n card1 = Card.new(:heart, 'Jack', 11)\n card2 = Card.new(:heart, '10', 10)\n card3 = Card.new(:heart, '9', 9)\n card4 = Card.new(:diamond, 'Jack', 11)\n card5 = Card.new(:heart, '8', 8)\n card6 = Card.new(:diamond, 'Queen', 12)\n card7 = Card.new(:heart, '3', 3)\n card8 = Card.new(:diamond, '2', 2)\n deck1 = Deck.new([card1, card2, card5, card8])\n deck2 = Deck.new([card3, card4, card6, card7])\n player1 = Player.new(\"Megan\", deck1)\n player2 = Player.new(\"Aurora\", deck2)\n turn = Turn.new(player1, player2)\n\n turn_winner = turn.winner\n turn.pile_cards\n turn.award_spoils(turn_winner)\n # using .any will make sure that the order of cards doesn't matter, just that they are included or not\n assert_equal false, ([card2, card5, card8, card1, card3] & [turn.player1.deck.cards]).any?\n end",
"def play_dealer(hand, shoe, odds, upcard_result)\n case decide(hand)\n when :stand\n upcard_result[result(hand)] += odds\n when :hit\n CARDS.each do |card|\n next unless shoe.any?(card)\n card_odds = shoe.odds_of(card)\n\n hand.push(card)\n shoe.consume(card)\n\n play_dealer(hand, shoe, odds * card_odds , upcard_result)\n\n shoe.replace(card)\n hand.pop\n end\n else\n raise \"error, illegal hand action\"\n end\nend",
"def deal\r\n @cards.shift\r\n end",
"def turn\n #I always start a turn by show the player the latest values of all the piles by calling my showPiles function\n showPiles()\n\n #Here i set some out-of-bounds defaults so that the until statements start false, allowing the player to make their choice\n take = -1\n pile = -1\n sum = 0\n\n #at the start of the turn I check if the sum of the sticks in all the piles is 0 or less, indicating that there are no more moves to make and this player has won\n $piles.each do |i|\n sum += i.count\n end\n if sum <= 0\n puts $name.to_name + \", You win!!\"\n return #this return is to exit the turn function returning to the rest of the code which is empty, essentially stopping the game now that it has been determined to be won and over.\n end\n\n #this ensures that the pile chosen is a valid number,because until it is it wont stop asking\n until pile.between?(0,2)\n print $name.to_name + \", Choose a pile:\"\n pile = gets.chomp().to_i\n end\n\n #this ensures that the pile chosen isnt already empty by restarting the turn if the chosen piles count is 0 or less\n if $piles[pile].count <= 0\n puts \"That pile is already empty, try again\"\n turn()\n return\n end\n\n #this ensures that the pile chosen has enough sticks in it to complete the users move of taking their defined sticks.\n until take.between?(1,$piles[pile].count)\n print \"How many to remove from pile \" + pile.to_s + \":\"\n take = gets.chomp().to_i\n end\n\n #this will only be ran once everything above it has been determined the move to be a plausible move, and calls the take function for the users decided sticks from their decided pile\n $piles[pile].take(take)\n\n #this inverts the name boolean so that it will show the next players name on the next turn\n $name = !$name\n #this begins the next players turn by calling the turn function, now that this players turn is done\n turn()\nend",
"def take!\n\t\[email protected]\n\tend",
"def move_card_down(card, num_spots)\n card_index = @cards.index(card)\n new_index = (card_index + num_spots)\n if new_index > 53\n new_index = (new_index % 54) + 1 # The plus 1 prevents it from becoming the first card\n end\n @cards.delete_at(card_index)\n @cards.insert(new_index, card)\n end",
"def play(card)\n fail 'invalid play' if !valid_play?(card)\n fail 'must declare suit when playing eight' if card.value == :eight\n\n @top_card = card\n @current_suit = card.suit\n end",
"def players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n puts 'You have '+players_cards_value.to_s+' right now. Would you like to hit or stay? (type hit or stay to perform said action)'\n players_actions_reply = gets.chomp\n while players_actions_reply.downcase != 'stay'\n #if reply is 'stay' then program ends\n if players_actions_reply.downcase == 'hit'\n players_cards.push (the_draw(deck))\n players_cards_value = card_value(players_cards_value, players_cards)\n board(computers_cards_value, players_cards_value, players_cards, computers_cards, players_cards_two, players_cards_two_value)\n if players_cards_value >= 21\n if players_cards.index{ |x, y| y == 11 } == true\n card_value_one(players_cards)\n players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit\n else\n if players_cards_two_value == 0\n puts 'Busted. You went over 21. You Lose'\n play_again\n exit\n else\n #could be bellow here\n players_actions(players_cards_two_value, players_cards_two, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit \n end\n end\n else\n reply\n players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n \n #deleted exit here, figure out problem now\n end\n else\n puts 'You didn\\'t enter hit or stay. Please try again.'\n players_actions_reply = gets.chomp\n end\n end\n end",
"def move_joker_a\n\t\t# find the index of the 'a' joker\n\t\tindex_a = @deck_of_cards.index(Card.new(:joker, 1))\n\t\t# if the 'a' joker is the last card in the deck, move it below the first card\n\t\tif index_a == 53\n\t\t\tjoker_a = @deck_of_cards.delete_at(index_a)\n\t\t\t@deck_of_cards.insert(1, joker_a)\n\n\t\t\t# new position of the 'a' joker\n\t\t\tnew_a = 1\n\t\telse # swap the 'a' joker with the card right below it\n\t\t\t@deck_of_cards[index_a], @deck_of_cards[index_a + 1] = @deck_of_cards[index_a + 1], @deck_of_cards[index_a] \n\t\t\t\n\t\t\t# new position of the 'a' joker\n\t\t\tnew_a = index_a + 1\n\t\tend\n\tend",
"def move_down( index )\r\n if index == @deck.length - 1\r\n @deck[1..1] = @deck[index], @deck[1]\r\n @deck.pop\r\n else\r\n @deck[index], @deck[index + 1] = @deck[index + 1], @deck[index]\r\n end\r\n end",
"def choose_card(pile)\n cards.find { |card| card.value != :eight && pile.valid_play?(card) } ||\n cards.find { |card| card.value == :eight }\n end",
"def deal_card(hand)\n #hand is a string whose valid values are 'player_cards' and 'dealer_cards' \n\n if !['player_cards','dealer_cards'].include?(hand)\n raise \"Unknown hand #{hand}\"\n end \n\n #Check for an empty deck and reshuffle if necessary\n if (session['game_cards'].length == 0) \n\n session['game_cards'] = session['discard']\n session['game_cards'].shuffle!\n session['discard'] = []\n append_message(\"Dealer shuffled the cards.\") \n\n end \n\n #Move the card\n session[hand] << session['game_cards'].pop \n\n end",
"def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n\n # What if they follow more aggressively on harder difficulty?\n\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n\n end",
"def deal\r\n @deck_of_cards.shift\r\n end",
"def comp_move(some_array,which_level) \n include StrategyTools\n include FormatBoard\n \n 3.times{print \"\\n\"}\n center\n print \"MY MOVE\\n\"\n center\n 4.times{print \"_ \"}\n \n case which_level \n when \"1\"\n\trandom_play(some_array) \n \n when \"2\"\n\tif rand(2).odd?\n\t smart_play(some_array) \t\t\t\n\telse\n\t random_play(some_array) \n\tend\n\t\n when \"3\"\n if rand(4) < 3\n\t smart_play(some_array) \n\telse\n\t random_play(some_array) \n\tend\n\n when \"4\"\n\tif rand(100) < 98\n\t smart_play(some_array) \t\t\n\telse\n\t random_play(some_array) \n\tend\n\t\n end\n \n some_array\nend",
"def play(board)\nwhile !over?(board)\nturn(board)\nend\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def redeal\n # take all current cards in play and add to deck\n @deck.concat(@cards_in_play)\n @cards_in_play = Array.new\n\n #shuffle cards \n @deck.shuffle!\n\n #deal 12 more new cards\n @cards_in_play.concat(@deck.pop(12))\nend",
"def draw_card\n waiting_to_pick_pile = true\n\n invalid_pile = nil\n while waiting_to_pick_pile\n DisplayManager.prepare_ingame_display\n show_state\n\n puts \"Do you want to draw a new card, or use the top discarded card?\"\n puts InputManager.input_options({ affirmative: 'Draw New Card', negative: 'Take Last Discarded Card' }, invalid_pile)\n invalid_pile = nil\n \n response = InputManager.get\n\n # If player picks the draw pile\n # draw the top card from that pile\n if InputManager.affirmative?(response)\n choose_new_card\n waiting_to_pick_pile = false\n\n # If player picks from discard pile\n # draw top card from that pile\n # player cannot discard this card\n elsif InputManager.negative?(response)\n choose_discard\n waiting_to_pick_pile = false\n else\n invalid_pile = response\n end\n end\n end",
"def deal_turn\n @pokerdeck.pop\n turn = @pokerdeck.pop\n @communal_cards << turn\n return turn\n end",
"def play\n while true\n current_player.en_passant = false\n board.formatted_grid\n if check_for_check\n if check_for_checkmate\n puts \"Checkmate!\"\n else\n puts \"Check!\"\n end\n end\n x, y = prompt_selection\n puts \"\"\n puts ask_move\n x_end, y_end = get_move\n if x_end == \"back\"\n board.clear_board\n play\n end\n while board.valid_place?(x_end, y_end) == false\n puts \"Invalid option! Try again:\"\n x_end, y_end = get_move\n board.valid_place?(x_end, y_end)\n end\n #check for en passant\n if board.get_cell_piece(x, y).type == \"pawn\" && y_end - y == 2\n current_player.en_passant = true\n elsif board.get_cell_piece(x, y).type == \"pawn\" && y - y_end == 2\n current_player.en_passant = true\n end\n\n #check for promotion\n if board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"white\" && y_end == 0\n promote(x, y)\n elsif board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"black\" && y_end == 7\n promote(x, y)\n end\n\n #check for castling\n if board.get_cell_piece(x, y).type == \"king\" && x_end - x == 2\n board.piece_move(x + 3, y, x + 1, y)\n board.set_cell_color(x + 2, y, \"red\")\n elsif board.get_cell_piece(x, y).type == \"king\" && x - x_end == 2\n board.piece_move(x - 4, y, x - 1, y)\n board.set_cell_color(x - 2, y, \"red\")\n end\n #check if taking an opponent's piece\n if is_taking_piece?(x_end, y_end) \n hash_value = other_player.pieces_left.key([x_end, y_end])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n other_player.pieces_left.delete(hash_value)\n\n board.piece_move(x, y, x_end, y_end)\n else\n hash_value = current_player.pieces_left.key([x, y])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n board.piece_move(x, y, x_end, y_end)\n end\n #if board.game_over\n #puts game_over_message\n #board.formatted_grid\n #return\n #else\n switch_players\n #end\n end\n end",
"def move(players, player_turn,mdice,snakes_ladders,board_size,players_name)\n puts \"#{players} .. #{players_name[player_turn]} your current position is #{players[player_turn]} its your turn to play so through a dice by press Enter\"\n mthrough_dice = gets.chomp.to_i \n my_val = throw_dice(mdice=6)\n puts \"#{players_name[player_turn]} you got this number #{my_val}\"\n new_position = players[player_turn] + my_val\n if snakes_ladders.has_key?(new_position)\n puts \"#{players_name[player_turn]} you got #{ (my_val.to_i - players_name[new_position].to_i) < 0 ? 'snakes' : 'ladder' }.... so your new position #{snakes_ladders[new_position]} \"\n new_position = snakes_ladders[new_position] \n else \n puts \"#{players_name[player_turn]} your new position #{new_position} \"\n end \n return player_turn if new_position >= board_size \n players[player_turn] = new_position\n next_player = (player_turn + 1) % players.length\n move(players, next_player,mdice,snakes_ladders,board_size,players_name)\n end",
"def move_piece(move)\n curr_piece = @board[move[0]]\n if curr_piece.non_check_moves.include?(move[1])\n #if en passant, remove captured piece\n if curr_piece.class == Pawn\n #puts curr_piece.can_en_passant?\n #puts \"HELKFDSJLFKD\"\n if curr_piece.can_en_passant?\n #puts \"HOMFDMSKFDFLSJFKDSLFJSDKLF JDSFKLSJFKLEJ FE FJSKLF\"\n rank = move[0][0]\n col = move[1][1]\n captured_pawn_pos = [rank,col]\n #puts captured_pawn_pos.inspect\n @board[captured_pawn_pos] = nil\n end\n end\n @board[move[1]] = curr_piece\n @board[move[0]] = nil\n curr_piece.move_history << move\n curr_piece.pos = move[1]\n #if castling, move rook too\n if curr_piece.class == King && (move[0][1] - move[1][1]).abs == 2\n #find the appropriate rook to move\n start_rank = move[0][0]\n start_file = move[1][1] == 2 ? 0 : 7\n start_pos = [start_rank, start_file]\n rook = @board[start_pos]\n #determine its final location, then move it.\n end_file = start_file == 0 ? 3 : 5\n end_pos = [start_rank, end_file]\n @board[end_pos] = rook\n @board[start_pos] = nil\n rook.move_history << end_pos\n rook.pos = end_pos\n end\n return true\n else\n puts \"Your king is still in check!\" if @board.in_check?(curr_piece.color)\n puts \"Not a legal move for this #{curr_piece.color} #{curr_piece.class}!\"\n puts\n return false\n end\n end",
"def draw_card\n #change for chapel if no card to draw\n if ! (top_card = deckcards.find_by(library_position: 1))\n shuffle\n top_card = deckcards.find_by(library_position: 1)\n end\n top_card.status = \"hand\"\n top_card.library_position = nil\n top_card.save\n library.each do |library_member|\n library_member.library_position -=1\n library_member.save\n end\n top_card\n end",
"def move_card(card, destination)\n card.location = destination\n card.save\n end",
"def play(board)\n display_board(board)\n until over?(board)\n turn(board)\n end\n if won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n else\n nil\n end\n #replay\nend",
"def deal_post_flop\n # Burns the top card of the deck.\n @deck.cards.shift\n # Moves the top card of the deck into the community table cards array.\n @community_cards.push(@deck.cards.shift)\n print 'The community cards are: '\n puts \"\"\n card_output(@community_cards)\n puts \"\"\n sleep(3)\nend",
"def take_card\n @deck.shift\n end",
"def opening_hand(players_cards, computers_cards, deck)\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n end",
"def play_move!( m )\n self.delete_if { |pos, piece| pos == m.to_coord || pos == m.captured_piece_coord }\n\n piece_moved = self.delete(m.from_coord)\n self[m.to_coord] = piece_moved\n\n if m.castled==1\n castling_rank = m.to_coord.rank.to_s\n [['g', 'f', 'h'], ['c', 'd', 'a']].each do |king_file, new_rook_file, orig_rook_file|\n #update the position of the rook corresponding to the square the king landed on\n\tif m.to_coord.file == king_file \n\t rook = self.delete(\"#{orig_rook_file}#{castling_rank}\")\n\t self[\"#{new_rook_file}#{castling_rank}\"] = rook\n\tend\n end\n end\n \n #TODO investigate why this method is getting called multiply per moves << Move.new\n return unless piece_moved\n ep_from_rank, ep_to_rank, ep_rank = EN_PASSANT_CONFIG[ piece_moved.side ]\n @en_passant_square = ( piece_moved.function == :pawn &&\n m.from_coord.rank == ep_from_rank && \n m.to_coord.rank == ep_to_rank ) ? m.from_coord.file + ep_rank.to_s : nil\n\n #reflect promotion\n if piece_moved && piece_moved.function == :pawn && m.to_coord.to_s.rank == piece_moved.promotion_rank\n self.delete(m.to_coord)\n self[m.to_coord] = Queen.new(piece_moved.side, :promoted)\n #puts self.to_s if m.to_coord == 'a8'\n #debugger if m.to_coord == 'a8'\n end\n \n self\n end",
"def do_move(game, mark)\n player = mark == 'X' ? 'O' : 'X'\n player_marks = game.turns.where(mark: player).map {|turn| turn.board_index}\n marks = game.turns.where(mark: mark).map {|turn| turn.board_index}\n i = nil\n\n # Look for winning move\n @@win_conditions.each do |win|\n if (win-marks).size == 1 && !game.board[(win-marks).first]\n i = (win-marks).first\n end\n end\n\n if !i\n # Block any potential wins for player\n @@win_conditions.each do |win|\n if (win-player_marks).size == 1 && !game.board[(win-player_marks).first]\n i = (win-player_marks).first\n end\n end\n end\n\n if !i\n # Prioritize corners \n if !game.board[0] || !game.board[2] || !game.board[6] || !game.board[8]\n i = [0, 2, 6, 8].sample \n\n while game.board[i]\n i = [0, 2, 6, 8].sample \n end\n # Else prioritize center\n elsif !game.board[4]\n i = 4\n end\n end\n\n # If all else fails just pick a random open spot\n if !i\n i = [1, 3, 5, 7].sample\n\n while game.board[i]\n i = [1, 3, 5, 7].sample \n end\n end\n\n game.turns.build(mark: mark, board_index: i).save\n end",
"def expected_hand(player, turn)\n my_player = @playerstates.detect{|playerstate| playerstate.name == player.player_name}\n expected_hand = my_player.hand.hand_to_list\n cardsfrom = turn.turn_end\n if cardsfrom.from_deck?\n new_cards = [turn.deck.take]\n elsif cardsfrom.from_stack?\n new_cards = turn.stack.take(cardsfrom.how_many_cards?)\n end\n expected_hand = expected_hand + new_cards\n end",
"def deal_cards(cards)\n @players.each do |player|\n player.hand += @deck.cards.pop(cards)\n end\n end",
"def deal\n # pack cards past the default 12 into the begining\n if @cards.length > 12\n # cards still in play past the standard 12 positions\n extra = @cards.last(@cards.length - 12).compact\n # move what can be moved into the standard 12 positions\n @cards = @cards.take(12).map! { |c| c || extra.pop }\n # hopefully extra is empty now, but maybe not\n @cards += extra\n end\n\n # sets is still valid as we haven't modified the combinaion of cards in play\n # do we need to expand the cards in play?\n if(@sets && @sets.none?)\n @cards += Array.new(3)\n end\n \n ## fill any gaps from the deck\n @cards.map! { |x| x || @deck.pop }\n\n # recompute sets\n #@sets = []\n @sets = IsASet.sets @cards.compact\n end",
"def deal\n @deckOfCards.shift\n end",
"def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n end",
"def play_game\n num_turns = 0\n # @deck = Deck.new\n @deck.create_shuffled_deck\n deal_cards\n\n until (@player1.hand.deck.front == nil && @player1.hand.deck.back == nil) || (@player2.hand.deck.front == nil && @player2.hand.deck.back == nil)\n num_turns += 1\n\n p1_card = @player1.hand.deal_card\n p2_card = @player2.hand.deal_card\n cards = WarAPI.play_turn(@player1, p1_card, @player2, p2_card)\n add_player_card(cards)\n end\n\n if @player1.hand.deck.front == nil\n puts \"#{@player2.name}\"\n return num_turns\n else\n puts \"#{@player1.name}\"\n return num_turns\n end\n end",
"def move_player (start, stop, piece)\r\n $board[stop[0]][stop[1]] = piece\r\n $board[start[0]][start[1]] = nil \r\n $board[stop[0]][stop[1]].turn += 1\r\n @prev_coord= [stop[0], stop[1]]\r\n @prev_delta_y = (stop[1] - start[1]).abs\r\n if piece.class == Pawn and (stop[1] == 7 or stop[1] == 0)\r\n promotion(stop, piece)\r\n end \r\n end",
"def turn_card(guess)\n @board[guess].reveal\n @player.store_cards(guess, @board[guess].value)\n p @player.store\n end",
"def move(area)\n options = []\n area.each { |f| options.push(f) }\n puts \"Which card? [1,2,3,4,5]\"\n options.each { |o| puts o[:name]}\n response = gets.to_i\n response -= 1\n $hand.push(area[response])\n area.delete[response]\nend",
"def handle_winner(p1,p2)\n winner = winner?(p1,p2)\n if winner == p1\n give_cards_to_winner(p1, p2)\n p1.take_own_hand\n elsif winner == p2\n give_cards_to_winner(p2, p1)\n p2.take_own_hand\n end\n end",
"def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end",
"def move(position, curr_player, other_player, path = 0)\n posibles = []\n \n #add [2,0]\n other = false\n curr = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] + 2, position[1]] || piece.position == [position[0] + 1, position[1]]\n other = true\n end\n end\n curr_player.pieces.each do |piece|\n if piece.position == [position[0] + 2, position[1]] || piece.position == [position[0] + 1, position[1]]\n curr = true\n end\n end\n if (!other && !curr) && @path == 0\n posibles << [2, 0]\n end\n \n #add [1,0]\n other = false\n curr = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] + 1, position[1]]\n other = true\n end\n end\n curr_player.pieces.each do |piece|\n if piece.position == [position[0] + 1, position[1]]\n curr = true\n end\n end\n if !other && !curr\n posibles << [1, 0]\n end\n \n #add [1, -1]\n other = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] + 1, position[1] - 1]\n other = true\n end\n end\n if other\n posibles << [1, -1]\n end\n \n #add [1,1]\n other = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] + 1, position[1] + 1]\n other = true\n end\n end\n if other\n posibles << [1, 1]\n end\n select_moves(position, posibles)\n end",
"def recycle(cards)\n LOGGER.debug \"Recycling #{cards.size} cards: #{self}\"\n return if cards.nil?\n\n top = @pile.pop\n\n if cards.respond_to?(:pop) # is it an array?\n @pile.concat(cards)\n else\n @pile.push(cards)\n end\n\n @pile.push(top)\n LOGGER.debug \"Done recycling: #{self}\"\n end",
"def players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n puts 'You have '+players_cards_value.to_s+' right now. Would you like to hit or stay? (type hit or stay to perform said action)'\n players_actions_reply = gets.chomp\n while players_actions_reply.downcase != 'stay'\n #if reply is 'stay' then program ends\n binding.pry\n if players_actions_reply.downcase == 'hit'\n players_cards.push (the_draw(deck))\n players_cards_value = card_value(players_cards_value, players_cards)\n board(computers_cards_value, players_cards_value, players_cards, computers_cards, players_cards_two, players_cards_two_value)\n if players_cards_value >= 21\n if players_cards.index{ |x, y| y == 11 } == true\n card_value_one(players_cards)\n players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit\n else\n if players_cards_two_value == 0\n puts 'Busted. You went over 21. You Lose'\n play_again\n exit\n else\n #could be bellow here\n players_actions(players_cards_two_value, players_cards_two, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit \n end\n end\n else\n players_actions(players_cards_value, players_cards, deck, computers_cards_value, computers_cards, players_cards_two_value, players_cards_two)\n exit\n end\n else\n puts 'You didn\\'t enter hit or stay. Please try again.'\n players_actions_reply = gets.chomp\n end\n end\n binding.pry\n end",
"def computer_turn\n\t\tputs \"+++++++++++++++++ Computer's turn +++++++++++++++++\"\n\n\t\t# computer chooses psuedo-random number between 1 and 3 inclusive\n\t\tcomputer_pile = rand(1..3)\n\n\t\t# retrieve the pile value based on computer random number\n\t\tselected_pile_value = choose_pile(computer_pile)\n\t\t\n\t\t# keep looping if pile has 0 value\n\t\twhile selected_pile_value == 0\n\t\t\tcomputer_pile = rand(1..3)\n\t\t\tselected_pile_value = choose_pile(computer_pile)\n\t\tend\n\t\t\n\t\t# case when pile = 1, then computer 'chooses' value 1\n\t\tif selected_pile_value == 1\n\t\t\tcomputer_choice = 1\n\t\t\n\t\t# computer chooses random number between 1 and pile value inclusive\n\t\telse\n\t\t\tcomputer_choice = rand(1..selected_pile_value).to_i\n\t\tend\n\t\t\n\t\t# update the pile after computer turn\n\t\tselected_pile_value -= computer_choice\n\t\tupdate_pile(computer_pile,selected_pile_value)\n\n\t\t# print out computer's turn to show user\n\t\tputs \"The computer chose pile #{computer_pile} and value #{computer_choice}\"\n\t\t\n\t\t# print out a new game stack showing updated piles\n\t\tprint \"Game stack now at #{current_score} \\n\"\n\n\t\treturn selected_pile_value # not used\n\tend",
"def win(boord)\n if board[0] == 'X' && board[0] == 'X'\n end\n\n\n def display_board\n puts\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]}\"\n puts \"-\" * 11\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]}\"\n puts \"-\" * 11\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]}\"\n puts\n end\n\n def one_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board[p1-1] = \"X\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n p2 = rand(9)\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n puts \"Computer player chooses square #{p2}\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def two_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0 && win == \"no\"\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board.delete_at(p1-1)\n @board.insert(p1 - 1, \"X\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n puts \"Player 2, please pick a square from 1 to 9\"\n p2 = gets.chomp.to_i\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def start_game\n available_turns = 9\n while available_turns == 9\n puts\n puts \"*\" * 36\n puts \"Are you ready for some Tic-Tac-Toe?!\"\n puts \"*\" * 36\n puts\n input = gets.chomp.downcase\n if input == \"yes\"\n puts\n puts \"*\" * 36\n puts \"One player or two?\"\n puts \"*\" * 36\n puts\n player_num = gets.chomp.downcase\n if player_num == \"one\"\n one_player_game\n else\n two_player_game\n end\n else\n puts \"Your loss, buddy!\"\n exit!\n end\n end\n end\nend",
"def play\n deal( INITIAL_CARDS )\n while hand.deck.size >= CARD_SET\n compare_cards\n deal( CARDS )\n end\n end",
"def winner_move(game, mark)\n (0..2).each do |x|\n (0..2).each do |y|\n board = game.board.dup #using the board's deep dup method\n pos = [x, y]\n\n next unless board.empty?(pos) #makes sure current position is empty\n board[pos] = mark #sets the current position on the dup'd board\n\n #returns the position if pos would make computer the winner\n # (remember, mark is set by the game object to track who is who)\n return pos if board.winner == mark\n end\n end\n\n # no winning move\n nil\n end",
"def deal_flop\n @pokerdeck.pop\n flop = @pokerdeck.pop(3)\n @communal_cards = flop\n return flop\n end",
"def move_castling(short, color)\n\n if short\n if color == 'black'\n board[0][5].piece, board[0][6].piece = board[0][7].piece, board[0][4].piece\n board[0][7].piece, board[0][4].piece = nil, nil\n board[0][5].piece.position, board[0][6].piece.position = [0,5], [0,6]\n update_possible_movement_all_pieces()\n turns[board[0][5].piece.COLOR.to_sym] += 1\n board[0][5].piece.number_of_move += 1 if board[0][5].piece.instance_of?(Rook)\n board[0][6].piece.number_of_move += 1 if board[0][6].piece.instance_of?(King)\n \n return board[0][5].piece\n else\n board[7][5].piece, board[7][6].piece = board[7][7].piece, board[7][4].piece\n board[7][7].piece, board[7][4].piece = nil, nil\n board[7][5].piece.position, board[7][6].piece.position = [7,5], [7,6]\n update_possible_movement_all_pieces()\n turns[board[7][5].piece.COLOR.to_sym] += 1\n board[7][5].piece.number_of_move += 1 if board[7][5].piece.instance_of?(Rook)\n board[7][6].piece.number_of_move += 1 if board[7][6].piece.instance_of?(King)\n \n return board[7][5].piece\n end\n else\n if color == 'black'\n board[0][3].piece, board[0][2].piece = board[0][0].piece, board[0][4].piece\n board[0][0].piece, board[0][4].piece = nil, nil\n board[0][3].piece.position, board[0][2].piece.position = [0,3], [0,2]\n update_possible_movement_all_pieces()\n\n turns[board[0][3].piece.COLOR.to_sym] += 1\n board[0][3].piece.number_of_move += 1 if board[0][3].piece.instance_of?(Rook)\n board[0][2].piece.number_of_move += 1 if board[0][2].piece.instance_of?(King)\n\n return board[0][3].piece\n else\n board[7][3].piece, board[7][2].piece = board[7][0].piece, board[7][4].piece\n board[7][0].piece, board[7][4].piece = nil, nil\n board[7][3].piece.position, board[7][2].piece.position = [7,3], [7,2]\n update_possible_movement_all_pieces()\n \n turns[board[7][3].piece.COLOR.to_sym] += 1\n board[7][3].piece.number_of_move += 1 if board[7][3].piece.instance_of?(Rook)\n board[7][2].piece.number_of_move += 1 if board[7][2].piece.instance_of?(King)\n\n return board[7][3].piece\n end\n end\n\n end",
"def choose_card \n\n @cards.shift\n end",
"def computer_move\n \tc_move = open_spots.sample\n \t@board[c_move] = @computer_symbol.to_s\n \t\t@turn = :player\n\tend",
"def move_B\r\n 2.times { move_down( @deck.index( 'B' ) ) }\r\n end",
"def botTurn\n # check if we can win with one move or need to block\n if positions = winOrBlock?(currentPlayer) || positions = winOrBlock?( (currentPlayer == 'X')? 'O' : 'X')\n takeLastSpot(positions)\n \n # check if there is a chance for bot to create a fork, or block oponent from making fork \n elsif forks = possibleFork?(currentPlayer) || forks = possibleFork?((currentPlayer == 'X')? 'O' : 'X')\n \n \n if forks.size == 1\n # find the most common index and move there\n commonElement = forks.max_by {|i| forks.count(i)}\n move(commonElement, currentPlayer)\n else\n # more than one fork possible,\n # find optimal block point, move there\n move(blockPoint(forks), currentPlayer)\n end\n \n # take the center if its available\n elsif !position_taken?(4)\n move(4, currentPlayer)\n \n # take an opposite corner from the oponent. If not available, take any corner\n elsif corner = cornerMove\n move(corner, currentPlayer)\n \n # play in a middle square on any of the sides \n else\n SIDE_MIDDLE.each do |position|\n if !position_taken?(position)\n move(position, currentPlayer)\n break\n end\n end\n end\n puts \"#{(currentPlayer == 'X')? 'O': 'X'}'s move: \"\n displayBoard\n end",
"def MovingSomeShit(pos1, pos2)\n p = self[pos1]\n target = self[pos2]\n begin\n if p\n @moves = p\n if moves(pos2)\n if p && target\n Notice(p, target)\n else\n self[pos1], self[pos2] = self[pos2], self[pos1]\n end\n p\n return true\n end\n end\n end\n end",
"def add_to_pile_beneath(card)\n @pile_beneath << @pile.remove(card)\n end",
"def move(disks, starting, goal)\n if disks == 1 # base case\n puts \"#{starting}->#{goal}\"\n else\n\n # Steps:\n # move n - 1 disks from starting to spare peg\n # move bottom disk from starting to goal peg\n # move n - 1 disks from spare peg to goal peg\n\n spare_peg = %w[1 2 3].reject do |x|\n x == starting || x == goal\n end\n spare_peg = spare_peg[0]\n\n move(disks - 1, starting, spare_peg)\n move(1, starting, goal)\n move(disks - 1, spare_peg, goal)\n end\nend",
"def play(board)\nwhile !over?(board) \n turn(board)\nend\n if draw?(board)\n puts \"Cat's Game!\"\n elsif won?(board)\n puts \"Congratulations #{winner(board)}!\"\n end\nend"
] | [
"0.7844412",
"0.7539244",
"0.7118394",
"0.7007648",
"0.6819015",
"0.65942794",
"0.656614",
"0.6563209",
"0.65028155",
"0.6502068",
"0.6441721",
"0.64398044",
"0.6428517",
"0.6423562",
"0.6348722",
"0.6337396",
"0.6307701",
"0.6295659",
"0.62912595",
"0.62645286",
"0.6261149",
"0.6257408",
"0.6246325",
"0.6233923",
"0.6198699",
"0.6182917",
"0.61765367",
"0.6150099",
"0.6141218",
"0.6139274",
"0.6124909",
"0.6091603",
"0.6085215",
"0.6074165",
"0.6069876",
"0.60606843",
"0.60518634",
"0.604639",
"0.6043616",
"0.6031806",
"0.60123503",
"0.6011451",
"0.5998722",
"0.599722",
"0.5993356",
"0.59721935",
"0.5971699",
"0.5971287",
"0.59629285",
"0.59586763",
"0.5955269",
"0.5955029",
"0.5951377",
"0.5940563",
"0.59323764",
"0.5919115",
"0.5913714",
"0.5912632",
"0.59085405",
"0.5904246",
"0.5894745",
"0.5894138",
"0.58899987",
"0.5889889",
"0.5883089",
"0.5882808",
"0.588014",
"0.58786947",
"0.5871814",
"0.5869546",
"0.5868151",
"0.58632535",
"0.5857774",
"0.5857091",
"0.58556044",
"0.5846047",
"0.58447707",
"0.5844519",
"0.5839197",
"0.58313453",
"0.58292246",
"0.5817255",
"0.58147776",
"0.5814075",
"0.5813629",
"0.5805868",
"0.57977504",
"0.5797631",
"0.57895535",
"0.57895476",
"0.578741",
"0.5786259",
"0.5786132",
"0.5779436",
"0.5778831",
"0.57776034",
"0.57749665",
"0.5770507",
"0.5768217",
"0.5751469"
] | 0.84700364 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_posts_tag
@posts_tag = PostsTag.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 posts_tag_params
params.fetch(:posts_tag, {})
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 :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 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 [: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 get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\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 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 filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\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 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 specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"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 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 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 sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\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 special_device_list_params\n params.require(:special_device_list).permit(:name)\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 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.71213365",
"0.70527846",
"0.6947171",
"0.6901663",
"0.67342883",
"0.6717481",
"0.668679",
"0.667654",
"0.6660948",
"0.655484",
"0.6525947",
"0.64567953",
"0.64502525",
"0.6450165",
"0.6446098",
"0.6433068",
"0.64118934",
"0.64118934",
"0.63903046",
"0.6379847",
"0.6379847",
"0.63736796",
"0.63605297",
"0.6353668",
"0.6283826",
"0.6277936",
"0.62436706",
"0.6226217",
"0.62238735",
"0.6222201",
"0.6208754",
"0.62079734",
"0.61760926",
"0.6171337",
"0.6166829",
"0.61594605",
"0.61429733",
"0.6134288",
"0.61210173",
"0.6106998",
"0.6097591",
"0.6074265",
"0.6053252",
"0.6039525",
"0.60342395",
"0.6030413",
"0.6017866",
"0.60174304",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60172004",
"0.60154676",
"0.60037804",
"0.6003128",
"0.5999996",
"0.5994808",
"0.59938943",
"0.5992965",
"0.59828913",
"0.5982352",
"0.59762347",
"0.5973914",
"0.5968744",
"0.5964729",
"0.5963057",
"0.5963057",
"0.5956878",
"0.5950747",
"0.5950746",
"0.5946173",
"0.59427863",
"0.59293395",
"0.5928864",
"0.5925602",
"0.5923773",
"0.5918309",
"0.5915812",
"0.59130466",
"0.59129673",
"0.5907004",
"0.59047765",
"0.590452",
"0.59017384",
"0.5899288",
"0.58962125",
"0.58959764",
"0.5893933"
] | 0.0 | -1 |
end return initialize player hands | def init_player_hands
@player1_hand = []
@player2_hand = []
@player3_hand = []
@player4_hand = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(cards)\n\n\n #while start waiting to east to start\n @state = :start\n #hand for each player\n @hands = {} \n @hands[:south] = cards.slice(0,10).sort!\n @hands[:east] = cards.slice(10,10).sort!\n @hands[:west] = cards.slice(20,10).sort!\n \n \n #cards played on table\n @played = {}\n # number of tricks taken by each player\n @taken = {}\n\n #sets taken and played\n @@PLAYERS.each do |player|\n @played[player] = nil\n @taken[player] = Array.new\n end \n # hole cards \n @hole_cards = cards.slice(30,2) \n @on_move = :east \n end",
"def init_deal\n initialhand = []\n initialhand << @dealingmachine.deal_one_card << @dealingmachine.deal_one_card\n @hands << initialhand\n @hands_status << \"unfinished\"\n end",
"def initialize_players\n\n end",
"def show_hands_initial\n player.show_hand\n dealer.show_hand\n end",
"def init_players\n\t\t@human = Human.new(\"Jack\", Field.new)\n\t\t@computer = Computer.new(Field.new)\n\t\tinit_fields\n\tend",
"def starting_hands\n @dealer_hand.push(random_card)\n @player_hand.push(random_card, random_card)\n end",
"def initialize\n @cards = full_deck.shuffle\n @used = []\n @inhand = []\n @hands = []\n end",
"def start_hand\n @hands[0] = DealerHand.new\n @hands[0].hit_soft_17 = @hit_soft_17\n return @hands[0]\n end",
"def start_hand\n @num_hands += 1\n @@total_hands += 1\n i = @hands.length\n @hands[i] = Hand.new\n self.place_bet(@hands[i])\n return @hands[i]\n end",
"def initialize\n\t#@users = count\n\t#@players = Array.new(@users,0) \n @table = Table.new\n\t@hands= Array.new(3,0){Array.new(0,0)} #...so..[[0,0],[0,0],[0,0],[0,0]] \nend",
"def be_ready_to_game\n @hand = Hand.new\n end",
"def hands\n dealer.hand = []\n player.hand = []\n end",
"def initalize\n @deck = Deck.new\n @player = Player.new\n @dealer = Dealer.new\n end",
"def initialize (cards)\n #sort the cards and store them in @cards\n @cards = Array.new\n cards.each do |card|\n @cards << Card.new(card)\n end\n @cards.sort!\n \n #determine the rank of the hand\n @rank = 0\n \n #see if at least one pair exists\n if @cards[0] == @cards[1] or @cards[1] == @cards[2] or @cards[2] == @cards[3] or @cards[3] == @cards[4]\n @handStart = @cards[0] == @cards[1] ? 0 : @cards[1] == @cards[2] ? 1 : @cards[2] == @cards[3] ? 2 : 3\n @rank = 1 #one pair\n #see if it's part of a three of a kind\n if @cards[0] == @cards[2] or cards[1] == @cards[3] or cards[2] == @cards[4]\n #see if hand is a full house\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3] and @cards[2] == @cards[4]) or (@cards[0] == @cards[1] and @cards[0] == @cards[2] and @cards[3] == @cards[4])\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n @rank = 6 #full house\n else\n @rank = 3 #three of a kind\n \n #see if it's part of a four of a kind\n if @cards[0] == @cards[3] or @cards[1] == @cards[4]\n @rank = 7 #four of a kind\n end\n end\n else\n #see if there are two pairs\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3]) or (@cards[1] == @cards[2] and @cards[3] == @cards[4]) or (@cards[0] == @cards[1] and @cards[3] == @cards[4])\n @rank = 2 #two pairs\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n end\n end\n else\n #check for straight\n inorder = true\n 0.upto(@cards.count - 2) do |x|\n if @cards[x].face and !@cards[x+1].face\n inorder = false\n break\n elsif !@cards[x].face and !@cards[x+1].face\n unless @cards[x].value + 1 == @cards[x+1].value\n inorder = false\n break\n end\n else\n unless @cards[x+1].value == \"J\"\n inorder = false\n break\n end\n end\n end\n if inorder\n @rank = 4 #straight\n end\n end\n \n #check for flush, straight flush and royal flush\n flush = true\n suit = @cards[0].suit\n @cards.each do |card|\n unless card.suit == suit\n flush = false\n break\n end\n end\n if flush\n if @rank == 4\n @rank = 8 #straight flush\n elsif @cards[1].face and @cards[2].face and @cards[3].face and @cards[4].face\n @rank = 9 #royal flush\n elsif @rank < 6\n @rank = 5 #flush\n end\n end\n end",
"def initialize(name, cash)\n @name = name\n @cash = cash\n @hands = []\n @bet = 0 # amount of money player is betting on default hand\n @total_bet = 0 # total amount bet on all hands thus far\n\n end",
"def init_game\n @io.welcome_msg\n @num_decks = @io.get_num_decks \n @player_cnt = @io.get_player_cnt(@max_players)\n players_names = @io.get_players_names\n\n # Initialize player objects\n 0.upto(players_names.length - 1) do |x|\n @players[x] = Player.new(players_names[x], @bankroll)\n end\n\n # Create the dealer and add as a player\n @dealer = Dealer.new\n @dealer.hit_soft_17 = @hit_soft_17\n @players[@players.length] = @dealer\n end",
"def initialize\r\n puts \"Dealing Gsme\"\r\n @deck = Deck.new\t\r\n @player_hand = Hand.new\r\n @dealer_hand = Hand.new\r\n 2.times {@player_hand.hit!(@deck)}\r\n 2.times {@dealer_hand.hit!(@deck)}\r\n \r\n if @player_hand.value == 21\r\n puts \"BLACKJACK, You win!!\"\r\n :player\r\n end\r\n if @dealer_hand.value == 21\r\n puts \"Dealer has BLACKJACK\"\r\n :dealer\r\n end\r\n end",
"def setup\n @potential_plays = [\"rock\", \"paper\", \"scissors\"]\n @win_counter = Hash[\"P1\",0, \"P2\",0]\n end",
"def start_new_round\n @hands = []\n end",
"def deal_initial_hands\n INITIAL_CARDS.times do\n @players_in_round.each do |player|\n @deck.deal_to player\n end\n end\n end",
"def game_init\r\n state(0)\r\n @game_deck.create_new_deck\r\n @player_deck = {}\r\n @dealer_deck = {}\r\n @player.points = 0\r\n @dealer.points = 0\r\n end",
"def initialize(total_money, position)\n @total_money = total_money\n @position = position\n @hands = Array.new\n @current_hand = 0\n end",
"def initialize\n self.player_hash = {}\n self.user_hash = {}\n self.playing_user_names=[]\n self.started = false\n self.disks_for_each_player=4#default\n self.shuffle_names = true\n end",
"def initialize name\n @name = name\n @my_hand = Hand.new\n @last_card_played = nil # last card played by the player\n end",
"def initialize\n greeting\n init_players\n end",
"def initialize\n @silent = false\n self.deck = create_deck\n self.player = Player.new\n self.player.strategy = Strategy.new(self) #default player strategy\n self.dealer = Dealer.new(\"Dealer\")\n self.dealer.strategy = DealerStrategy.new(self)\n\n @last_hand = false\n end",
"def initialize\n @player1 = Player.new\n @player2 = Player.new\n @deck = Deck.new\n end",
"def cards\n @cards ||= Hand.new\n end",
"def initialize (money, life, fights, respect)\n #The health bar of the player, when the health gets down to 0 the player loses.\n @life = life\n #The wealth that the player has amassed throughout the game.\n @money = money\n #Respect that the player has earned winning fights in the game\n @respect = respect\n #Number of fight events that the player has won.\n @fights = fights\n #List of states for the game.\n @states = []\n\tend",
"def initialize \n\t@first_player = Player.new(\"joueur 1\")\n\t@second_player = Player.new(\"joueur 2\")\n\t self.create_board\n\t self.play_until_victory\n end",
"def init_dealer_hand\n\n @dealer_hand = []\n\n end",
"def bootstrap\n generate_deck = self.deck.empty?\n @shoe = Deck.new(self.num_decks || 1, generate_deck ? nil : self.deck, generate_deck, self.seed )\n @rule_engine = RuleFactory.create( self.rules || RuleFactory::HIT_AND_STAND_ONLY )\n if new_record?\n self.playing = true\n start_game if player_hand.empty? && dealer_hand.empty? # really only need to check this when i want to setup hands in the debugger for testing\n self.outcome = @rule_engine.solve(self)\n self.playing = self.outcome[\"winner\"] == \"none\"\n self.deck = @shoe.to_a\n end\n \n self\n end",
"def setup(numPlayers, myIndex, suspects, locations, weapons)\n @@numPlayers = numPlayers\n @myIndex = myIndex\n @suspects = suspects.clone\n @locations = locations.clone\n @weapons = weapons.clone\n @cards = Array.new\n @inGame = true\n end",
"def initialize\n @shoe = @player_cnt = @dealer = nil\n @num_rounds = @num_shoes = 0\n @num_decks = 1\n @max_players = 4\n @min_bet = 1\n @max_bet = 100\n @bet_increment = 1\n @bankroll = 1000\n @hit_soft_17 = nil\n @even_money_offered = 1 # Hate when casinos don't offer this option\n @players = []\n @broke_players = []\n @io = BlackJackIO.new\n end",
"def initialize (hand = [], score = 0)\n @hand = hand\n @score = score\n end",
"def set_hands(hand_size = 2)\n puts \"Dealing cards\"\n @player.new_hand\n @dealer.new_hand\n\n @dealer.update_deck if @deck.cards_left < ((hand_size * 2) + 1) # Rebuilds deck if empty\n hand_size.times do\n @player.hand.hit\n @dealer.hand.hit\n end\n end",
"def initialize # utilise la classe player pour demander les infos aux joueurs et la classe baord pour lancer la tipar\n puts \" The Houmous Project présente Morbac\"\n @player_one = Player.new\n @player_one.informations\n @player_two = Player.new\n @player_two.informations\n @boboard = Board.new\n end",
"def initialize\n super\n @op_hand = Array.new\n @my_hand = Array.new\n @unseen = Array.new\n @op_lands = Hash.new\n @discards = Hash.new\n @my_lands = Hash.new\n Game::LANDS.each do |land|\n @op_lands[land] = Array.new\n @discards[land] = Array.new\n @my_lands[land] = Array.new\n end\n moveover\n gameover\n end",
"def initialize\r\n\t\t@cards =[]\r\n\t\t%w[Spades Hearts Diamonds Clubs].each do |suit|\r\n\t\t\t%w[2 3 4 5 6 7 8 9 10 J Q K A].each do |face_value|\r\n\t\t\t\t@cards << Card.new(suit, face_value)\r\n\t\t\tend\r\n\t\tend\r\n\t\tshuffle!\r\n\tend",
"def initialize(codes)\n\t\t@cards = codes.split(\" \").map { |s| Card.new(s) }.sort {|a,b| a <=> b}.reverse\n\t\t\n\t\tdistinct_suits = Set.new.merge @cards.map{|card| card.suit}\n\n\t\tis_straight =\n\t\t\t@cards[0].value-1 == @cards[1].value &&\n\t\t\t@cards[0].value-2 == @cards[2].value &&\n\t\t\t@cards[0].value-3 == @cards[3].value &&\n\t\t\t@cards[0].value-4 == @cards[4].value\n\n\t\tif @is_straight && @cards[0].value == 14 && distinct_suits.size == 1\n\t\t\t@hand = 'ROYAL_FLUSH'\n\t\t\treturn\n\t\tend\n\n\t\tif is_straight && distinct_suits.size == 1\n\t\t\t@hand = 'STRAIGHT_FLUSH'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# Four of a kind\n\t\tif equal_values([0,1,2,3])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3,4])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([1])\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Full house\n\t\tif equal_values([0,1,2],[3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\t@ranking_cards = [@cards[0]]\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[2,3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\tset_ranking_cards([2])\n\t\t\treturn\n\t\tend\n\n\t\t# Flush\n\t\tif distinct_suits.size == 1\n\t\t\t@hand = 'FLUSH'\n\t\t\tset_ranking_cards([0,1,2,3,4])\n\t\t\treturn\n\t\tend\n\n\t\t# Straight\n\t\tif is_straight\n\t\t\t@hand = 'STRAIGHT'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# 3 of a kind\n\t\tif equal_values([0,1,2])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([1,0,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3,4])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([2,0,1])\n\t\t\treturn\n\t\tend\n\n\n\t\t# 2 pair\n\t\tif equal_values([0,1],[2,3])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,2,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,3,2])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([1,3,0])\n\t\t\treturn\n\t\tend\n\n\t\t# pair\n\t\tif equal_values([0,1])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([0,2,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([1,0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([2,0,1,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([3,4])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([3,0,1,2])\n\t\t\treturn\n\t\tend\n\n\t\t@hand = 'HIGH_CARD'\n\t\tset_ranking_cards([0,1,2,3,4])\n\n\tend",
"def initialize\n #Initialize list of players\n @player_list = []\n @highscore_list = []\n end",
"def update_hands\n\t\tplayers.each do |player|\n\t\t\tnext if player.folded?\n\t\t\tdiscard_idx = player.get_discard\n\t\t\tplayer.update_hand(discard_idx, @deck)\n\t\tend\n\tend",
"def initialize_game_board\n current_player = players.last\n gameboard_id = id\n update(current_player: current_player, current_state: 'ingame')\n Centercard.find_or_create_by!(gameboard_id: gameboard_id)\n Graveyard.find_or_create_by!(gameboard_id: gameboard_id)\n Playerinterceptcard.find_or_create_by!(gameboard_id: gameboard_id)\n Interceptcard.find_or_create_by!(gameboard_id: gameboard_id)\n\n # pp Player.find(current_player).gameboard\n players.each do |player|\n lobby_card = 0\n player.user.monsterone.blank? ? nil : lobby_card += 1\n player.user.monstertwo.blank? ? nil : lobby_card += 1\n player.user.monsterthree.blank? ? nil : lobby_card += 1\n Handcard.find_or_create_by!(player_id: player.id) # unless player.handcard\n Handcard.draw_handcards(player.id, self, 4) unless lobby_card.positive?\n Handcard.draw_handcards(player.id, self, 5 - lobby_card) if lobby_card.positive?\n Handcard.draw_one_monster(player.id, self) unless lobby_card.positive?\n end\n end",
"def initialize(current_player)\n\n\t@current_player = current_player\n\n\t@board = Array.new(BOARD_MAX_INDEX + 1) {Array.new(BOARD_MAX_INDEX + 1) {EMPTY_POS} }\n\n#puts \"You are playing as #{HUMAN_PLAYER}, and the computer is playing as #{COMPUTER_PLAYER}.\"\n\nend",
"def initialize_player\n\n Player.new\n\nend",
"def start_game\n set_game_state 'play'\n @deck = Deck.new\n @deck.shuffle\n @deck.deal @players\n @hand_played = []\n @cards_on_table = []\n @war_is_on = false\n nil\n end",
"def initialize(player_entities)\n @turn = 0\n @turn_count = 1\n @players = player_entities\n end",
"def initialize\n puts \"Let's play a game of Black Jack.\"\n self.deck = Deck.new\n self.shoe = Shoe.new\n self.dealer = []\n self.player = []\n shoe.shuffle!\n self.dealer_score = 0\n self.player_score = 0\n self.game_counter = 0\n end",
"def initialize\n\t\t@health_info = { previous_health: PLAYER_MAX_HEALTH, heal_amount: 0 }\n\t\t@@look_comfort = 0\n\t\t@look = []\n\tend",
"def new_hand\n @hand = Hand.new\n end",
"def init_for_battle\n super\n self.song_count = 0\n initialize_anger\n end",
"def initialize(*players)\n\t\t@players = players.select{ |p| p.bankroll > 0 }\n\t\t@deck = Deck.new\n\t\t@pot = 0\n\tend",
"def initialize\n @ranks = %w(1 2 3 4 5 6 7 8 9 10 11 12)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n \n\n end",
"def initialize\n super CardNine::Cards::PlayingCard.deck, [:community], STAGES\n end",
"def initialize\n @human = Human.new #(:human) symbol here will be used internally by Player class above, not needed\n # because its a default in the initialize method of the Player class above\n @computer = Computer.new # remove the `(:computer)` right after new for Redesign 1 video\n end",
"def init_deck\n @deck = Deck.new\nend",
"def addHand(hand)\n if @hands.empty?\n super\n end\n end",
"def initialize_game\n setup_boards\n end",
"def initial_hand(hand,name)\n puts\n hand.cards.each do |card|\n puts \"#{name} was dealt #{card.rank}#{card.suit}\"\n end\n puts \"#{name}'s score: #{hand.determine_score}\\n\"\n end",
"def initialize(deck, players)\n @deck = deck\n @players = players\n end",
"def show_hands_final\n player.show_hand\n dealer.show_hand_for_turn\n end",
"def init_bots\r\n p1 = Player.new(\"José\")\r\n p2 = Player.new(\"Josiane\")\r\nend",
"def show_hands_initial\n puts \"\\nYour hand (#{player_hand_total}):\" #\\n creates a new line. makes the command line text easier to read\n players_hand.each do |card|\n puts \"\\t#{card.face} of #{card.suit}\" #\\t indents the given text. not necessary, just easier to read/play\n end\n puts \"\\nDealer is showing #{dealers_hand[0].face} of #{dealers_hand[0].suit}\"\n end",
"def reset\n @player_status = \"in\" \n @hands = [] \n @hands_status = [] \n @bets = [] \n @values = [] \n @cur = 0 \n end",
"def initialize(pot, name)\n @pot = pot\n @name = name\n @hand = Hand.new\n end",
"def set_hand hand\n @my_hand = hand\n end",
"def initialize()\n # Cards table, containing cards hashes\n setAllCards()\n end",
"def start_round!\n @players.each { |player| player.empty_hand! }\n @players_in_round.replace(@players)\n @round_winner = nil\n ante_up!\n deal_initial_hands\n end",
"def poker_hand\n # If a hand hasn't been played yet, display a welcome message with some key information.\n welcome_message(@player_positions) unless @hand_played\n\n # Do the players want to start a new hand?\n new_hand_check\n\n # If they do, let's play!\n if @game_running\n\n # Resets and reinitializes everything required for the start of a new hand.\n reset_values\n set_blinds\n init_deck\n deal_hole_cards\n system 'clear'\n puts 'Dealing the cards..'\n sleep(2)\n\n # Starts a loop that checks to see whether a winner needs to be determined.\n while @active_players.length > 1 && @stage_of_play < 4\n # Each time it loops back to this point means we've progressed to the next stage of play and cards need to be dealt.\n deal_community_cards\n\n # If a player has gone all in in the last round of betting, sets the maximum amount that player can win this hand.\n @active_players.map do |player|\n next unless player.chip_stack == 0 && player.max_pot != 0\n\n player.max_winnings = (@pot_size - @committed) + (player.max_pot * @active_players.length)\n player.max_pot = 0\n end\n\n # Resets the committed value AFTER max_winnings has been calculated.\n @committed = 0 if @stage_of_play.positive?\n\n loop do\n # If a player has folded they are no longer active in this hand.\n @active_players.map do |player|\n @active_players.delete(player) if player.folded == true\n end\n\n # If a player is still active and has no chips left, they are all in.\n @all_in_players = 0\n @active_players.map do |player|\n @all_in_players += 1 if player.chip_stack.zero?\n end\n\n # If the player is all in and there are players who aren't all in rotate the array to check the next player.\n if @active_players[0].acted == true && @active_players[0].chip_stack.zero? && @active_players.length != @all_in_players\n @active_players.rotate!\n\n # If the player was the initial raiser and they haven't had their bet raised, move onto the next stage of the hand.\n elsif (@active_players[0].acted == true) && (@active_players[0].current_bet == @table_current_bet)\n @stage_of_play += 1\n\n # Resets everyone so they haven't acted for the next round of betting, except for those who are all in.\n @active_players.map do |player|\n if player.current_bet == @table_current_bet\n player.acted = false unless player.chip_stack.zero?\n end\n player.current_bet = 0\n end\n @table_current_bet = 0\n break\n\n else\n # If all of the above conditions fail, it means the player needs to make a move.\n ready_check(@active_players[0])\n player_action\n end\n end\n end\n end\n end",
"def initialize\n @game_settings = GameSettings.new\n super 920, 480\n self.caption = GAME_TITLE\n @settings_hovered = Options::START_SCREEN[0]\n @title_font, @subtitle_font = Gosu::Font.new(50), Gosu::Font.new(20)\n @background_image = Gosu::Image.new(\"media/background1.jpg\", :tileable => true)\n @blank_card = Gosu::Image.new(\"media/card.png\", :tileable => true)\n @button_option = Gosu::Image.new(\"media/button.png\", :tileable => true)\n @deck = Deck.new\n @playing_cards = Array.new\n @computer_signal = ComputerTimer.new\n @players_created, @mes, @false_mes, @true_mes, @trying_mes = false, false, false, false, false\n @hint = []\n #players\n @pressed, @p1, @p2 = nil, nil, nil\n @game_timer = Timers.new\n end",
"def init_players\r\n markers = MARKERS.dup\r\n (1..NUM_PLAYERS).each do |player_num|\r\n player_type = multiple_choice(\"Choose player #{player_num} type\",\r\n 'h' => Human, 'c' => Computer)\r\n @players << player_type.new(markers.pop)\r\n end\r\n end",
"def initialize\n @ranks = %w(A 2 3 4 5 6 7 8 9 10 J Q K)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n end",
"def initialize\n @ranks = %w(A 2 3 4 5 6 7 8 9 10 J Q K)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n end",
"def finish_round\n @hands = []\n end",
"def initialize(cards = Deck.all_cards)\n end",
"def initialize(black=nil, white=nil, handicap=0, komi=6.5, size=\"19x19\")\n @black = black ||= Player.new(\"Black\")\n @white = white ||= Player.new(\"White\")\n @komi = komi\n @size = size\n @groups = []\n @hashes = []\n @turn = black\n @dead_groups = []\n\n raise ArgumentError, \"Incorrect handicap\" if handicap < 0 or handicap > 9\n @handicap = handicap\n @komi = 0.5 if handicap > 0\n @turn = white if handicap > 1\n\n if size == \"9x9\"\n @letters = %w{A B C D E F G H J}\n handicap_stones = %w{G7 C3 G3 C7 E5 C5 G5 E7 E3}\n elsif size == \"13x13\"\n @letters = %w{A B C D E F G H J K L M N}\n handicap_stones = %w{K10 D4 K4 D10 G7 D7 K7 G10 G4}\n elsif size == \"19x19\"\n @letters = %w{A B C D E F G H J K L M N O P Q R S T}\n handicap_stones = %w{Q16 D4 Q4 D16 K10 D10 Q10 K16 K4}\n else\n raise ArgumentError, \"Incorrect board size\"\n end\n\n case @handicap\n when 2..5, 7, 9\n handicap_stones[0..(@handicap-1)].each {|s| self.add_stone(s, :black)}\n when 6, 8\n handicap_stones[0..@handicap].each {|s| self.add_stone(s, :black)}\n self.remove_stone(handicap_stones[4]) # Middle stone\n end\n end",
"def initialize(player)\n @player = player\n @cards = player.cards\n @@all << self\n end",
"def initialize\n\t\t@players = []\n\t\t@players << @p1 = Player.new(\"p1\")\n\t\t@players << @p2 = ComputerPlayer.new(\"p2\")\n\t\t\n\t\t#@p1 = Player.new\n\t\t#@p2 = ComputerPlayer.new\n\t\tplay\n\tend",
"def initialize_deck\n new_deck = {}\n SUITS_SYMBOLS.each do |suit|\n new_deck[suit] = %w(2 3 4 5 6 7 8 9 10 J Q K A)\n end\n new_deck\nend",
"def setup_players!(hunter_connection, hunter_name, prey_connection, prey_name)\n\t\t@hunter = Hunter.new(self, hunter_connection, hunter_name)\n\t\t@prey = Prey.new(self, prey_connection, prey_name)\n\tend",
"def initialize(rank, suit)\n @rank = rank\n @suit = suit\n # instantiate 2 variables that the deck class can use\n end",
"def setup_players\n @players = []\n @players << add(Spaceship, 400, 320)\n @players << add(Tank, width/2, height-100)\n end",
"def initialize(players)\n self.players = players\n end",
"def initialize (humanplayer)\n @humanplayer = HumanPlayer.new(\"#{humanplayer}\",100,1)\n @player_1 = Player.new(\"Melee creep\", 10)\n @player_2 = Player.new(\"Ranged creep\", 10)\n @player_3 = Player.new(\"Siege creep\", 10)\n @player_4 = Player.new(\"Mega creep\", 10)\n @ennemies = [@player_1, @player_2, @player_3, @player_4]\n end",
"def reset_players_hand(current_player)\n if current_player == 1 then\n @player1_hand = []\n end\n if current_player == 2 then\n @player2_hand = []\n end\n if current_player == 3 then\n @player3_hand = []\n end\n if current_player == 4 then\n @player4_hand = []\n end\n end",
"def test_initialize\n assert_equal(2, @TwoCardHand.max_hand, 'Expected max hand size: 2 for <TwoCardHand>')\n assert_equal(2, @TwoCardHand.cards_in_hand, 'Expected hand size: 2 on initialization')\n\n assert_equal(5, @FiveCardHand.max_hand, 'Expected max hand size: 5 for <FiveCardHand>')\n assert_equal(5, @FiveCardHand.cards_in_hand, 'Expected hand size: 5 on initialization')\n end",
"def clear_hands\n @player_hand = []\n @dealer_hand = []\n end",
"def initialize\n @num_players = 0\n @round_players=0\n @deck = Deck.new\n @dealer = Dealer.new\n @players = []\n @ui = UserInterface.new\n end",
"def init\n\t\t@state = NewGame.new(self)\n\t\t# Deck.create({:game => self})\n\tend",
"def initialize()\n\t\tcards = []\n\t\t@board = cards\n\t\t@deck = Deck.new\n\t\tSTARTINGCARDS.times { @board << @deck.draw }\n\tend",
"def initialize\n @ranks = %w(A 2 3 4 5 6 7 8 9 10 J Q K)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n end",
"def game_setup\n end",
"def initialize(needed_players=2)\n @players = []\n @needed_players = needed_players\n end",
"def initialize\n @e_tanks = 4\n\n # alive (true) ; defeated (false)\n @bubble_man = false\n @air_man = false\n @quick_man = false\n @wood_man = false\n @crash_man = false\n @flash_man = false\n @metal_man = false\n @heat_man = false\n end",
"def initialize(player)\n @player = player\n end",
"def opening_hand(players_cards, computers_cards, deck)\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n end",
"def initialize num_decks = 1\n @shoe = []\n @used_cards = []\n @dealt_cards = []\n num_decks.times do\n @shoe.concat(Deck.new.deck)\n end\n shuffle!\n end",
"def init_deal(play_deck, dealer_hand, player_hand)\n for i in 1..2\n dealer_hand << hit(play_deck)\n player_hand << hit(play_deck)\n end\nend",
"def initialize\n\t\tsystem \"clear\"\n\t\tputs \"Lets play hangman!\"\n \t\t@guess_count = 0\n \t\t@game_status = false\n \t\t@guessed_letters=[]\n \t\t@guessing_word=[]\n \tend",
"def initialize(name)\n @name = name\n @best_guess = []\n @key_pegs = []\n @encoded_guess = []\n @turn = 0\n @previous_shuffles = []\n @previous_values = []\n play\n end"
] | [
"0.7758745",
"0.7235557",
"0.7200113",
"0.7123786",
"0.70800775",
"0.7041325",
"0.704064",
"0.70072865",
"0.6998174",
"0.68564904",
"0.68395317",
"0.6826799",
"0.679842",
"0.6769762",
"0.6767948",
"0.6763759",
"0.67102075",
"0.6707476",
"0.6659009",
"0.6650143",
"0.66490406",
"0.6637445",
"0.657475",
"0.65721166",
"0.65461195",
"0.65344",
"0.6521268",
"0.6518763",
"0.6510223",
"0.650406",
"0.650235",
"0.6497482",
"0.6487662",
"0.6475971",
"0.6469106",
"0.645869",
"0.6440019",
"0.6435138",
"0.64305156",
"0.64048004",
"0.6386916",
"0.6382166",
"0.6357489",
"0.6351057",
"0.63493115",
"0.6333796",
"0.6330846",
"0.63299966",
"0.632194",
"0.63209146",
"0.63170695",
"0.63100517",
"0.6300357",
"0.62980837",
"0.62956136",
"0.62925136",
"0.62890494",
"0.6287796",
"0.6274885",
"0.62696373",
"0.6267757",
"0.6267739",
"0.6263495",
"0.6255919",
"0.62437475",
"0.62385106",
"0.6235852",
"0.62269133",
"0.6222079",
"0.6214898",
"0.62126404",
"0.6210546",
"0.6210402",
"0.62050295",
"0.61983365",
"0.61940795",
"0.6187896",
"0.6176458",
"0.61705667",
"0.6170306",
"0.61693853",
"0.6156953",
"0.6156745",
"0.61546916",
"0.61447704",
"0.6144327",
"0.61436",
"0.6142584",
"0.6142288",
"0.6137491",
"0.61360663",
"0.613291",
"0.6121117",
"0.61117816",
"0.61108613",
"0.60885656",
"0.6086389",
"0.6084845",
"0.607976",
"0.60781705"
] | 0.8422662 | 0 |
end init_play_hand Initialize Player Hands | def init_dealer_hand
@dealer_hand = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_player_hands\n\n @player1_hand = []\n @player2_hand = []\n @player3_hand = []\n @player4_hand = []\n\n end",
"def show_hands_initial\n player.show_hand\n dealer.show_hand\n end",
"def starting_hands\n @dealer_hand.push(random_card)\n @player_hand.push(random_card, random_card)\n end",
"def show_hands_final\n player.show_hand\n dealer.show_hand_for_turn\n end",
"def start_hand\n @hands[0] = DealerHand.new\n @hands[0].hit_soft_17 = @hit_soft_17\n return @hands[0]\n end",
"def initialize(cards)\n\n\n #while start waiting to east to start\n @state = :start\n #hand for each player\n @hands = {} \n @hands[:south] = cards.slice(0,10).sort!\n @hands[:east] = cards.slice(10,10).sort!\n @hands[:west] = cards.slice(20,10).sort!\n \n \n #cards played on table\n @played = {}\n # number of tricks taken by each player\n @taken = {}\n\n #sets taken and played\n @@PLAYERS.each do |player|\n @played[player] = nil\n @taken[player] = Array.new\n end \n # hole cards \n @hole_cards = cards.slice(30,2) \n @on_move = :east \n end",
"def set_hand hand\n @my_hand = hand\n end",
"def addHand(hand)\n if @hands.empty?\n super\n end\n end",
"def show_hand(player, hand)\n display(\"#{player.name} has hand: #{hand.to_s}.\")\n end",
"def initialize name\n @name = name\n @my_hand = Hand.new\n @last_card_played = nil # last card played by the player\n end",
"def be_ready_to_game\n @hand = Hand.new\n end",
"def init_deal\n initialhand = []\n initialhand << @dealingmachine.deal_one_card << @dealingmachine.deal_one_card\n @hands << initialhand\n @hands_status << \"unfinished\"\n end",
"def set_hand\r\n @hand = Hand.find(params[:id])\r\n end",
"def set_hand\n @hand = Hand.find(params[:id])\n end",
"def start_hand\n @num_hands += 1\n @@total_hands += 1\n i = @hands.length\n @hands[i] = Hand.new\n self.place_bet(@hands[i])\n return @hands[i]\n end",
"def show_hands\n puts \"Dealer Shows\"\n @dealer.hand.print_hand(1)\n puts \"Your hand is\"\n @player.hand.print_hand\n end",
"def update_hands\n\t\tplayers.each do |player|\n\t\t\tnext if player.folded?\n\t\t\tdiscard_idx = player.get_discard\n\t\t\tplayer.update_hand(discard_idx, @deck)\n\t\tend\n\tend",
"def set_hand(hand)\n\t\t\t@hand = hand\n\t\tend",
"def set_hand(hand)\n\t\t\t@hand = hand\n\t\tend",
"def start_new_round\n @hands = []\n end",
"def hands\n dealer.hand = []\n player.hand = []\n end",
"def poker_hand\n # If a hand hasn't been played yet, display a welcome message with some key information.\n welcome_message(@player_positions) unless @hand_played\n\n # Do the players want to start a new hand?\n new_hand_check\n\n # If they do, let's play!\n if @game_running\n\n # Resets and reinitializes everything required for the start of a new hand.\n reset_values\n set_blinds\n init_deck\n deal_hole_cards\n system 'clear'\n puts 'Dealing the cards..'\n sleep(2)\n\n # Starts a loop that checks to see whether a winner needs to be determined.\n while @active_players.length > 1 && @stage_of_play < 4\n # Each time it loops back to this point means we've progressed to the next stage of play and cards need to be dealt.\n deal_community_cards\n\n # If a player has gone all in in the last round of betting, sets the maximum amount that player can win this hand.\n @active_players.map do |player|\n next unless player.chip_stack == 0 && player.max_pot != 0\n\n player.max_winnings = (@pot_size - @committed) + (player.max_pot * @active_players.length)\n player.max_pot = 0\n end\n\n # Resets the committed value AFTER max_winnings has been calculated.\n @committed = 0 if @stage_of_play.positive?\n\n loop do\n # If a player has folded they are no longer active in this hand.\n @active_players.map do |player|\n @active_players.delete(player) if player.folded == true\n end\n\n # If a player is still active and has no chips left, they are all in.\n @all_in_players = 0\n @active_players.map do |player|\n @all_in_players += 1 if player.chip_stack.zero?\n end\n\n # If the player is all in and there are players who aren't all in rotate the array to check the next player.\n if @active_players[0].acted == true && @active_players[0].chip_stack.zero? && @active_players.length != @all_in_players\n @active_players.rotate!\n\n # If the player was the initial raiser and they haven't had their bet raised, move onto the next stage of the hand.\n elsif (@active_players[0].acted == true) && (@active_players[0].current_bet == @table_current_bet)\n @stage_of_play += 1\n\n # Resets everyone so they haven't acted for the next round of betting, except for those who are all in.\n @active_players.map do |player|\n if player.current_bet == @table_current_bet\n player.acted = false unless player.chip_stack.zero?\n end\n player.current_bet = 0\n end\n @table_current_bet = 0\n break\n\n else\n # If all of the above conditions fail, it means the player needs to make a move.\n ready_check(@active_players[0])\n player_action\n end\n end\n end\n end\n end",
"def show_hands_initial\n puts \"\\nYour hand (#{player_hand_total}):\" #\\n creates a new line. makes the command line text easier to read\n players_hand.each do |card|\n puts \"\\t#{card.face} of #{card.suit}\" #\\t indents the given text. not necessary, just easier to read/play\n end\n puts \"\\nDealer is showing #{dealers_hand[0].face} of #{dealers_hand[0].suit}\"\n end",
"def initialize\n @cards = full_deck.shuffle\n @used = []\n @inhand = []\n @hands = []\n end",
"def play\n @last_card_played = @my_hand.pick_random\n set_last_card_played @last_card_played\n end",
"def play_internally(player,hand_index)\n p = player\n i = hand_index\n\n while p.is_playing(i)\n p.print_hand(i) # print the current hand\n\n #if blackjack, no need to play further, only a moron would hit more, they'd obviously stand.\n if p.blackjack(i)\n p.disable_playing(i)\n puts \"***Blackjack!!! No need to play further!\" # TODO maybe play for a hard blackjack, in which case just comment out this BLOCK! code will be shorter\n break\n end # end blackjack if\n\n print \"Please choose from the following {hit, stand, split, double, surrender}: \"\n decision = gets.chomp\n\n if decision == \"hit\"\n p.push_card(i,get_card)\n elsif decision == \"stand\"\n p.disable_playing(i) # just finish this hand\n elsif decision == \"split\" and p.player_number >=0 # dealer cant split\n if i == 0 and p.can_split() # i==0 is redundant actually. p.can_split() just checks\n p.create_new_hand_for_split() # create new hands\n p.push_card(0,get_card) # offer one more card for Hand 0\n p.push_card(1,get_card) # offer one more card for Hand 1\n puts \"Player #{p.player_number} Split call was done on hand #{i}\"\n p.print_Player # print the players new set of Hands\n else\n puts \"Player #{p.player_number} Split call was denied on hand #{i}\"\n end\n elsif decision == \"double\" and p.player_number >=0 #dealer cant double\n ## Player can double his hand after splitting so not putting that condition\n if p.can_double(i) # check if its ok to double, note that a split hand can indeed be doubled\n p.modify_for_double(i) # modify bet for doubling\n p.push_card(i,get_card) # take one more card & stand down\n puts \"Player #{p.player_number} has called Double on his hand #{i}\"\n p.print_Player\n else\n puts \"Player #{p.player_number} Double call was denied on hand #{i}\"\n end\n elsif decision == \"surrender\" and p.player_number >=0 #dealer cant surrnder\n if p.can_surrender()\n p.surrender()\n puts \"Player #{p.player_number} Surrender on hand #{i}\"\n else\n puts \"Player #{p.player_number} Surrender call was denied on hand #{i}\"\n end\n end# end hit, stand, split, double if\n\n # If busted, can't play further\n if p.get_value(i) > 21\n p.print_hand(i)\n puts \"***BUST!!! Can't Play Further!\"\n p.disable_playing(i)\n end\n\n end # end while hand is being played out\n\n end",
"def show_hands\n puts \"\\nDealer hand: #{@dealer_hand}\" \" | Hand Value: #{hand_value(@dealer_hand)}\"\n puts \"\\nYour hand: #{@player_hand}\" \" | Hand Value: #{hand_value(@player_hand)}\"\n end",
"def clear_hands\n @player_hand = []\n @dealer_hand = []\n end",
"def reset_hand\n @hand_played = []\n end",
"def new_hand\n @hand = Hand.new\n end",
"def set_hands(hand_size = 2)\n puts \"Dealing cards\"\n @player.new_hand\n @dealer.new_hand\n\n @dealer.update_deck if @deck.cards_left < ((hand_size * 2) + 1) # Rebuilds deck if empty\n hand_size.times do\n @player.hand.hit\n @dealer.hand.hit\n end\n end",
"def play_hand( player, hand )\n @events.handle(:player_play_hand, player, hand) do\n\n while hand.active?\n @events.handle(:player_play_hand_turn, player, hand) do\n if :split == take_turn(player, hand)\n # Automatically return if Player decided to split their hand\n return\n end\n end\n end\n\n end\n end",
"def deal_initial_hands\n INITIAL_CARDS.times do\n @players_in_round.each do |player|\n @deck.deal_to player\n end\n end\n end",
"def analyze_hand\n pairs = 0\n straight = 0\n flush = 0\n\n # for now be conservative\n @play = 3\n\n # check for pairs\n\n\n # check for flush\n\n # check for straight\n\n\n\n # check for special hands\n #full house\n #royal flush\n #straight flush\n \n end",
"def play\n @players.each do |p|\n @events.handle(:player_play, p) do\n p.hands.each {|hand| play_hand(p, hand) }\n\n p.hands.reject! {|hand| hand.invalid }\n end\n end\n\n # Dealer plays his hand last.\n @events.handle(:dealer_play, @dealer) do\n dealer_play_hand\n end\n end",
"def display_hand\n display_hand = []\n @hand.each do |h|\n display_hand << \"#{create_hand(h)}\"\n end\n display_hand\n end",
"def getHand()\n return @hand\n end",
"def initialize\r\n puts \"Dealing Gsme\"\r\n @deck = Deck.new\t\r\n @player_hand = Hand.new\r\n @dealer_hand = Hand.new\r\n 2.times {@player_hand.hit!(@deck)}\r\n 2.times {@dealer_hand.hit!(@deck)}\r\n \r\n if @player_hand.value == 21\r\n puts \"BLACKJACK, You win!!\"\r\n :player\r\n end\r\n if @dealer_hand.value == 21\r\n puts \"Dealer has BLACKJACK\"\r\n :dealer\r\n end\r\n end",
"def initial_hand(hand,name)\n puts\n hand.cards.each do |card|\n puts \"#{name} was dealt #{card.rank}#{card.suit}\"\n end\n puts \"#{name}'s score: #{hand.determine_score}\\n\"\n end",
"def print_all_hands(players)\n players.each { |player| \n self.print_hand(player, player.get_initial_hand)\n }\n end",
"def initialize_players\n\n end",
"def initialize (hand = [], score = 0)\n @hand = hand\n @score = score\n end",
"def initialize(pot, name)\n @pot = pot\n @name = name\n @hand = Hand.new\n end",
"def example3(hand_values)\n hand = PokerHand.new hand_values\n puts \"Hand generated, coded: #{hand.coded_info}\"\n puts \"In human format: #{hand}\"\n puts '----'\n puts \"Poker hand name: #{hand.poker_hand}\"\n end",
"def finish_round\n @hands = []\n end",
"def start_game\n set_game_state 'play'\n @deck = Deck.new\n @deck.shuffle\n @deck.deal @players\n @hand_played = []\n @cards_on_table = []\n @war_is_on = false\n nil\n end",
"def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end",
"def print_player_hands()\n puts \"--- Player #{@position} --- \"\n @hands.each do |hand| # The player might have multiple hands, if splitting was used\n puts hand.to_s() # Print the details of the hand\n end\n end",
"def reset_players_hand(current_player)\n if current_player == 1 then\n @player1_hand = []\n end\n if current_player == 2 then\n @player2_hand = []\n end\n if current_player == 3 then\n @player3_hand = []\n end\n if current_player == 4 then\n @player4_hand = []\n end\n end",
"def get_hand\n return @cards_in_hand\n end",
"def setup\n @potential_plays = [\"rock\", \"paper\", \"scissors\"]\n @win_counter = Hash[\"P1\",0, \"P2\",0]\n end",
"def opening_hand(players_cards, computers_cards, deck)\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n players_cards.push (the_draw(deck))\n computers_cards.push (the_draw(deck))\n end",
"def start_round!\n @players.each { |player| player.empty_hand! }\n @players_in_round.replace(@players)\n @round_winner = nil\n ante_up!\n deal_initial_hands\n end",
"def example4 poker_hands\n deck = PokerDeck.new\n deck.shuffle!\n hand = deck.hand\n num = 1\n while !poker_hands.include?(hand.poker_hand) do\n num += 1\n deck.shuffle!\n hand = deck.hand\n puts \"[#{num}] #{hand.coded_info}\"\n end\n puts '----'\n hand.order!\n puts \"The hand, coded and ordered: #{hand.coded_info}\"\n puts \"Same hand, ordered: #{hand}\"\n puts \"Poker hand type: #{hand.poker_hand}\"\n end",
"def initialize (cards)\n #sort the cards and store them in @cards\n @cards = Array.new\n cards.each do |card|\n @cards << Card.new(card)\n end\n @cards.sort!\n \n #determine the rank of the hand\n @rank = 0\n \n #see if at least one pair exists\n if @cards[0] == @cards[1] or @cards[1] == @cards[2] or @cards[2] == @cards[3] or @cards[3] == @cards[4]\n @handStart = @cards[0] == @cards[1] ? 0 : @cards[1] == @cards[2] ? 1 : @cards[2] == @cards[3] ? 2 : 3\n @rank = 1 #one pair\n #see if it's part of a three of a kind\n if @cards[0] == @cards[2] or cards[1] == @cards[3] or cards[2] == @cards[4]\n #see if hand is a full house\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3] and @cards[2] == @cards[4]) or (@cards[0] == @cards[1] and @cards[0] == @cards[2] and @cards[3] == @cards[4])\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n @rank = 6 #full house\n else\n @rank = 3 #three of a kind\n \n #see if it's part of a four of a kind\n if @cards[0] == @cards[3] or @cards[1] == @cards[4]\n @rank = 7 #four of a kind\n end\n end\n else\n #see if there are two pairs\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3]) or (@cards[1] == @cards[2] and @cards[3] == @cards[4]) or (@cards[0] == @cards[1] and @cards[3] == @cards[4])\n @rank = 2 #two pairs\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n end\n end\n else\n #check for straight\n inorder = true\n 0.upto(@cards.count - 2) do |x|\n if @cards[x].face and !@cards[x+1].face\n inorder = false\n break\n elsif !@cards[x].face and !@cards[x+1].face\n unless @cards[x].value + 1 == @cards[x+1].value\n inorder = false\n break\n end\n else\n unless @cards[x+1].value == \"J\"\n inorder = false\n break\n end\n end\n end\n if inorder\n @rank = 4 #straight\n end\n end\n \n #check for flush, straight flush and royal flush\n flush = true\n suit = @cards[0].suit\n @cards.each do |card|\n unless card.suit == suit\n flush = false\n break\n end\n end\n if flush\n if @rank == 4\n @rank = 8 #straight flush\n elsif @cards[1].face and @cards[2].face and @cards[3].face and @cards[4].face\n @rank = 9 #royal flush\n elsif @rank < 6\n @rank = 5 #flush\n end\n end\n end",
"def show_hands(players)\n for player in players\n for hand in player.hands\n puts \"#{player.to_s} ------ #{hand.to_s}\"\n end\n end\n end",
"def init_players\n\t\t@human = Human.new(\"Jack\", Field.new)\n\t\t@computer = Computer.new(Field.new)\n\t\tinit_fields\n\tend",
"def reset_hand\n @hand = []\n end",
"def play_round\n for player in @players\n for hand in player.hands\n # Check for split from previous hand\n if hand.cards.length == 1 and hand.is_split\n hit_split_hand(player, hand)\n end\n\n if player.is_dealer and not @play_god\n hand.play(@shoe)\n else\n while hand.can_hit and not hand.is_done\n move = @io.get_players_move(@dealer, player, hand)\n case move\n when \"h\" # Hit\n hit_hand(player, hand)\n when \"d\" # Double down\n hit_hand(player, hand)\n player.double_bet(hand)\n hand.stand\n when \"t\" # Stand\n hand.stand\n when \"p\" # Split\n player.split_hand(hand)\n @io.show_hands(player)\n hit_split_hand(player, hand)\n when \"g\" # play_god mode, let god.super decide\n if player.is_dealer and @play_god\n hand.play(@shoe)\n else\n @io.try_again\n end\n else\n # Invalid result\n @io.try_again\n end\n end\n end\n @io.show_hand(player, hand)\n end\n end\n end",
"def play\n 2.times {deal}\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) == 21\n bjwin\n elsif computer_hand.collect{|x| x.value}.inject(:+) == 21\n bjlose\n else\n action\n end\n end",
"def hand\n hands.first\n end",
"def expected_hand(player, turn)\n my_player = @playerstates.detect{|playerstate| playerstate.name == player.player_name}\n expected_hand = my_player.hand.hand_to_list\n cardsfrom = turn.turn_end\n if cardsfrom.from_deck?\n new_cards = [turn.deck.take]\n elsif cardsfrom.from_stack?\n new_cards = turn.stack.take(cardsfrom.how_many_cards?)\n end\n expected_hand = expected_hand + new_cards\n end",
"def display_hands\n @output.puts '--'\n @output.puts \"| Pot: $#{@game.pot}\"\n @output.puts \"| Ante: $#{@game.ante}\"\n @output.puts '--'\n\n @output.puts @player\n @output.puts \"#{@player.view_hand(:format => :string)}\".rjust(5)\n\n bots = @game.players[[email protected]]\n bots.each do |bot|\n @output.puts ''.center(WIDTH, '-')\n @output.puts bot\n hand = bot.view_hand\n # Hide the first card for all bots. No cheating!\n public_hand = hand[1..hand.size].join(' ')\n # public_hand = bot.view_hand.reject do |c|\n # c == bot.view_hand.first\n # end.join(' ')\n @output.puts \"** #{public_hand}\".rjust(5)\n end\n end",
"def playHand\n\t\ttotal_score = 0\n\t\ti = 0\n\t\tputs @hand.to_str\n\t\tputs @hand.isEmpty?\n\t\twhile not @hand.isEmpty? do\n\t\t\tputs 'Current Hand: %s' % [@hand.to_str]\n\t\t\tword = self.pickBestWord\n\t\t\treturn if word == \".\"\n\t\t\tpoints = getWordScore(word)\n\t\t\ttotal_score += points\n\t\t\tputs '%s earned %d points. Total: %d points' % [word, points, total_score]\n\t\t\[email protected](word)\n\t\t\ti += 1\n\t\tend\n\tend",
"def play(deck)\r\n\t\taction = get_user_action if hand.hand_value < 21\r\n\t\twhile (hand.hand_value) < 21 && (action == \"H\") do\r\n\t\t\tdraw_card(deck.deal_card)\r\n\t\t\tshow_hand\r\n\t\t\taction = get_user_action if hand.hand_value < 21\r\n\t\tend\r\n\tend",
"def printEmptyHandMessage(player, dealer)\n puts dealer.printHands(true)\n puts player.printHands\n puts \"Uh oh. This hand is now over 21. Sorry :(\"\n pressKeyToContinue\nend",
"def initialize(codes)\n\t\t@cards = codes.split(\" \").map { |s| Card.new(s) }.sort {|a,b| a <=> b}.reverse\n\t\t\n\t\tdistinct_suits = Set.new.merge @cards.map{|card| card.suit}\n\n\t\tis_straight =\n\t\t\t@cards[0].value-1 == @cards[1].value &&\n\t\t\t@cards[0].value-2 == @cards[2].value &&\n\t\t\t@cards[0].value-3 == @cards[3].value &&\n\t\t\t@cards[0].value-4 == @cards[4].value\n\n\t\tif @is_straight && @cards[0].value == 14 && distinct_suits.size == 1\n\t\t\t@hand = 'ROYAL_FLUSH'\n\t\t\treturn\n\t\tend\n\n\t\tif is_straight && distinct_suits.size == 1\n\t\t\t@hand = 'STRAIGHT_FLUSH'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# Four of a kind\n\t\tif equal_values([0,1,2,3])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3,4])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([1])\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Full house\n\t\tif equal_values([0,1,2],[3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\t@ranking_cards = [@cards[0]]\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[2,3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\tset_ranking_cards([2])\n\t\t\treturn\n\t\tend\n\n\t\t# Flush\n\t\tif distinct_suits.size == 1\n\t\t\t@hand = 'FLUSH'\n\t\t\tset_ranking_cards([0,1,2,3,4])\n\t\t\treturn\n\t\tend\n\n\t\t# Straight\n\t\tif is_straight\n\t\t\t@hand = 'STRAIGHT'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# 3 of a kind\n\t\tif equal_values([0,1,2])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([1,0,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3,4])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([2,0,1])\n\t\t\treturn\n\t\tend\n\n\n\t\t# 2 pair\n\t\tif equal_values([0,1],[2,3])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,2,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,3,2])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([1,3,0])\n\t\t\treturn\n\t\tend\n\n\t\t# pair\n\t\tif equal_values([0,1])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([0,2,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([1,0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([2,0,1,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([3,4])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([3,0,1,2])\n\t\t\treturn\n\t\tend\n\n\t\t@hand = 'HIGH_CARD'\n\t\tset_ranking_cards([0,1,2,3,4])\n\n\tend",
"def hit_hand(player, hand)\n card = nil\n if @play_god\n card = @io.set_card(@shoe, player, nil)\n else\n card = @shoe.deal_card\n end\n hand.hit(card)\n end",
"def start\n @win_state = CHECK # clear out win_state for new games\n get_player_name\n deck.deal_hand(players)\n show_flops\n player_turn\n dealer_turn\n check_winner\n play_again?\n end",
"def hand\n return @hands[0] if self.has_a_hand\n return nil\n end",
"def winner_take_hand\n from_war = @state == 'war'\n\n #save this for use in the stats display later\n @hand_played.freeze \n\n @winning_player = get_player_by_name @hand_played.try(:first).try(:owner)\n # @hand_played.each{|x| cards_played.push(x)}\n\n unless @winning_player.blank? \n # first calculate the loser's lost cards and metadata\n @cards_on_table.each do |c|\n get_player_by_name( c.try(:owner) ).in_battle\n get_player_by_name( c.try(:owner) ).lose_cards [c]\n end\n\n # winner puts all cards on table at the end of their deck, change ownership\n @winning_player.gain_cards(@cards_on_table)\n @winning_player.won_battle\n\n # reset var to empty array\n @cards_on_table = []\n end\n\n # check if all players can continue\n players.each do |p|\n player_leaves_game(p) if p.try(:cards).try(:count) < 1\n end\n\n display_battle_results\n set_game_state 'play'\n end",
"def has_a_hand\n return 1 if @hands.length > 0\n return nil\n end",
"def initialize\n @game_settings = GameSettings.new\n super 920, 480\n self.caption = GAME_TITLE\n @settings_hovered = Options::START_SCREEN[0]\n @title_font, @subtitle_font = Gosu::Font.new(50), Gosu::Font.new(20)\n @background_image = Gosu::Image.new(\"media/background1.jpg\", :tileable => true)\n @blank_card = Gosu::Image.new(\"media/card.png\", :tileable => true)\n @button_option = Gosu::Image.new(\"media/button.png\", :tileable => true)\n @deck = Deck.new\n @playing_cards = Array.new\n @computer_signal = ComputerTimer.new\n @players_created, @mes, @false_mes, @true_mes, @trying_mes = false, false, false, false, false\n @hint = []\n #players\n @pressed, @p1, @p2 = nil, nil, nil\n @game_timer = Timers.new\n end",
"def initialize\n @silent = false\n self.deck = create_deck\n self.player = Player.new\n self.player.strategy = Strategy.new(self) #default player strategy\n self.dealer = Dealer.new(\"Dealer\")\n self.dealer.strategy = DealerStrategy.new(self)\n\n @last_hand = false\n end",
"def initialize\n self.player_hash = {}\n self.user_hash = {}\n self.playing_user_names=[]\n self.started = false\n self.disks_for_each_player=4#default\n self.shuffle_names = true\n end",
"def play_dealer_hand(hand)\n\tputs \"stub: play_dealer_hand\"\nend",
"def set_player\n\n end",
"def createNewHand(deck, bet=nil)\n \tif @hands.empty?\n \t hand = DealerHand.new()\n \t hand.addCard(deck.removeCard)\n hand.addCard(deck.removeCard)\n addHand(hand)\n \tend\n end",
"def bot_hand(player_hand)\n @elements.keys.sample\n end",
"def initialize\n\t\t@health_info = { previous_health: PLAYER_MAX_HEALTH, heal_amount: 0 }\n\t\t@@look_comfort = 0\n\t\t@look = []\n\tend",
"def restock_hand!\n return if Bot::CONFIG.hand_size == unplayed_cards.count\n (Bot::CONFIG.hand_size - unplayed_cards.count).times do\n add_player_card PlayerCard.create(answer: game.available_answers.sample)\n end\n end",
"def get_hand\n\t\t12.times {\n\t\t\[email protected](@deck[@top_card])\n\t\t\t@top_card += 1\n\t\t}\n\t\t@start_time = Time.now\n\tend",
"def play_game\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Assign the player and dealer an initial starting card\r\n playerHand = get_new_card\r\n dealerHand = get_new_card\r\n\r\n #Call the method responsible for dealing new cards to the player\r\n playerHand = complete_player_hand(playerHand, dealerHand)\r\n\r\n #If the player has not gone bust, call the method responsible for managing\r\n #dealer's hand\r\n if playerHand <= 21 then\r\n dealerHand = play_dealer_hand(dealerHand)\r\n end\r\n\r\n #call the method responsible for determining the results of the game\r\n determine_winner(playerHand, dealerHand)\r\n\r\n end",
"def initialize\n @secret_code = Code::random\n @steps = 0\n @guess = nil\n @in_play = true\n end",
"def play_round()\n # Deal hand to all players\n for p in @players\n hand = Hand.new\n hand.deal_hand()\n p.hands << hand\n end\n\n # Dealer deals his own hand\n @dealers_hand.deal_hand()\n\n # Gather bets from all players\n for p in @players\n game_state()\n puts \"Player #{p.player}, how much would you like to bet?\"\n bet_amount = gets.chomp.to_i\n while !(p.can_bet(bet_amount))\n game_state()\n puts \"Player #{p.player}, that's an invalid bet! Try again.\"\n bet_amount = gets.chomp.to_i\n end\n p.bet(bet_amount)\n\n for h in p.hands\n p.place_bet(h)\n end\n end\n\n # Allow players to finalize their bet(s) and hand(s)\n for player in @players\n for hand in player.hands\n while !(hand.is_stand())\n valid_moves = ['h']\n if hand.is_split and player.can_bet_double()\n valid_moves += ['s', 'd', 'e']\n elsif player.can_bet_double()\n valid_moves += ['d', 'e']\n else\n valid_moves += ['e']\n end\n\n game_state()\n puts \"Player #{player.player}, what would you like to do for your #{hand} hand? Your valid moves: #{valid_moves}\"\n puts \"Legend: ['h' -> hit, 's' -> split, 'd' -> double down, 'e' -> end turn]\"\n\n move = gets.chomp\n while !(valid_moves.include? move)\n game_state()\n puts \"Player #{player.player}, that is not a valid move! Try again. Your valid moves: #{valid_moves}\"\n puts \"Legend: ['h' -> hit, 's' -> split, 'd' -> double down, 'e' -> end turn]\"\n move = gets.chomp\n end\n\n case move\n when 'h'\n hand.hit()\n when 's'\n new_hand = hand.split()\n player.place_bet(new_hand)\n\n hand.hit()\n new_hand.hit()\n player.hands << new_hand\n when 'd'\n player.place_bet(hand)\n hand.hit()\n hand.stand()\n when 'e'\n hand.stand()\n end\n\n if hand.is_bust()\n puts \"You busted!\"\n hand.stand()\n end\n end\n end\n end\n\n # Determine dealer's ending hand\n while @dealers_hand.value() < 17\n @dealers_hand.hit()\n end\n\n puts \"-=-=-=- Resulting Hands For This Round -=-=-=-\"\n game_state()\n\n # Determine winnings of each player and their hand(s)\n for player in @players\n for hand in player.hands\n if (!hand.is_bust() and @dealers_hand.is_bust()) or (!hand.is_bust() and !@dealers_hand.is_bust and hand.value() > @dealers_hand.value())\n player.win_hand(hand)\n puts \"Player #{player.player}'s #{hand} beat the dealer's #{@dealers_hand} hand!\"\n elsif (hand.is_bust() and @dealers_hand.is_bust()) or (hand.value() == @dealers_hand.value())\n player.tie_hand(hand)\n puts \"Player #{player.player}'s #{hand} tied with the dealer's #{@dealers_hand} hand!\"\n else\n player.lose_hand(hand)\n puts \"Player #{player.player}'s #{hand} lost to the dealer's #{@dealers_hand} hand! :(\"\n end\n end\n end\n\n # Determine who can continue playing\n continuing_players = []\n for player in @players\n if player.money != 0\n continuing_players << player\n else\n puts \"Player #{player.player} has no money and is eliminated!\"\n end\n end\n @players = continuing_players\n\n # Clear all playing hands.\n for player in @players\n player.hands = []\n player.bet = 0\n end\n end",
"def initialize hand\n if hand.is_a? String\n @hand = create_hand hand\n else\n @hand = hand\n end\n\n @analysis = analyse @hand\n end",
"def plays(h)\n\th.each do |bros, inst|\n\t\tputs \"#{bros.capitalize} Marx plays the #{inst}\"\n\tend\nend",
"def main_hand\n if has_hands\n return @hands[0]\n else\n return false\n end\n end",
"def show_hand hand=@hand\n\t\t#Output the title\n\t\tputs \"#\".center(5)+\"Color\".ljust(8)+\"Shading\".ljust(10)+\"Symbol\".ljust(10)+\"Number\"\n\t\tputs \"----------------------------------------\"\n\n\t\t#Output the cards\n\t\thand.length.times{ |card|\n\t\t\tputs \"#{card}\".rjust(3)+\": \"+\"#{hand[card].color}\".ljust(8)+\"#{hand[card].shading}\".ljust(10)+\"#{hand[card].symbol}\".ljust(10)+\" #{hand[card].number}\".rjust(3)\n\t\t}\n\n\t\t#Gives hint for easy development/testing\n\t\t# hint = []\n\t\t# find_set.each do |card| hint.push(@hand.index(card)) end\n\t\t# puts hint.to_s\n\tend",
"def plays(h)\n\th.each do |bros, inst|\n\t\tputs \"#{bros.to_s.capitalize} Marx plays the #{inst}\"\n\tend\nend",
"def initialize(black=nil, white=nil, handicap=0, komi=6.5, size=\"19x19\")\n @black = black ||= Player.new(\"Black\")\n @white = white ||= Player.new(\"White\")\n @komi = komi\n @size = size\n @groups = []\n @hashes = []\n @turn = black\n @dead_groups = []\n\n raise ArgumentError, \"Incorrect handicap\" if handicap < 0 or handicap > 9\n @handicap = handicap\n @komi = 0.5 if handicap > 0\n @turn = white if handicap > 1\n\n if size == \"9x9\"\n @letters = %w{A B C D E F G H J}\n handicap_stones = %w{G7 C3 G3 C7 E5 C5 G5 E7 E3}\n elsif size == \"13x13\"\n @letters = %w{A B C D E F G H J K L M N}\n handicap_stones = %w{K10 D4 K4 D10 G7 D7 K7 G10 G4}\n elsif size == \"19x19\"\n @letters = %w{A B C D E F G H J K L M N O P Q R S T}\n handicap_stones = %w{Q16 D4 Q4 D16 K10 D10 Q10 K16 K4}\n else\n raise ArgumentError, \"Incorrect board size\"\n end\n\n case @handicap\n when 2..5, 7, 9\n handicap_stones[0..(@handicap-1)].each {|s| self.add_stone(s, :black)}\n when 6, 8\n handicap_stones[0..@handicap].each {|s| self.add_stone(s, :black)}\n self.remove_stone(handicap_stones[4]) # Middle stone\n end\n end",
"def play_for_trick \n if @player1.deal == true && @player2.deal == false && [email protected]?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player1.lead_card\n @player1.remove_card_from_hand(leading_card)\n puts @player1.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player2.respond(leading_card)\n @player2.remove_card_from_hand(response_card)\n puts @player1.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player2.name + \" plays the \" + response_card.card_to_string\n \n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n if winning_card == leading_card \n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n else\n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n\n if @player1.deal == false && @player2.deal == true && [email protected]?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player2.lead_card\n @player2.remove_card_from_hand(leading_card)\n puts @player2.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player1.respond(leading_card)\n @player1.remove_card_from_hand(response_card)\n puts @player2.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player1.name + \" plays the \" + response_card.card_to_string\n\n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n\n if winning_card == leading_card \n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n else\n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n end",
"def playable\r\n\t\[email protected] do |x| #go through player hand\r\n\t\t\tif @attack[-1].suit == @trump.suit && x.suit == @trump.suit && x.value > @attack[-1].value\r\n\t\t\t\tx.canplay = true\r\n\t\t\telsif x.suit == @trump.suit && @attack[-1].suit != @trump.suit #player can always trump any non trump\r\n\t\t\t\tx.canplay = true\r\n\t\t\telsif x.suit == @attack[-1].suit && x.value > @attack[-1].value #player can play a higher card of the same suit\r\n\t\t\t\tx.canplay = true\r\n\t\t\telsif x.value == @attack[-1].value && @defend.count == 0\r\n\t\t\t\tx.canplay = true\r\n\t\t\telse\r\n\t\t\t\tx.canplay = false\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def initialize(total_money, position)\n @total_money = total_money\n @position = position\n @hands = Array.new\n @current_hand = 0\n end",
"def initialize(name, cash)\n @name = name\n @cash = cash\n @hands = []\n @bet = 0 # amount of money player is betting on default hand\n @total_bet = 0 # total amount bet on all hands thus far\n\n end",
"def start_round(cards, bet)\n new_hand = Hand.new(cards, bet)\n place_bet(bet)\n @hands.push(new_hand)\n @current_hand = 0\n check_blackjack()\n end",
"def cards\n @cards ||= Hand.new\n end",
"def play_game\n\n Console_Screen.cls #Clear the display area\n \n #Assist the player and dealer an initial starting card\n playerHand = get_new_card\n dealerHand = get_new_card\n \n #Call the method responsible for dealing new cards to the player\n playerHand = complete_player_hand(playerHand, dealerHand)\n \n #If the player has not gone bust, call the method responsible for managing\n #dealer's hand\n if playerHand <= 21 then\n dealerHand = play_dealer_hand(dealerHand)\n end\n\n #call the method responsible for determining the results of the game\n determine_winner(playerHand, dealerHand)\n\n end",
"def display_hand\n hand.each do |card|\n puts \"#{card.value} of #{card.suit}\"\n end\n puts \"#{name} has a #{self.get_hand_score}.\\n\\n\"\n end",
"def setup_players!(hunter_connection, hunter_name, prey_connection, prey_name)\n\t\t@hunter = Hunter.new(self, hunter_connection, hunter_name)\n\t\t@prey = Prey.new(self, prey_connection, prey_name)\n\tend"
] | [
"0.80169576",
"0.760556",
"0.70050603",
"0.69155616",
"0.6876794",
"0.6857762",
"0.673321",
"0.6671339",
"0.66579527",
"0.6627292",
"0.6582967",
"0.657855",
"0.6540019",
"0.6539772",
"0.652969",
"0.6525629",
"0.645023",
"0.6450114",
"0.6450114",
"0.6445877",
"0.64421535",
"0.6433231",
"0.6416405",
"0.6415721",
"0.64080137",
"0.6403228",
"0.640205",
"0.63912743",
"0.63871396",
"0.6378902",
"0.6378891",
"0.63746536",
"0.6339406",
"0.63108027",
"0.6310478",
"0.6310221",
"0.6307668",
"0.6290777",
"0.625604",
"0.6239631",
"0.623865",
"0.62297624",
"0.6220791",
"0.62008715",
"0.6199894",
"0.6197326",
"0.6193521",
"0.6168292",
"0.61645025",
"0.61529267",
"0.61410964",
"0.6131876",
"0.61264604",
"0.6120329",
"0.6119888",
"0.61122686",
"0.6111644",
"0.609155",
"0.60755193",
"0.60660636",
"0.6052698",
"0.60520405",
"0.60444444",
"0.6015439",
"0.6005585",
"0.59972596",
"0.59939027",
"0.59834045",
"0.5982835",
"0.59799594",
"0.5979129",
"0.59790355",
"0.59776944",
"0.5973607",
"0.59726375",
"0.5972286",
"0.59673744",
"0.59663975",
"0.5946703",
"0.59452224",
"0.5939609",
"0.59306484",
"0.5929075",
"0.5924402",
"0.59233916",
"0.59134126",
"0.59091306",
"0.59073496",
"0.5906635",
"0.59048826",
"0.59044546",
"0.589397",
"0.58932525",
"0.5890093",
"0.5889361",
"0.5881343",
"0.58760715",
"0.58721995",
"0.58691585",
"0.5868009"
] | 0.6301033 | 37 |
end of card_shuffle Deal the Dealer a Card | def deal_dealer_card
card = @deck.delete_at(0)
@dealer_hand << card
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal_card\n if @unshuffled_deck[-1] == nil\n @unshuffled_deck = @addhand\n @addhand = @emptyarray\n @x = 0\n end\n card = @unshuffled_deck[@x]\n @unshuffled_deck[@x] = nil\n @x+=1\n return card\n end",
"def hand_over_dealer\r\n puts \"Dealer getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @dealer_deck[@random_card] = random_card_val # to dealer\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@dealer_deck = #{@dealer_deck}\"\r\n end",
"def create_card(deck)\n card = deck.shuffle.pop\nend",
"def deal\n end_round()\n shuffle()\n rounds_dealt = 0\n while rounds_dealt < @hand_size\n @players.each do | player |\n if card = @deck.draw()\n player.hand << card\n else\n return\n end\n end\n rounds_dealt += 1\n end\n end",
"def deal_card\n @deck.pop\n end",
"def deal_cards\n\t\t\tend",
"def deal_card\n random = rand(@playable_cards.size)\n @playable_cards.delete_at(random)\n end",
"def deal_card\r\n random = rand(@playable_cards.size)\r\n @playable_cards.delete_at(random)\r\n end",
"def return\n @cards += @discard\n @discard.clear\n @cards.shuffle\n end",
"def deal\r\n @deck_of_cards.shift\r\n end",
"def deal_card(hand)\n #hand is a string whose valid values are 'player_cards' and 'dealer_cards' \n\n if !['player_cards','dealer_cards'].include?(hand)\n raise \"Unknown hand #{hand}\"\n end \n\n #Check for an empty deck and reshuffle if necessary\n if (session['game_cards'].length == 0) \n\n session['game_cards'] = session['discard']\n session['game_cards'].shuffle!\n session['discard'] = []\n append_message(\"Dealer shuffled the cards.\") \n\n end \n\n #Move the card\n session[hand] << session['game_cards'].pop \n\n end",
"def load_card #(draw card?)\n @cards_array.shuffle!.shift\n end",
"def deal\r\n @cards.shift\r\n end",
"def shuffleCards!()\n\t\[email protected]!\n\tend",
"def deal_card(hand)\n\t# pick a random card and add to the hand\n\tindex = rand($card_deck.length)\n\thand << $card_deck[index]\n\n\t# remove the card from the deck\n\t$card_deck.delete_at(index)\nend",
"def shuffle\r\n @deck_of_cards.shuffle!\r\n end",
"def deal_card\r\n\t\tcards.pop\r\n\tend",
"def redeal\n # take all current cards in play and add to deck\n @deck.concat(@cards_in_play)\n @cards_in_play = Array.new\n\n #shuffle cards \n @deck.shuffle!\n\n #deal 12 more new cards\n @cards_in_play.concat(@deck.pop(12))\nend",
"def shuffle_deck\n if [email protected]?\n @cards = manual_shuffle\n end\n end",
"def deal_cards\n Print.heading('Dealing initial cards')\n deal_card_to_players\n dealer_card_to_dealer(false) #false to hide first dealer card\n deal_card_to_players\n dealer_card_to_dealer(true)\n end",
"def deal\n @deckOfCards.shift\n end",
"def deal_cards\n if @deck.length != 0\n puts \"Dealt 3 more cards\"\n for i in 0...3\n r = rand([email protected])\n @cards_in_play.append(@deck[r])\n @deck.delete_at(r)\n end\n else\n puts \"There are no more cards in the deck!\"\n end\nend",
"def shuffle\r\n @cards.shuffle!\r\n end",
"def shuffle\n\t\[email protected]\n\tend",
"def deal_card\n @cards.pop\n end",
"def play_like_a_dummy\r\n # very brutal algorithm , always play the first card\r\n card = @cards_on_hand.pop\r\n return card\r\n end",
"def random\n card_dealt = @possible_cards.sample\n end",
"def shuffle\n\t\[email protected]!\n\tend",
"def random_card\n result = @deck.sample(1)\n @deck.delete result\n result.first\n end",
"def shuffle\n @cards.shuffle! \n end",
"def shuffle!\n cards.shuffle!\n end",
"def playcard\n @cards.shuffle.slice!(0,2)\n end",
"def deal()\n loop_size = Constant::CARD_COUNT / 6\n loop_size.times do\n @players.each do |player|\n break if @deck.cards.empty?\n player.hand += @deck.cards.pop(2)\n end\n end\n end",
"def deal_hand\n\t\thand = Array.new\n\t\t@num_cards.times do\n\t\t\tcard = get_card(get_random_number)\n\t\t\thand << card\n\t\t\tremove_card_from_deck(card)\n\t\tend\n\t\thand\n\tend",
"def shuffle\n @cards.shuffle!\n end",
"def deal_cards\n player.add_card(deck.deal_one)\n dealer.add_card(deck.deal_one)\n player.add_card(deck.deal_one)\n dealer.add_card(deck.deal_one)\n end",
"def show_card\n\t\[email protected]\n\tend",
"def shuffle!\n @deck.shuffle!\n end",
"def shuffle!\n @deck.shuffle!\n end",
"def deal_card!(cards)\n\nend",
"def deal(player)\n cards = []\n 26.times do \n cards << self.deck.shift\n end\n\n player.receive_cards(cards)\n end",
"def shuffle\n @cards.shuffle!\n end",
"def get_card_and_put_in_hand(which_hand)\n the_card = @deck_current.delete_at(rand(@deck_current.length))\n\n if which_hand === \"dealer\"\n @hand_dealer.push(the_card)\n\n elsif which_hand === \"player\"\n @hand_player.push(the_card)\n\n end\n \nend",
"def deal_cards\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\tend",
"def shuffle_list\n @cardList.shuffle!\n end",
"def hand_over_player \r\n puts \"Player getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @player_deck[@random_card] = random_card_val # to player\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@player_deck = #{@player_deck}\"\r\n\r\n end",
"def deal_card\n @deck.remove(:front)\n end",
"def shuffle!\n @cards.shuffle!\n self\n end",
"def deal_turn\n @pokerdeck.pop\n turn = @pokerdeck.pop\n @communal_cards << turn\n return turn\n end",
"def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end",
"def reshuffle\n discard.each do |modifier|\n deck.push modifier\n end\n @discard = []\n shuffle\n end",
"def shuffle_deck!\n @deck.shuffle\n @deck_position = @deck.each\n end",
"def deal\n @deck.shift\n end",
"def hand_deal\n hand = []\n 2.times do\n @card = self.random_card_deal\n hand.push(@card)\n end\n hand\n end",
"def deal_card\n card = rand(11) + 1\nend",
"def shuffle!\n self.cards.shuffle!\n self\n end",
"def shuffle\n @cards.shuffle!\n binding.pry\n end",
"def shuffle\n @fulldeck.shuffle!\n end",
"def deal_cards(old_deck, num_cards)\n hand = old_deck.sample(num_cards)\n new_deck = old_deck - hand\n return [hand, new_deck]\nend",
"def deal_card\n return rand(1..11)\nend",
"def shuffle(d)\n puts \"Reshuffling\"\n d.add_to_deck(@cards_showing)\n @cards_showing.clear\n @table_max.times {@cards_showing.push(d.draw_card)}\n @table_size = @cards_showing.length\n end",
"def build_deck\n CARD_SUITS.product(CARD_VALUES).shuffle\nend",
"def deal\n @view.print_dealing_message\n deal_player_cards(@player, 2)\n deal_player_cards(@dealer, 2)\n @dealer.make_last_card_facedown\n print_dealt_cards\n end",
"def deal_cards(player_hand, dealer_hand)\n\t# Everyone gets 2 cards\n\t2.times do\n\t\tdeal_card(player_hand)\n\t\tdeal_card(dealer_hand)\n\tend\nend",
"def draw_card\n #suit = Card::SUITS.sample\n #rank = Card::RANKS.sample\n #Card.new(suit: suit, rank: rank)\n @cards.pop\n end",
"def drawcard\n @deck.pop\n end",
"def draw_card\n cards_in_deck = @playing_deck.length - 1\n draw_num = rand(0..cards_in_deck)\n card = @playing_deck[draw_num]\n @playing_deck = @playing_deck - [@playing_deck[draw_num]]\n\n card\n end",
"def shuffle_cards\n n = self.cards.length - 1\n while n > 0\n i = rand(n -= 1 )\n temp = self.cards[i]\n self.cards[i] = self.cards[n]\n self.cards[n] = temp\n # can be written more elegantly like:\n # self.cards[i], self.cards[n] = self.cards[n], self.cards[i]\n end\n self.cards.each do |c|\n puts c.face\n end\n self\n end",
"def deal\n\n @first_card = @cards.shift\n\n return @first_card\n\n end",
"def shuffle\n @cards.shuffle!\n self\n end",
"def deal_card(deck,card_values)\n suites = deck.map {|k,v| k}\n suite_choice = suites[rand(0..3)]\n value = card_values[rand(0..12)]\n value_index = card_values.index(value)\n while deck[suite_choice].values_at(value_index).count(TAKEN_MARKER) == 1\n\n suite_choice = suites[rand(0..3)]\n value_index = card_values[rand(0..12)]\n end\n deck[suite_choice][value_index] = TAKEN_MARKER\n\n deck[suite_choice][value_index] = TAKEN_MARKER\nend",
"def deal(cards)\n @cards = cards\n end",
"def deal()\n card = self.cards.shift()\n raise \"Cannot deal more than 52 cards.\" unless card\n return card\n end",
"def test_shuffle\n new_deck = Deck.new\n @deck.shuffle\n assert_not_equal(new_deck.cards, @deck.cards)\n end",
"def deal_card\n rand(1...12)\nend",
"def take_card\n @deck.shift\n end",
"def deal_card\n @eg_users.each do |user|\n user << @pokerdeck.pop\n end\n @eg_users\n end",
"def deal\n @hand << @dealingmachine.deal_one_card << @dealingmachine.deal_one_card\n end",
"def deal(deck)\n unless players.size == 4\n raise NotImplementedError, \"only 4 players are supported\"\n end\n raise ArgumentError, \"deck has fewer than 43 cards\" if deck.size < 43\n\n deck = deck.shuffle\n\n merge(\n hands: Hamster::Hash[players.map {|p| [p, deck.shift(10)] }],\n kitty: deck.shift(3),\n )\n end",
"def shuffle\n @deck.sort_by{rand}\n end",
"def shuffle\n @deck.shuffle! # Contents of @deck will be permanently changed\n end",
"def hit(deck)\n rand_card = deck.sample # pulls a random card from the playing deck.\n deck.delete(rand_card)\nend",
"def deal_hand\n 3.times do \n @players.each do |player|\n player.hand.draw_card\n end\n end\n end",
"def deal_card(game_deck,player)\n card = game_deck.deck.pop\n ace_checker(card,player)\n player.hand.push(card)\n puts\"#{player.player_name} received #{card.identify}\"\n puts \"Current hand: #{player.display_hand}\"\n win_or_bust(player)\n hit_or_stay(player)\nend",
"def draw_card\n #change for chapel if no card to draw\n if ! (top_card = deckcards.find_by(library_position: 1))\n shuffle\n top_card = deckcards.find_by(library_position: 1)\n end\n top_card.status = \"hand\"\n top_card.library_position = nil\n top_card.save\n library.each do |library_member|\n library_member.library_position -=1\n library_member.save\n end\n top_card\n end",
"def deal_one\n cards.pop\n end",
"def create_deck\n @deck = CARDS.product(SUITS).shuffle\n end",
"def play_like_a_dummy\r\n # very brutal algorithm , always play the first card\r\n #card = @cards_on_hand.pop\r\n #p @cards_on_hand.size\r\n card = @cards_on_hand[0]\r\n if card\r\n # check if the played card take something\r\n #@table_cards\r\n \r\n #@log.debug \"Alg: cards on table #{@table_cards}\"\r\n list = @core_game.which_cards_pick(card, @table_cards)\r\n #p \"which cards pick: card #{card}, table #{@table_cards.join(\",\")}, list #{list.size}\"\r\n result = [card, list[0]].flatten\r\n return result\r\n end\r\n raise \"Error cards on hand #{@cards_on_hand.join(',')}\" \r\n end",
"def get_card\n all_cards = self.deck.cards\n correct_cards = self.guesses.where(correct: true).map { |guess| guess.card }\n (all_cards - correct_cards).shuffle.sample\n end",
"def shuffle!\n @cards = self.cards.sort_by { rand }\n end",
"def deal\n @events.handle(:deal) do\n 2.times do\n all_at_table.each {|p| p.hand << @deck.take_card }\n end\n end\n end",
"def random_card\n return @deck[rand(@deck.length)]\n end",
"def deal\n hit = bjdeck.draw\n self.player_hand << hit\n hit = bjdeck.draw\n self.computer_hand << hit\n end",
"def new_unshuffled\n card_codes = Card.unshuffled_card_codes\n @deck = Deck.create(card_codes: card_codes, player_id: 1, shuffled: false, )\n render json: {\n deck_id: @deck.id,\n shuffled: @deck.shuffled,\n remaining: @deck.card_codes.count\n }\n end",
"def deal\n # pack cards past the default 12 into the begining\n if @cards.length > 12\n # cards still in play past the standard 12 positions\n extra = @cards.last(@cards.length - 12).compact\n # move what can be moved into the standard 12 positions\n @cards = @cards.take(12).map! { |c| c || extra.pop }\n # hopefully extra is empty now, but maybe not\n @cards += extra\n end\n\n # sets is still valid as we haven't modified the combinaion of cards in play\n # do we need to expand the cards in play?\n if(@sets && @sets.none?)\n @cards += Array.new(3)\n end\n \n ## fill any gaps from the deck\n @cards.map! { |x| x || @deck.pop }\n\n # recompute sets\n #@sets = []\n @sets = IsASet.sets @cards.compact\n end",
"def deal_card(player)\n if !self.is_empty?\n player.hand << cards.pop\n else\n self.initialize(1)\n end\n end",
"def shuffle\n @cards.replace @cards.sort_by {rand}\n end",
"def player_deal_card\n player.add_card(deck.deal_card)\n player.add_card(deck.deal_card)\n player.show_hand\n end",
"def deal\n puts @deck.first\n @deck.shift\n end",
"def flush_deck (n = 1)\n deck = []\n n.times { deck.concat(generate_deck) }\n\n # swap two random cards (4 * deck.length) times\n (4 * deck.length).times do\n \n i, j = rand(deck.length), rand(deck.length)\n deck[i], deck[j] = deck[j], deck[i]\n end\n deck\nend"
] | [
"0.8009064",
"0.7723573",
"0.7551772",
"0.74831754",
"0.7421461",
"0.7408734",
"0.73830014",
"0.73792255",
"0.73752725",
"0.7366532",
"0.7351065",
"0.7266771",
"0.7245088",
"0.72328687",
"0.7229793",
"0.72269017",
"0.72122264",
"0.71954054",
"0.7176603",
"0.71583277",
"0.7141979",
"0.7140588",
"0.7112402",
"0.70796955",
"0.7053691",
"0.7039738",
"0.70359397",
"0.7027513",
"0.7012517",
"0.70060635",
"0.7001511",
"0.699539",
"0.69952214",
"0.6993744",
"0.69895875",
"0.69770247",
"0.69611794",
"0.6960504",
"0.6960504",
"0.69600564",
"0.6951723",
"0.6949533",
"0.69347286",
"0.69289273",
"0.69248223",
"0.69213974",
"0.6919603",
"0.69078606",
"0.690713",
"0.69001603",
"0.68928146",
"0.6879553",
"0.6879168",
"0.68775684",
"0.68684286",
"0.6866731",
"0.6860253",
"0.6853636",
"0.6850517",
"0.6845905",
"0.6843941",
"0.6842348",
"0.6836574",
"0.68307036",
"0.68258923",
"0.6821405",
"0.6805479",
"0.6805229",
"0.67962617",
"0.67956984",
"0.6779404",
"0.67777777",
"0.67773414",
"0.67705303",
"0.6761873",
"0.6747597",
"0.674464",
"0.67365074",
"0.67352664",
"0.6735239",
"0.67263645",
"0.67189264",
"0.6716983",
"0.6708316",
"0.6707144",
"0.6703494",
"0.6688574",
"0.6680671",
"0.6675574",
"0.6675553",
"0.66625977",
"0.665662",
"0.66523844",
"0.6651345",
"0.66489106",
"0.66448915",
"0.66406655",
"0.66289645",
"0.6625481",
"0.66109055"
] | 0.7416056 | 5 |
end of deal_dealer_card_method Dealing Player Cards | def deal_player_card(current_player)
card = @deck.delete_at(0)
if current_player == 1 then
@player1_hand << card
end
if current_player == 2 then
@player2_hand << card
end
if current_player == 3 then
@player3_hand << card
end
if current_player == 4 then
@player4_hand << card
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal_cards\n\t\t\tend",
"def deal_cards\n Print.heading('Dealing initial cards')\n deal_card_to_players\n dealer_card_to_dealer(false) #false to hide first dealer card\n deal_card_to_players\n dealer_card_to_dealer(true)\n end",
"def deal_cards\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\tend",
"def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end",
"def deal\n @view.print_dealing_message\n deal_player_cards(@player, 2)\n deal_player_cards(@dealer, 2)\n @dealer.make_last_card_facedown\n print_dealt_cards\n end",
"def deal\n self.player.receive_card hit \n self.dealer.receive_card hit \n self.player.receive_card hit \n self.dealer.receive_card hit \n end",
"def deal_cards\n player.add_card(deck.deal_one)\n dealer.add_card(deck.deal_one)\n player.add_card(deck.deal_one)\n dealer.add_card(deck.deal_one)\n end",
"def deal_card(game_deck,player)\n card = game_deck.deck.pop\n ace_checker(card,player)\n player.hand.push(card)\n puts\"#{player.player_name} received #{card.identify}\"\n puts \"Current hand: #{player.display_hand}\"\n win_or_bust(player)\n hit_or_stay(player)\nend",
"def player_deal_card\n player.add_card(deck.deal_card)\n player.add_card(deck.deal_card)\n player.show_hand\n end",
"def deal_card\r\n\t\tcards.pop\r\n\tend",
"def deal_dealer_card\n\n card = @deck.delete_at(0)\n @dealer_hand << card\n\n end",
"def deal_card!(cards)\n\nend",
"def deal_cards(player_hand, dealer_hand)\n\t# Everyone gets 2 cards\n\t2.times do\n\t\tdeal_card(player_hand)\n\t\tdeal_card(dealer_hand)\n\tend\nend",
"def deal_card\n @deck.pop\n end",
"def deal(cards)\n @cards = cards\n end",
"def deal()\n loop_size = Constant::CARD_COUNT / 6\n loop_size.times do\n @players.each do |player|\n break if @deck.cards.empty?\n player.hand += @deck.cards.pop(2)\n end\n end\n end",
"def deal_cards(cards)\n @players.each do |player|\n player.hand += @deck.cards.pop(cards)\n end\n end",
"def deal(player)\n cards = []\n 26.times do \n cards << self.deck.shift\n end\n\n player.receive_cards(cards)\n end",
"def deal_card\n @cards.pop\n end",
"def deal_card(player)\n if !self.is_empty?\n player.hand << cards.pop\n else\n self.initialize(1)\n end\n end",
"def deal\n end_round()\n shuffle()\n rounds_dealt = 0\n while rounds_dealt < @hand_size\n @players.each do | player |\n if card = @deck.draw()\n player.hand << card\n else\n return\n end\n end\n rounds_dealt += 1\n end\n end",
"def deal_card\n\t\tCard.deal_new(self)\n\t\tupdate_total\n\tend",
"def deal_card(hand)\n #hand is a string whose valid values are 'player_cards' and 'dealer_cards' \n\n if !['player_cards','dealer_cards'].include?(hand)\n raise \"Unknown hand #{hand}\"\n end \n\n #Check for an empty deck and reshuffle if necessary\n if (session['game_cards'].length == 0) \n\n session['game_cards'] = session['discard']\n session['game_cards'].shuffle!\n session['discard'] = []\n append_message(\"Dealer shuffled the cards.\") \n\n end \n\n #Move the card\n session[hand] << session['game_cards'].pop \n\n end",
"def dealCards\n @players.times do |p|\n c=p + 1\n tmp = []\n puts \"#{$dm} Dealing #{c} of #{cardsDealt} Cards for player #{c} of #{players}\" if $debug\n while c <= cardsNeeded do\n puts \"#{$dm} INSIDE While #{c} up to #{cardsNeeded}\" if $debug\n #d=c-1 # This is ugly... :( Needed to start at array 0 beginning\n tmp.push(@deckOfCards[@deckA[c-1]])\n c += @players\n end\n @playersCards[(p+1)] = tmp\n end\n end",
"def deal_hand\n 3.times do \n @players.each do |player|\n player.hand.draw_card\n end\n end\n end",
"def deal_card\n @deck.remove(:front)\n end",
"def deal\r\n @cards.shift\r\n end",
"def deal_card_to_player(player, card, show)\n if show\n puts \"Dealing to #{player.name}: #{card}\"\n elsif\n puts \"Dealing hidden card to #{player.name}\"\n end\n player.hands[0].add_card(card, false)\n end",
"def hand_over_dealer\r\n puts \"Dealer getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @dealer_deck[@random_card] = random_card_val # to dealer\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@dealer_deck = #{@dealer_deck}\"\r\n end",
"def deal\r\n @deck_of_cards.shift\r\n end",
"def deal\n hit = bjdeck.draw\n self.player_hand << hit\n hit = bjdeck.draw\n self.computer_hand << hit\n end",
"def deal\n self.deck.deal(player1)\n self.deck.deal(player2)\n end",
"def deal_hand(players)\n players.each do |player|\n player.clear_hand\n end\n\n 2.times do \n players.each do |player|\n deal_card(player)\n end\n end\n end",
"def deal_hand\n dealt = 0\n while dealt < @hand_size \n for player in @players\n player.cards.push(deal_answer_card)\n end \n dealt = dealt + 1\n end\n return @players\n \n end",
"def deal(card)\n\t\[email protected](card)\n\tend",
"def deal_card\n @eg_users.each do |user|\n user << @pokerdeck.pop\n end\n @eg_users\n end",
"def deal_player player_array, dealer_array\r\n card = deal player_array, dealer_array\r\n player_array << card\r\n return card\t\r\nend",
"def dealer_turn\n @dealer.show_hidden_card\n render_cards(@dealer.cards_in_hand, \"The Dealer shows his hidden card...\")\n hit_loop(@dealer) unless @player.bust?\n end",
"def deal\n @hand << @dealingmachine.deal_one_card << @dealingmachine.deal_one_card\n end",
"def deal_one_card\n player.hands.each do |hand|\n # return nil if hand.bust?\n deck.deal(hand.cards)\n puts \"#{player.name} got #{hand.cards[-1].output_card}\"\n end\n deck.deal(house.hand.cards)\n puts \"#{house.name} got #{house.hand.cards[-1].output_card}\"\n end",
"def dealInitialCards\n\t\[email protected]_index do |player, playerIndex|\n\t\t\t(0..1).each do |i|\n\t\t\t\tcard = @deck.getNextCard\n\t\t\t\tplayer.dealCard(card, 0, false)\n\t\t\t\tif playerIndex != DEALER_INDEX\n\t\t\t\t\[email protected] \"Player #{playerIndex} drew a #{card}\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def deal()\n card = self.cards.shift()\n raise \"Cannot deal more than 52 cards.\" unless card\n return card\n end",
"def deal\n # pack cards past the default 12 into the begining\n if @cards.length > 12\n # cards still in play past the standard 12 positions\n extra = @cards.last(@cards.length - 12).compact\n # move what can be moved into the standard 12 positions\n @cards = @cards.take(12).map! { |c| c || extra.pop }\n # hopefully extra is empty now, but maybe not\n @cards += extra\n end\n\n # sets is still valid as we haven't modified the combinaion of cards in play\n # do we need to expand the cards in play?\n if(@sets && @sets.none?)\n @cards += Array.new(3)\n end\n \n ## fill any gaps from the deck\n @cards.map! { |x| x || @deck.pop }\n\n # recompute sets\n #@sets = []\n @sets = IsASet.sets @cards.compact\n end",
"def deal\n @deckOfCards.shift\n end",
"def deal_card\n if @unshuffled_deck[-1] == nil\n @unshuffled_deck = @addhand\n @addhand = @emptyarray\n @x = 0\n end\n card = @unshuffled_deck[@x]\n @unshuffled_deck[@x] = nil\n @x+=1\n return card\n end",
"def deal_turn\n @pokerdeck.pop\n turn = @pokerdeck.pop\n @communal_cards << turn\n return turn\n end",
"def remaining_cards\r\n @deck_of_cards.each do |card|\r\n card.output_card\r\n end\r\n end",
"def deal_hand no_of_cards\r\n @card_list.deal_hand no_of_cards\r\n end",
"def deal_hand no_of_cards\n @card_list.deal_hand no_of_cards\n end",
"def deal_one\n cards.pop\n end",
"def deal\n deck = build_deck\n players = create_players\n hands = []\n puts \"Dealing cards...\"\n players.each do |player|\n hand = {\n player: player, card: deck.pop\n }\n hands << hand\n end\n return hands\n end",
"def deal_card\n if @cards.length > 0 then\n return @cards.slice!(0)\n else\n raise StandardError, \"No cards left in shoe; please use can_play\"\n end\n end",
"def deal\n @players.each{ |p| @shoe.trash(p.discard_hands) }\n @shoe.trash(@dealer.discard_hands)\n @shoe.reshuffle! if @shoe.cards_left < (@players.length+1) * 5\n first = true\n 2.times{\n @players.each{ |p| p.take(@shoe.hit) }\n if first\n @dealer.take(@shoe.silent_hit)\n else\n @dealer.take(@shoe.hit)\n end\n first = false\n }\n\n # In Counting Mode, it'd be nice to see everyone's hand so you can practice\n # doing the count yourself. In other modes, it just clutters things though.\n all_player_status if $Counting_Mode\n end",
"def deal_river\n @pokerdeck.pop\n river = @pokerdeck.pop\n @communal_cards << river\n return river\n end",
"def hit(deck)\n deck.deal_card(self)\n end",
"def deal_hand\n\t\thand = Array.new\n\t\t@num_cards.times do\n\t\t\tcard = get_card(get_random_number)\n\t\t\thand << card\n\t\t\tremove_card_from_deck(card)\n\t\tend\n\t\thand\n\tend",
"def deal\n @events.handle(:deal) do\n 2.times do\n all_at_table.each {|p| p.hand << @deck.take_card }\n end\n end\n end",
"def give_initial_cards\n # deal each player their initial cards\n @players.each do |player|\n player.receive(@deck.draw_card)\n player.receive(@deck.draw_card)\n end\n\n # give the dealer his two cards\n @dealer.receive(@deck.draw_card)\n @dealer.receive(@deck.draw_card)\n end",
"def get_card_and_put_in_hand(which_hand)\n the_card = @deck_current.delete_at(rand(@deck_current.length))\n\n if which_hand === \"dealer\"\n @hand_dealer.push(the_card)\n\n elsif which_hand === \"player\"\n @hand_player.push(the_card)\n\n end\n \nend",
"def deal_a_card(players_hand, deck_final)\n players_hand << deck_final.pop\n return players_hand, deck_final\nend",
"def play_dealer(hand, shoe, odds, upcard_result)\n case decide(hand)\n when :stand\n upcard_result[result(hand)] += odds\n when :hit\n CARDS.each do |card|\n next unless shoe.any?(card)\n card_odds = shoe.odds_of(card)\n\n hand.push(card)\n shoe.consume(card)\n\n play_dealer(hand, shoe, odds * card_odds , upcard_result)\n\n shoe.replace(card)\n hand.pop\n end\n else\n raise \"error, illegal hand action\"\n end\nend",
"def deal amount = 5, player_name = \"Player #{@@anonymous_player_count += 1}\"\n cards = amount.times.map do\n card = take(1).first\n unless card\n reset_unused!\n card = take(1).first\n end\n @inhand << card\n card\n end\n hand = CardDecks::Hand.new *cards, deck: self, name: player_name\n @hands << hand\n hand\n end",
"def deal(deck)\n unless players.size == 4\n raise NotImplementedError, \"only 4 players are supported\"\n end\n raise ArgumentError, \"deck has fewer than 43 cards\" if deck.size < 43\n\n deck = deck.shuffle\n\n merge(\n hands: Hamster::Hash[players.map {|p| [p, deck.shift(10)] }],\n kitty: deck.shift(3),\n )\n end",
"def dealSelf(deck)\n \t@hands[0].addCard(deck.removeCard)\n end",
"def deal_player\n @printer << \"Dealer deals you a #{session[:dealer].deal1(session[:player]).to_s}\"\n nil\n end",
"def deal\n\n @first_card = @cards.shift\n\n return @first_card\n\n end",
"def desk_cards\n desk = []\n self.public_deal.each do |i|\n desk.push(i)\n end\n self.hand_deal.each do |i|\n desk.push(i)\n end\n desk\n end",
"def deal_cards(deck)\n hands []\n players.each do |player|\n hand = {\n player: = player\n card: = deck.shift\n }\n hands << hand\n end\n hands\n end",
"def hand_over_player \r\n puts \"Player getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @player_deck[@random_card] = random_card_val # to player\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@player_deck = #{@player_deck}\"\r\n\r\n end",
"def dealer_hit\n dealer_hand << deck.cards.pop\n puts \"Dealer pulled a #{dealer_hand.last.face} of #{dealer_hand.last.suit}.\"\n end",
"def dealer_action\n # Dealer stands on soft 17's.\n while @dealer.hand.count < 17\n @dealer.take(@shoe.hit)\n end\n\n # The first card is drawn silently. This fixes the count.\n @shoe.adjust_count(@dealer.hand.cards[0])\n end",
"def deal_cards(cards)\n super\n @pipe.puts cards.join $/\n @pipe.puts\n @pipe.flush\n end",
"def deal_card\r\n random = rand(@playable_cards.size)\r\n @playable_cards.delete_at(random)\r\n end",
"def deal_card\n random = rand(@playable_cards.size)\n @playable_cards.delete_at(random)\n end",
"def deal_cards\n go_fish.deal_cards\n save!\n end",
"def deal(round)\n round_int = round.to_i\n case round_int\n when 0\n self.players.each do |player|\n move_card(get_random_card, player.location) # moves cards to users\n move_card(get_random_card, player.location)\n # player.in_hand = true\n player.save\n end\n addBlinds()\n when 1\n self.current_player = get_next_player(self.dealer)\n move_card(get_random_card, 0) #moves cards to table\n move_card(get_random_card, 0)\n move_card(get_random_card, 0)\n when 2\n self.current_player = get_next_player(self.dealer)\n move_card(get_random_card, 0)\n when 3\n self.current_player = get_next_player(self.dealer)\n move_card(get_random_card, 0)\n when 4\n get_winners()\n else\n p 'deal case > 4 or < 0, error'\n end\n\n self.players.each do |player|\n player.in_pot_current = 0\n player.save\n end\n if round_int > 0 && round_int < 4\n self.high_bet = 0\n self.high_better = self.current_player\n end\n self.save\n end",
"def deal_card(hand)\n\t# pick a random card and add to the hand\n\tindex = rand($card_deck.length)\n\thand << $card_deck[index]\n\n\t# remove the card from the deck\n\t$card_deck.delete_at(index)\nend",
"def action_useCard(pockerCard_id)\n\n if check_cardOwn(pockerCard_id) and check_currentTurn()#only owner can play card and current turn on\n if check_usableNumShape(pockerCard_id) #check bottom number and shape\n\n sourcePlayer_id = Game.last.players.by_user(current_user).id\n destPlayer_id = Game.last.players.dummy.id # destPlayer_id = 2 (dummy) \n\n action_moveCard(dest_id: destPlayer_id, source_id: sourcePlayer_id, card_id: pockerCard_id)\n\n #check effect of cards\n card_effect = Pockercard.find(pockerCard_id).effect\n action_addDummyList(pockerCard_id)\n action_putBottomCard(pockerCard_id)\n if card_effect == \"none\"\n action_endTurn(1) #move to next player=[\n elsif card_effect == \"back\" \n Game.last.toggle_order!\n action_endTurn(1) #skip next player\n elsif card_effect == \"jump\" \n action_endTurn(2) #move to next next player\n elsif card_effect == \"attack\"\n action_attackCard(pockerCard_id)\n action_endTurn(1) #move to next next player\n elsif card_effect == \"change\"\n action_setBottomCardStep()\n elsif card_effect == \"onemore\" \n else\n action_endTurn(1) #skip next player\n end\n check_winOrLose() \n end\n end\n\n\n\n end",
"def give_card_to_player(card,player)\n\t\t#player is another player object\n\t\t@cards[card].times do\n\t\t\tplayer.add_card(card)\n\t\tend\n\n\n\t\t#remove cards from hand if selected by another player\n\t\tself.remove_set_from_hand(card)\n\tend",
"def deal(num_cards)\n card_lst = @cards.slice!(0,num_cards)\n return (num_cards == 1 ? ((card_lst == nil) ? nil : card_lst[0]) : card_lst)\n end",
"def deal(c)\n if c.respond_to?(:valid) and c.valid\n @cards << c\n end\n end",
"def complete_player_hand(playerHand, dealerHand)\n \n loop do #Loop forever\n \n Console_Screen.cls #Clear the display area\n \n #Show the current state of the player and dealer's hands\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\n print \"Would you like another card? (Y/N) \"\n \n reply = STDIN.gets #Collect the player's answer\n reply.chop! #Remove any extra characters appended to the string\n\n #See if the player decided to ask for another card\n if reply =~ /y/i then\n #Call method responsible for getting a new card and add it to the \n #player's hand\n playerHand = playerHand + get_new_card\n end\n\n #See if the player has decided to stick with the current hand\n if reply =~ /n/i then\n break #Terminate the execution of the loop\n end\n \n if playerHand > 21 then\n break #Terminate the execution of the loop\n end\n \n end\n \n #Return the value of the player's hand\n return playerHand\n \n end",
"def play # << This method doesnt exist in any class - JH\n while @player.cards.count > 0 do # @player is going to be not defined out here - JH\n first_card = @player.cards.draw\n second_card = @player.cards.draw\n round = @bank - 10\n puts \"Your cards are #{first_card} and #{second_card}.\"\n\n third_card = @dealer.cards.draw\n fourth_card = @dealer.cards.draw\n puts \"Dealer's hand is #{third_card} and #{fourth_card}.\"\n if first_card + second_card == 21\n puts \"Outstanding! You win!\"\n elsif third_card + fourth_card == 21\n puts \"Dealer wins. You lose.\"\n elsif first_card + second_card > 21\n puts \"You lost kid.\"\n elsif third_card + fourth_card > 21\n puts \"House loses.\"\n #You don't need all these extra lines down here before your end -JH\n\n end\n end\nend",
"def deal_hand(player_index, player_cnt)\n if can_play(player_cnt - player_index) then\n return [ @cards.slice!(0), @cards.slice!(player_cnt - player_index - 1) ]\n else\n raise StandardError, \"Not enough cards left in shoe; please use can_play\"\n end\n end",
"def complete_player_hand(playerHand, dealerHand)\r\n\r\n loop do #Loop forever\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Show the current state of the player and dealer's hands\r\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\r\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\r\n print \"Would you like another card? (Y/N) \"\r\n\r\n reply = STDIN.gets #Collect the player's answer\r\n reply.chop! #Remove any extra characters appended to the string\r\n\r\n #See if the player decided to ask for another card\r\n if reply =~ /y/i then\r\n #Call method responsible for getting a new card and add it to the\r\n #player's hand\r\n playerHand = playerHand + get_new_card\r\n end\r\n\r\n #See if the player has decided to stick with the current hand\r\n if reply =~ /n/i then\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n if playerHand > 21 then\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n end\r\n\r\n #Return the value of the player's hand\r\n return playerHand\r\n\r\n end",
"def play (dealer, deck)\n print \"Dealer turns over his hole card and he has a \"\n dealer.hand[1].show_card \n sleep(2)\n dealer.show_hand\n sleep(1)\n\n while dealer.total_hand < 17\n puts \"Dealer to hit on #{dealer.total_hand}\"\n sleep(2)\n dealer.new_card(deck.draw_card)\n dealer.show_hand\n end\n\n \n\n\n puts \"\\nDealer total is #{dealer.total_hand}\" \n sleep(1)\n dealer.total_hand\n if dealer.total_hand > 21\n puts \"Dealer busts you win!!!\"\n return -1 \n end \n end",
"def use_card\n waiting_to_confirm_placement = true\n waiting_to_use_card = true\n invalid_usage = nil\n invalid_confirmation = nil\n remind_cannot_discard = nil\n \n while waiting_to_confirm_placement\n while waiting_to_use_card\n DisplayManager.prepare_ingame_display\n show_state\n puts \"Newest Card: #{@selected_card.to_s} #{'* you cannot discard this card' if @drew_from_discard}\" unless @selected_card.nil?\n puts \"You cannot discard this card because you drew it from the discard pile.\" if remind_cannot_discard\n remind_cannot_discard = false\n \n @card_to_replace = nil\n @card_to_discard = nil\n\n puts InputManager.input_options({ negative: 'Discard this Card', rack_positions: 'Switch With Card at Position' }, invalid_usage)\n invalid_usage = nil\n\n @placement_response = InputManager.get\n\n # If player chooses a location in their rack\n # Get ready to exchange those cards\n if InputManager::INPUTS[:rack_positions].include?(@placement_response)\n prep_place_card_in_rack(@placement_response)\n waiting_to_use_card = false\n\n # If player chooses to discard their card\n # get ready to discard their card\n # Disallow discard if card was drawn from the discard pile\n elsif InputManager.negative?(@placement_response)\n if @drew_from_discard\n remind_cannot_discard = true\n else\n prep_discard_drawn_card\n waiting_to_use_card = false\n end\n else\n invalid_usage = @placement_response\n end\n end\n\n DisplayManager.prepare_ingame_display\n show_state\n puts \"Newest Card: #{@selected_card.to_s}\"\n\n if @card_to_replace\n puts \"You want to exchange #{@card_to_replace.to_s} with #{@selected_card.to_s}.\"\n else\n puts \"You do not want to use #{@selected_card.to_s}.\"\n end\n\n puts \"You are discarding #{@card_to_discard.to_s}.\"\n\n puts InputManager.input_options({ affirmative: 'Save and Complete Turn', negative: 'Do Something Different' }, invalid_confirmation)\n invalid_confirmation = nil\n confirm_response = InputManager.get\n\n # If player confirms their decision\n # persist their decision\n if InputManager.affirmative?(confirm_response)\n save_and_discard(@placement_response)\n waiting_to_confirm_placement = false\n \n # If player changes their mind\n # allow them to choose how to use their card again \n elsif InputManager.negative?(confirm_response)\n waiting_to_use_card = true\n else\n invalid_confirmation = confirm_response\n end\n end\n end",
"def deal_flop\n @pokerdeck.pop\n flop = @pokerdeck.pop(3)\n @communal_cards = flop\n return flop\n end",
"def deal_cards(deck, playing_cards)\n return if deck.length == 0\n\n #initializing deck.\n if playing_cards.length == 0\n for count in 0...12\n card = deck.delete_at(rand(deck.length))\n card.set_id($card_count)\n $card_count += 1\n playing_cards.push(card)\n end\n return\n end\n\n if (valid_table(playing_cards)).length == 0\n #continually adds cards until there is a set or there are no more cards.\n while ((valid_table(playing_cards)).length == 0) && deck.length > 0\n #print(\"\\n Empty: #{(valid_table(playingCards)).length == 0} \\n\")\n for count in 0...3\n card = deck.delete_at(rand(deck.length))\n card.set_id($card_count)\n $card_count += 1\n playing_cards.push(card)\n end\n end\n elsif playing_cards.length < 12\n # Adds cards if there is a set but less than 12 playing cards.\n for count in 0...3\n card = deck.delete_at(rand(deck.length))\n card.set_id($card_count)\n $card_count += 1\n playing_cards.push(card)\n end\n\n end\n\nend",
"def deal\n @deck.shift\n end",
"def throw_card_player(player)\n puts \"lanzar\"+player.id\n puts \"Carta del triunfo: Numero: #{@trump_card.number}, Tipo: #{@trump_card.type}\"\n puts \"Turno para el jugador: #{player.name}\"\n puts \"-------------------------------------Sus Cartas-----------------------------------------\"\n player.cards.each do |card|\n print card.id\n print ' || '\n end\n card_valid = true\n while card_valid\n card_valid = get_card(player, card_valid)\n end\n end",
"def deal_initial_hands\n INITIAL_CARDS.times do\n @players_in_round.each do |player|\n @deck.deal_to player\n end\n end\n end",
"def play_dealer_hand(dealerHand)\r\n\r\n loop do #Loop forever\r\n\r\n #If the value of the dealer's hand is less than 17 then give the\r\n #dealer another card\r\n if dealerHand < 17 then\r\n #Call method responsible for getting a new card and add it to the\r\n #dealer's hand\r\n dealerHand = dealerHand + get_new_card\r\n else\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n end\r\n\r\n #Return the value of the dealer's hand\r\n return dealerHand\r\n\r\n end",
"def drawcard\n @deck.pop\n end",
"def return_cards\n @hand = []\n end",
"def deal_and_check\n get_bet\n deal_hands\n blackjack_winner\n check_winner_else_do(\"player_loop\")\n end",
"def deal_cards (num_cards, deck)\n dealt_cards = []\n num_cards.times {dealt_cards << deck.pop}\n dealt_cards\nend",
"def play_game\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Assign the player and dealer an initial starting card\r\n playerHand = get_new_card\r\n dealerHand = get_new_card\r\n\r\n #Call the method responsible for dealing new cards to the player\r\n playerHand = complete_player_hand(playerHand, dealerHand)\r\n\r\n #If the player has not gone bust, call the method responsible for managing\r\n #dealer's hand\r\n if playerHand <= 21 then\r\n dealerHand = play_dealer_hand(dealerHand)\r\n end\r\n\r\n #call the method responsible for determining the results of the game\r\n determine_winner(playerHand, dealerHand)\r\n\r\n end",
"def get_cards(deck)\n\n end",
"def card\n\t @dance_card\n\tend"
] | [
"0.8399073",
"0.8333051",
"0.8246254",
"0.816907",
"0.813615",
"0.8123897",
"0.8027193",
"0.79399896",
"0.7863337",
"0.7849715",
"0.7823181",
"0.7813507",
"0.7798923",
"0.7755101",
"0.775068",
"0.77466846",
"0.7744429",
"0.7708262",
"0.76856196",
"0.76445395",
"0.764265",
"0.7599846",
"0.7567284",
"0.75407404",
"0.75138193",
"0.74357516",
"0.7429596",
"0.7407163",
"0.73446906",
"0.73239344",
"0.73109925",
"0.7309566",
"0.72601974",
"0.7256452",
"0.72508466",
"0.72372735",
"0.7170432",
"0.71617514",
"0.7153812",
"0.71385986",
"0.7135878",
"0.7124609",
"0.71170264",
"0.70837694",
"0.7077105",
"0.70638406",
"0.7061395",
"0.70610356",
"0.7048413",
"0.7034707",
"0.70338076",
"0.70257473",
"0.7024621",
"0.70242625",
"0.7011263",
"0.69963694",
"0.6955371",
"0.6938871",
"0.6933267",
"0.6926965",
"0.6925295",
"0.6923647",
"0.6911277",
"0.6908956",
"0.6878429",
"0.68781537",
"0.6868923",
"0.68687147",
"0.6865604",
"0.68518525",
"0.68491554",
"0.68183357",
"0.6801363",
"0.6797519",
"0.6789967",
"0.67801934",
"0.6767798",
"0.6767661",
"0.67460936",
"0.67375463",
"0.67173845",
"0.670099",
"0.6698956",
"0.66977507",
"0.6692456",
"0.6686768",
"0.6683725",
"0.66813654",
"0.66712624",
"0.66678727",
"0.66532403",
"0.66487235",
"0.6643305",
"0.6642684",
"0.66384506",
"0.66325337",
"0.6599687",
"0.6597779",
"0.6579762",
"0.6570765"
] | 0.74183035 | 27 |
end of dealing player card Displaying Dealer Cards (Return the only yhe 2cd card unless (the arg passed was equal to "dealer")) | def display_dealer_card(dealer="")
card = []
if dealer == "dealer"
card = @dealer_hand # Fetch all of dealers cards
else
card = ["blank card"]
card << @dealer_hand.fetch(1) # Fetch dealers 2cd card
end
return card
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal_cards\n Print.heading('Dealing initial cards')\n deal_card_to_players\n dealer_card_to_dealer(false) #false to hide first dealer card\n deal_card_to_players\n dealer_card_to_dealer(true)\n end",
"def dealer_turn\n @dealer.show_hidden_card\n render_cards(@dealer.cards_in_hand, \"The Dealer shows his hidden card...\")\n hit_loop(@dealer) unless @player.bust?\n end",
"def deal\n @view.print_dealing_message\n deal_player_cards(@player, 2)\n deal_player_cards(@dealer, 2)\n @dealer.make_last_card_facedown\n print_dealt_cards\n end",
"def show_dealer_cards(dlr_first_hand, game_status)\n c1_pic = dlr_first_hand[:show_card_1][:picture]\n c1_name = dlr_first_hand[:show_card_1][:name]\n c2_pic = dlr_first_hand[:show_card_2][:picture]\n c2_name = dlr_first_hand[:show_card_2][:name]\n hits = dlr_first_hand[:hit_cards].map { |n| n[:name] }\n dealer_hand_total = game_status[:dealer_hand]\n\n if game_status[:show_all_hands] == false\n c2_pic = '? '\n dealer_hand_total = \"unknown\"\n end\n\n prompt \"***** Dealers Cards *****\"\n prompt \"Here are the dealers first 2 cards\"\n prompt \"First card => #{c1_name}\"\n prompt \"Second card => Dealer to know, you to find out..\"\n prompt \"+-----+ +-----+\"\n prompt \"| | | |\"\n prompt \"| #{c1_pic} | | #{c2_pic} |\"\n prompt \"| | | |\"\n prompt \"+-----+ +-----+\"\n prompt \" \"\n prompt \"Dealers 'hit cards' #{hits}\"\n prompt \"The dealers total card count is #{dealer_hand_total}\"\nend",
"def show_dealer_cards(dlr_first_hand, game_status)\n c1_pic = dlr_first_hand[:show_card_one][:picture]\n c1_name = dlr_first_hand[:show_card_one][:name]\n c2_pic = dlr_first_hand[:show_card_two][:picture]\n c2_name = dlr_first_hand[:show_card_two][:name]\n hits = dlr_first_hand[:hit_cards].map { |n| n[:name] }\n dealer_hand_total = game_status[:dealer_hand]\n\n if game_status[:show_all_hands] == false\n c2_pic = '? '\n dealer_hand_total = \"unknown\"\n end\n\n prompt \"***** Dealers Cards *****\"\n prompt \"Here are the dealers first two cards\"\n prompt \"First card => #{c1_name}\"\n prompt \"Second card => Dealer to know, you to find out..\"\n prompt \"+-----+ +-----+\"\n prompt \"| | | |\"\n prompt \"| #{c1_pic} | | #{c2_pic} |\"\n prompt \"| | | |\"\n prompt \"+-----+ +-----+\"\n prompt \" \"\n prompt \"Dealers 'hit cards' #{hits}\"\n prompt \"The dealers total card count is #{dealer_hand_total}\"\nend",
"def out_of_cards\n display(\"---Dealer ran out of cards this round!---\\n\\n\")\n end",
"def deal_cards\n\t\t\tend",
"def display_card(player_hand,dealer_hand,index,dealer_turn)\n\t#puts \"debug: display_card\"\n\n\tif index >= dealer_hand.length\n\t\t# we know that we have gone past the length of the hand, so print blanks\n\t\tplayer_card = ' '\n\telse\n\t\tplayer_card = player_hand[index]\n\tend\n\n\t# To print the dealer hand, we know that if dealer_turn is false, don't dislay the second card\n\tif !dealer_turn\n\t\tif index == 1\n\t\t\tdealer_card = '--'\n\t\telsif index == 0\n\t\t\tdealer_card = dealer_hand[0]\n\t\telse\n\t\t\tdealer_card = ' '\n\t\tend\n\telse \n\t\t# We know it is the dealer turn\n\t\tif index >= dealer_hand.length\n\t\t\t# we know that we have gone past the length of the hand, so print blanks\n\t\t\tdealer_card = ' '\n\t\telse\n\t\t\tdealer_card = dealer_card[index]\n\t\tend\n\tend\n\n\tputs (\" \" * (13 - player_card.length)) + player_card + (\" \" * (17 - dealer_card.length)) + dealer_card\nend",
"def remaining_cards\r\n @deck_of_cards.each do |card|\r\n card.output_card\r\n end\r\n end",
"def print_deal_cards\n puts \"-----------\"\n puts \"Cards Dealt\"\n puts \"-----------\"\n end",
"def show_cards2(dck, dlr, plyr, plyr_points, dlr_points)\n system \"clear\"\n puts \"=========================\"\n prompt \"Dealer has...#{dlr_points}\"\n dlr.each do |card|\n prompt \" \" + dck[card][:name] + ' ' + dck[card][:value].to_s\n end\n puts\n prompt \"Player has...#{plyr_points}\"\n plyr.each do |card|\n prompt \" \" + dck[card][:name] + ' ' + dck[card][:value].to_s\n end\nend",
"def display_board_screen(hidden_dealer)\n display_hand_dealer = []\n display_hand_player = []\n\n if hidden_dealer\n dealer_card = [generate_ASCII_card(@hand_dealer[0]),generate_ASCII_card(@hidden_card)]\n display_hand_dealer = concatenate_cards(dealer_card)\n\n else\n dealer_card = []\n @hand_dealer.each do |card|\n dealer_card.push(generate_ASCII_card(card))\n end\n display_hand_dealer = concatenate_cards(dealer_card)\n end\n \n\n @hand_player.each do |card|\n player_card = []\n @hand_player.each do |card|\n player_card.push(generate_ASCII_card(card))\n end\n display_hand_player = concatenate_cards(player_card)\n end\n\n system \"clear\" or system \"cls\"\n puts \"Dealer:\"\n puts display_hand_dealer\n puts\n puts \"Player:\"\n puts display_hand_player\n puts\n puts \"Do you want to (h)it or (s)tay?\"\nend",
"def decide(dealer)\n @dealer_card = dealer.visible_card[:value]\n @card_total = hands.last.total\n if values.include?(Ace)\n if (values.include?(2) || values.include?(3)) && [5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(2) || values.include?(3)\n :hit\n elsif (values.include?(4) || values.include?(5)) && [4,5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(4) || values.include?(5)\n :hit\n elsif values.include?(6) && [3,4,5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(6)\n :hit\n elsif values.include?(7) && [2,7,8].include?(@dealer_card)\n elsif values.include?(7) && [3,4,5,6].include?(@dealer_card)\n :doubledown #stand\n elsif values.include?(7)\n :hit\n elsif values.include?(8) || values.include?(9)\n :stand\n elsif values.first == values.last\n :split\n end\n elsif values.first == values.last\n if [2,3,7].include?(values.first) && @dealer_card <= 7\n :split\n elsif [2,3,7].include?(values.first)\n :hit\n elsif values.first == 4 && [5,6].include?(@dealer_card)\n :split\n elsif values.first == 4\n :hit\n elsif values.first == 5 && #dealer_card <= 9\n :doubledown #hit\n elsif values.first == 5 \n :hit\n elsif values.first == 6 && @dealer_card <= 6\n :split\n elsif values.first == 6\n :hit\n elsif values.first == 8\n :split\n elsif values.first == 9 && [2,3,4,5,6,8,9].include?(@dealer_card)\n :split\n elsif values.first == 9\n :stand\n elsif values.first.to_i == 10\n :split\n end\n else\n if (5...8).include?(@card_total)\n :hit\n elsif @card_total == 9 && (3...6).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 9\n :hit\n elsif @card_total == 10 && (2...9).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 10\n :hit\n elsif @card_total == 11 && ((2...10)+[Jack, Queen, King]).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 11\n :hit\n elsif @card_total == 12 && [4,5,6].include?(@dealer_card)\n :stand\n elsif @card_total == 12\n :hit\n elsif (13...16).include?(@card_total) && @dealear_card <= 6\n :stand\n elsif (13...16).include?(@card_total) && (@dealer_card >= 7 || @dealer_card.is_a?(Ace))\n :hit\n elsif @card_total == 17\n :stand\n end\n end\n end",
"def first_deal\n @printer = []\n if session[:player].chips == 0\n @printer << \"#{session[:player].gender}. #{session[:player].name} is all in!\"\n session[:player].make_reckless\n end \n deal_dealer\n de_total\n 2.times {deal_player}\n pl_total\n if session[:player].hand_total == 21\n @action = :end\n run_dealer\n else\n @action = :choice\n end\n chat\n end",
"def deal_cards\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\t\[email protected]_card(@deck.deal_card)\r\n\tend",
"def deal_dealer_card\n\n card = @deck.delete_at(0)\n @dealer_hand << card\n\n end",
"def player_deal_card\n player.add_card(deck.deal_card)\n player.add_card(deck.deal_card)\n player.show_hand\n end",
"def display_cards (cards, name)\n puts \"#{name} has been dealt:\"\n cards.each do |card|\n puts \"#{card.value} of #{card.suit}\"\n end \n end",
"def deal_dealer\n @printer << \"Dealer draws a #{session[:dealer].deal1(session[:dealer]).to_s}\"\n nil\n end",
"def dealer_hit\n dealer_hand << deck.cards.pop\n puts \"Dealer pulled a #{dealer_hand.last.face} of #{dealer_hand.last.suit}.\"\n end",
"def deal_player\n @printer << \"Dealer deals you a #{session[:dealer].deal1(session[:player]).to_s}\"\n nil\n end",
"def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end",
"def deal_cards(player_hand, dealer_hand)\n\t# Everyone gets 2 cards\n\t2.times do\n\t\tdeal_card(player_hand)\n\t\tdeal_card(dealer_hand)\n\tend\nend",
"def play (dealer, deck)\n print \"Dealer turns over his hole card and he has a \"\n dealer.hand[1].show_card \n sleep(2)\n dealer.show_hand\n sleep(1)\n\n while dealer.total_hand < 17\n puts \"Dealer to hit on #{dealer.total_hand}\"\n sleep(2)\n dealer.new_card(deck.draw_card)\n dealer.show_hand\n end\n\n \n\n\n puts \"\\nDealer total is #{dealer.total_hand}\" \n sleep(1)\n dealer.total_hand\n if dealer.total_hand > 21\n puts \"Dealer busts you win!!!\"\n return -1 \n end \n end",
"def dealer_turn(dealer_cards, deck)\n loop do\n break if hand_value(dealer_cards) >= DEALER_THRESHOLD\n hit(dealer_cards, deck)\n end\n puts \"\\nThe dealer has: #{cards_string(dealer_cards)}.\\n\\\ntotal: #{hand_value(dealer_cards)}\"\n puts \"The dealer busted!\" if busted?(dealer_cards)\nend",
"def reveal_final_hand\n linebreak('-')\n @players.each{ |p| puts p; linebreak; }\n puts \"Dealer reveals #{@dealer.hand}. #{@dealer.hand.count}!\"\n puts \"Dealer BUSTED!\" if @dealer.hand.busted?\n linebreak\n end",
"def deal_card\r\n\t\tcards.pop\r\n\tend",
"def deal_card_to_player(player, card, show)\n if show\n puts \"Dealing to #{player.name}: #{card}\"\n elsif\n puts \"Dealing hidden card to #{player.name}\"\n end\n player.hands[0].add_card(card, false)\n end",
"def full_dance_card\n\t\tif @card.length > 5\n\t\t\tputs \"Your dance card is full! You have to dance with #{@card[0]} before you can add #{@card[-1]}\"\n\t\t\[email protected]_at(-1)\n\t\tend\n\t\t@card\n\tend",
"def deal_cards\n player.add_card(deck.deal_one)\n dealer.add_card(deck.deal_one)\n player.add_card(deck.deal_one)\n dealer.add_card(deck.deal_one)\n end",
"def display_hands(player_hand, dealer_hand, hide_dealer=false)\n system('clear') || system('cls')\n puts \">>>>>> Twenty-One <<<<<<\"\n prompt(\"Dealer's Hand:\")\n print_cards(dealer_hand, hide_dealer)\n puts\n prompt(\"Player's Hand:\")\n print_cards(player_hand)\nend",
"def use_card\n waiting_to_confirm_placement = true\n waiting_to_use_card = true\n invalid_usage = nil\n invalid_confirmation = nil\n remind_cannot_discard = nil\n \n while waiting_to_confirm_placement\n while waiting_to_use_card\n DisplayManager.prepare_ingame_display\n show_state\n puts \"Newest Card: #{@selected_card.to_s} #{'* you cannot discard this card' if @drew_from_discard}\" unless @selected_card.nil?\n puts \"You cannot discard this card because you drew it from the discard pile.\" if remind_cannot_discard\n remind_cannot_discard = false\n \n @card_to_replace = nil\n @card_to_discard = nil\n\n puts InputManager.input_options({ negative: 'Discard this Card', rack_positions: 'Switch With Card at Position' }, invalid_usage)\n invalid_usage = nil\n\n @placement_response = InputManager.get\n\n # If player chooses a location in their rack\n # Get ready to exchange those cards\n if InputManager::INPUTS[:rack_positions].include?(@placement_response)\n prep_place_card_in_rack(@placement_response)\n waiting_to_use_card = false\n\n # If player chooses to discard their card\n # get ready to discard their card\n # Disallow discard if card was drawn from the discard pile\n elsif InputManager.negative?(@placement_response)\n if @drew_from_discard\n remind_cannot_discard = true\n else\n prep_discard_drawn_card\n waiting_to_use_card = false\n end\n else\n invalid_usage = @placement_response\n end\n end\n\n DisplayManager.prepare_ingame_display\n show_state\n puts \"Newest Card: #{@selected_card.to_s}\"\n\n if @card_to_replace\n puts \"You want to exchange #{@card_to_replace.to_s} with #{@selected_card.to_s}.\"\n else\n puts \"You do not want to use #{@selected_card.to_s}.\"\n end\n\n puts \"You are discarding #{@card_to_discard.to_s}.\"\n\n puts InputManager.input_options({ affirmative: 'Save and Complete Turn', negative: 'Do Something Different' }, invalid_confirmation)\n invalid_confirmation = nil\n confirm_response = InputManager.get\n\n # If player confirms their decision\n # persist their decision\n if InputManager.affirmative?(confirm_response)\n save_and_discard(@placement_response)\n waiting_to_confirm_placement = false\n \n # If player changes their mind\n # allow them to choose how to use their card again \n elsif InputManager.negative?(confirm_response)\n waiting_to_use_card = true\n else\n invalid_confirmation = confirm_response\n end\n end\n end",
"def deal_card(game_deck,player)\n card = game_deck.deck.pop\n ace_checker(card,player)\n player.hand.push(card)\n puts\"#{player.player_name} received #{card.identify}\"\n puts \"Current hand: #{player.display_hand}\"\n win_or_bust(player)\n hit_or_stay(player)\nend",
"def deal_card\n @cards.pop\n end",
"def dealer_decision\n while hand_value(@dealer_hand) < 17 \n puts \"\\nDealer hits!\"\n hit(@dealer_hand)\n show_hands()\n end\n end",
"def deal_card\n @deck.pop\n end",
"def first_hand\n @player_hand = deck.cards.pop(2)\n @dealer_hand = deck.cards.pop(2)\n puts \"House will now deal you two cards..Press any key.\"\n #Dumb speech, might take out.\n %x(say 'to lose')\n gets\n #Shows the first two cards you receive\n puts \"Dealer showing #{dealer_hand[0].face} of #{dealer_hand[0].suit}.\"\n puts \"You have a #{player_hand[0].face} of #{player_hand[0].suit} and a #{player_hand[1].face} of #{player_hand[1].suit}. \"\n two_aces\n if dealer_score == 21\n puts \"Well you lost, I got #{dealer_score} already. That was quick huh.\"\n dealer_win\n play_again\n elsif player1_score == 21\n puts \"You win. with a total of #{player1_score}. I didn't even get to deal :(\"\n player_win\n play_again\n else\n play\n end\n end",
"def dealer_method\n\tdcard1 = deck.sample\n\tdcard2 = deck.sample\n\tputs \"The dealer's cards are #{dcard1} and #{dcard2}. His total is currently #{dealer_total}\"\n\t\tif dealer_total > 21\n\t\t\tputs \"Dealer Busts\"\n\t\telsif dealer_total < 17 \n\t\t\tputs \"Dealer needs to draw\"\n\t\t\tdealer_draw\n\t\telse dealer_total >= 17 && dealer_total <= 21 \n\t\t\tcompare_method \n\t\tend \nend",
"def hand_over_dealer\r\n puts \"Dealer getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @dealer_deck[@random_card] = random_card_val # to dealer\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@dealer_deck = #{@dealer_deck}\"\r\n end",
"def deal_one\n cards.pop\n end",
"def print_dealers_partial_hand(dealer)\n dealer_hand = dealer.get_hand\n cards = dealer_hand.get_hand_cards\n print \"Dealer: Hand: \"\n print \"#{cards[0].symbol}#{cards[0].suit} \"\n print \"XX\"\n puts \"\"\n end",
"def desk_cards\n desk = []\n self.public_deal.each do |i|\n desk.push(i)\n end\n self.hand_deal.each do |i|\n desk.push(i)\n end\n desk\n end",
"def draw_card\n @dwanted.each_with_index{|w,i|\n if w && (@dpile[i][-1] > (@land[i][-1]||0))\n @dpile[i].pop\n return [S.index(i)].pack(\"C\")\n end\n }\n @deckcount-=1\n \"n\"\n end",
"def show_cards(players_hand, dealers_hand)\n puts \"Dealers cards:\"\n dealers_hand.each do |card|\n puts \".---. \"\n puts \"|#{card[0]} | \"\n puts \"| #{card[1]} | \"\n puts \"| #{card[0]}| \"\n puts \".---. \"\n puts\n end\n puts \"Players cards:\"\n players_hand.each do |card|\n puts \".---. \"\n puts \"|#{card[0]} | \"\n puts \"| #{card[1]} | \"\n puts \"| #{card[0]}| \"\n puts \".---. \"\n puts\n end\nend",
"def play_as_dealer(deck)\r\n if value < 17\r\n hit!(deck)\r\n play_as_dealer(deck)\r\n else\r\n puts \"Dealer Total is #{value}\"\r\n end\r\n end",
"def get_decision(dealer_show_card)\n dealer_show_value = dealer_show_card.value\n @strategy.play(@hand, dealer_show_value)\n end",
"def dealer_action\n # Dealer stands on soft 17's.\n while @dealer.hand.count < 17\n @dealer.take(@shoe.hit)\n end\n\n # The first card is drawn silently. This fixes the count.\n @shoe.adjust_count(@dealer.hand.cards[0])\n end",
"def deal_one_card\n player.hands.each do |hand|\n # return nil if hand.bust?\n deck.deal(hand.cards)\n puts \"#{player.name} got #{hand.cards[-1].output_card}\"\n end\n deck.deal(house.hand.cards)\n puts \"#{house.name} got #{house.hand.cards[-1].output_card}\"\n end",
"def complete_player_hand(playerHand, dealerHand)\n \n loop do #Loop forever\n \n Console_Screen.cls #Clear the display area\n \n #Show the current state of the player and dealer's hands\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\n print \"Would you like another card? (Y/N) \"\n \n reply = STDIN.gets #Collect the player's answer\n reply.chop! #Remove any extra characters appended to the string\n\n #See if the player decided to ask for another card\n if reply =~ /y/i then\n #Call method responsible for getting a new card and add it to the \n #player's hand\n playerHand = playerHand + get_new_card\n end\n\n #See if the player has decided to stick with the current hand\n if reply =~ /n/i then\n break #Terminate the execution of the loop\n end\n \n if playerHand > 21 then\n break #Terminate the execution of the loop\n end\n \n end\n \n #Return the value of the player's hand\n return playerHand\n \n end",
"def complete_player_hand(playerHand, dealerHand)\r\n\r\n loop do #Loop forever\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Show the current state of the player and dealer's hands\r\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\r\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\r\n print \"Would you like another card? (Y/N) \"\r\n\r\n reply = STDIN.gets #Collect the player's answer\r\n reply.chop! #Remove any extra characters appended to the string\r\n\r\n #See if the player decided to ask for another card\r\n if reply =~ /y/i then\r\n #Call method responsible for getting a new card and add it to the\r\n #player's hand\r\n playerHand = playerHand + get_new_card\r\n end\r\n\r\n #See if the player has decided to stick with the current hand\r\n if reply =~ /n/i then\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n if playerHand > 21 then\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n end\r\n\r\n #Return the value of the player's hand\r\n return playerHand\r\n\r\n end",
"def list_hand_cards(card_array) \n user_choice = \"\"\n while user_choice != \"⬅️ BACK ⬅️\" && user_choice != \"🗑 DELETE READING 🗑\" do\n user_choice = prompt.select(\"🔮 #{self.user.name}, Select a card to see more details.\") do |menu|\n card_emoji_string = \"🂠\"\n crystal_ball_emoji_string = \"🔮\"\n card_array.map do |handCard|\n string=\" 🂠 TAROT #{crystal_ball_emoji_string} 🂠 \"\n menu.choice \" 🂠 TAROT #{crystal_ball_emoji_string} 🂠 \", -> {reading_card(handCard.card, card_array,string); \" 🂠 TAROT #{crystal_ball_emoji_string} 🂠 \"}\n card_emoji_string += \"🂠\"\n crystal_ball_emoji_string += \" 🔮\"\n end\n menu.choice \"🗑 DELETE READING 🗑\", -> {self.delete_reading(card_array); \"🗑 DELETE READING 🗑\"}\n menu.choice \"⬅️ BACK ⬅️\", -> {self.main_menu;\"⬅️ BACK ⬅️\"}\n end \n end \n end",
"def show_hand\n if @hand.point == \"Blackjack\" # the dealer should reveal both cards when it has blackjack\n @hand.turn_all_cards_up\n puts \" #{@hand.to_s} Blackjack\\n\" \n else\n puts \" #{@hand.to_s}\\n\"\n end\n end",
"def deal_card!(cards)\n\nend",
"def opening_deal(dealer, player, deck, hidden_card_var)\n sleep(1)\n clear_display\n deal_hidden_card!(dealer, deck, hidden_card_var)\n display_dealer_hand(dealer, hidden_card_var, false)\n add_5_lines_to_display\n puts \"\\n\"\n sleep(1)\n hit!(player, deck)\n display_player_hand(player)\n sleep(1)\n hit!(dealer, deck)\n clear_display\n display_dealer_hand(dealer, hidden_card_var, false)\n display_player_hand(player)\n sleep(1)\n hit!(player, deck)\n clear_display\n display_dealer_hand(dealer, hidden_card_var, false)\n display_player_hand(player)\nend",
"def receiveInfo( playerIndex, card )\n if(playerIndex == -1 && card == nil)\n puts \"No one could answer. \"\n else\n # since the computer player doesn't make bad guess, \n # we delete the card just showed by other players from the lists of potential right cards.\n if( card.type == :person )\n i = 0\n while( i < @listOfAllSuspects.length )\n if(@listOfAllSuspects[i].value == card.value)\n @listOfAllSuspects.delete_at(i)\n else\n i = i + 1\n end\n end\n elsif( card.type == :place )\n i = 0\n while( i < @listOfAllLocations.length )\n if(@listOfAllLocations[i] == card)\n @listOfAllLocations.delete_at(i)\n else\n i = i + 1\n end\n end\n elsif( card.type == :weapon )\n i = 0\n while( i < @listOfAllWeapons.length )\n if(@listOfAllWeapons[i] == card)\n @listOfAllWeapons.delete_at(i)\n else\n i = i + 1\n end\n end\n end\n end #if\n end",
"def deal_card\n if @cards.length > 0 then\n return @cards.slice!(0)\n else\n raise StandardError, \"No cards left in shoe; please use can_play\"\n end\n end",
"def display_hands(cards_of_player, cards_of_dealer, player_name, hidden)\n system 'clear'\n print \"#{player_name}:\\t\"\n cards_of_player.each {|card| print card.join + ' '}\n puts \"\\t\\tPoints: #{calculate_points(cards_of_player)}\"\n puts\n print \"Dealer:\\t\"\n cards_of_dealer.each_with_index do |v, index|\n if !hidden || index == 0\n print v.join + ' '\n else\n print \"??\" + ' '\n end\n end\n\n print \"\\t\\tPoints: #{calculate_points(cards_of_dealer)}\" if !hidden\n puts\n puts\nend",
"def deal(num_cards)\n card_lst = @cards.slice!(0,num_cards)\n return (num_cards == 1 ? ((card_lst == nil) ? nil : card_lst[0]) : card_lst)\n end",
"def turn_dealer\n display_board_screen(false)\n hand_total = calculate_hand_total_value(@hand_dealer)\n\n if check_if_over_21(hand_total)\n return \"over21\"\n elsif check_if_over_17(hand_total)\n return \"over17\"\n else\n get_card_and_put_in_hand(\"dealer\")\n sleep 1\n turn_dealer\n end\nend",
"def dealer\n if @hand\n (@hand.dealer == @player1) ? @player2 : @player1\n else\n # coin toss\n (rand(2) == 0) @player1 : @player2\n end\n end",
"def display_both_hands(users_name, dealers_hand, users_hand, initial_deal_bool, cards_n_values)\n display_players_hand(\"Dealer\", dealers_hand, initial_deal_bool, cards_n_values)\n puts\n display_players_hand(users_name, users_hand, false, cards_n_values)\n puts\n\n return nil\nend",
"def deal\n self.player.receive_card hit \n self.dealer.receive_card hit \n self.player.receive_card hit \n self.dealer.receive_card hit \n end",
"def blackjack_or_bust?(player_or_dealer)\n if player_or_dealer.total == BLACKJACK_AMOUNT\n if player_or_dealer.is_a?(Dealer)\n puts \"Sorry, dealer hit BlackJack. #{player.name} loses.\"\n play_again?\n else\n puts \"Congrats. #{player.name} hit BlackJack. #{player.name} wins!\"\n play_again?\n end\n\n elsif player_or_dealer.is_busted?\n if player_or_dealer.is_a?(Player)\n puts \"Sorry, #{player.name} busted. #{player.name} loses.\"\n play_again?\n else\n puts \"Congrats, dealer busted. #{player.name} wins!\"\n play_again?\n end\n end\n\n end",
"def take_turn(player)\n p player.render_hand\n #render their hand\n p \"Which cards do you want to discard? (first, second..etc) i.e. '1,2' If none, reply 'none'\"\n discarded_cards = gets.chomp\n indices = parse(discarded_cards)\n discard(indices, player)\n #promt for how many new cards? => quantity\n #rerender the hand\n #promt for fold?\n #prompt them for a bet.. show their current bet\n end",
"def card\n false\n end",
"def dealer_turn\r\n dealer.reveal_hand\r\n if dealer.total_for_hand < 17\r\n loop do\r\n dealer.add_to_hand(deck)\r\n break if dealer.total_for_hand > 16\r\n end\r\n puts \"#{dealer.name} has #{dealer.total_for_hand}\"\r\n end\r\n end",
"def display_compare_cards(player_cards, dealer_cards)\n # compare cards!\n puts \"==============\"\n prompt \"Dealer has #{dealer_cards}, for a total of: #{total(dealer_cards)}\"\n prompt \"Player has #{player_cards}, for a total of: #{total(player_cards)}\"\n puts \"==============\"\nend",
"def deal\r\n @cards.shift\r\n end",
"def blackjack_or_bust?(player_or_dealer)\n if player_or_dealer.total == BLACKJACK_AMOUNT # exit condition\n if player_or_dealer.is_a?(Dealer)\n # If it's a dealer, put this message:\n puts \"Sorry, dealer hit blackjack. #{player.name} loses.\"\n # you still have access to the name getter as long as you are in the game\n # engine, and the game engine is the Blackjack class that called this method\n else # it it hits else it's a Player:\n puts \"Congratulations, you hit blackjack! #{player.name} wins!\"\n end\n play_again? # exit program?\n elsif player_or_dealer.is_busted? # exit condition\n if player_or_dealer.is_a?(Dealer)\n puts \"Congratulations, dealer busted. #{player.name} wins!\"\n else\n puts \"Sorry, #{player.name} busted. #{player.name} loses.\"\n end\n play_again? # exit program?\n end\n end",
"def check_blackjack\n\t\tif @player.blackjack?\n\t\t\tputs \"Blackjack!\"\n\t\t\treturn\n\t\telsif @dealer.blackjack?\n\t\t\tputs \"Dealer blackjack!\"\n\t\t\treturn\n\t\tend\n\tend",
"def deal_card\n @eg_users.each do |user|\n user << @pokerdeck.pop\n end\n @eg_users\n end",
"def show_top_card\n self.discard(draw)\n end",
"def show_hand\r\n\t\tputs \"#{name} was dealt:\"\r\n\t\thand.cards.each{|c| c.display_card}\r\n\t\tputs \"Hand value: #{hand.hand_value.to_s}\\n\\n\"\r\n\tend",
"def play_dealer_hand(dealerHand)\r\n\r\n loop do #Loop forever\r\n\r\n #If the value of the dealer's hand is less than 17 then give the\r\n #dealer another card\r\n if dealerHand < 17 then\r\n #Call method responsible for getting a new card and add it to the\r\n #dealer's hand\r\n dealerHand = dealerHand + get_new_card\r\n else\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n end\r\n\r\n #Return the value of the dealer's hand\r\n return dealerHand\r\n\r\n end",
"def card\n\t @dance_card\n\tend",
"def deal\r\n @deck_of_cards.shift\r\n end",
"def de_total\n @printer << \"Dealer has #{session[:dealer].hand_total}\" if !session[:dealer].blackjack?\n @printer << \"Dealer busts!\" if session[:dealer].bust? \n if session[:dealer].blackjack?\n @printer << \"Dealer has BlackJack.\"\n session[:player].make_unlucky\n end\n nil\n end",
"def play_dealer_hand(dealerHand)\n \n loop do #Loop forever\n \n #If the value of the dealer's hand is less than 17 then give the \n #dealer another card\n if dealerHand < 17 then\n #Call method responsible for getting a new card and add it to the \n #dealer's hand\n dealerHand = dealerHand + get_new_card\n else\n break #Terminate the execution of the loop\n end\n \n end\n \n #Return the value of the dealer's hand\n return dealerHand\n \n end",
"def play_dealer(hand, shoe, odds, upcard_result)\n case decide(hand)\n when :stand\n upcard_result[result(hand)] += odds\n when :hit\n CARDS.each do |card|\n next unless shoe.any?(card)\n card_odds = shoe.odds_of(card)\n\n hand.push(card)\n shoe.consume(card)\n\n play_dealer(hand, shoe, odds * card_odds , upcard_result)\n\n shoe.replace(card)\n hand.pop\n end\n else\n raise \"error, illegal hand action\"\n end\nend",
"def dealInitialCards\n\t\[email protected]_index do |player, playerIndex|\n\t\t\t(0..1).each do |i|\n\t\t\t\tcard = @deck.getNextCard\n\t\t\t\tplayer.dealCard(card, 0, false)\n\t\t\t\tif playerIndex != DEALER_INDEX\n\t\t\t\t\[email protected] \"Player #{playerIndex} drew a #{card}\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def deal_card(hand)\n #hand is a string whose valid values are 'player_cards' and 'dealer_cards' \n\n if !['player_cards','dealer_cards'].include?(hand)\n raise \"Unknown hand #{hand}\"\n end \n\n #Check for an empty deck and reshuffle if necessary\n if (session['game_cards'].length == 0) \n\n session['game_cards'] = session['discard']\n session['game_cards'].shuffle!\n session['discard'] = []\n append_message(\"Dealer shuffled the cards.\") \n\n end \n\n #Move the card\n session[hand] << session['game_cards'].pop \n\n end",
"def deal_turn\n @pokerdeck.pop\n turn = @pokerdeck.pop\n @communal_cards << turn\n return turn\n end",
"def deal_flop\n @pokerdeck.pop\n flop = @pokerdeck.pop(3)\n @communal_cards = flop\n return flop\n end",
"def deal_card\n @deck.remove(:front)\n end",
"def dealCards\n @players.times do |p|\n c=p + 1\n tmp = []\n puts \"#{$dm} Dealing #{c} of #{cardsDealt} Cards for player #{c} of #{players}\" if $debug\n while c <= cardsNeeded do\n puts \"#{$dm} INSIDE While #{c} up to #{cardsNeeded}\" if $debug\n #d=c-1 # This is ugly... :( Needed to start at array 0 beginning\n tmp.push(@deckOfCards[@deckA[c-1]])\n c += @players\n end\n @playersCards[(p+1)] = tmp\n end\n end",
"def dealer_draw\n if dealer_hand_value < 16\n until dealer_hand_value >=16\n dealer_hit\n end\n puts \"The dealer has drawn.\"\n else\n puts \"The dealer stays.\"\n end\n end",
"def auto_dealer(deck)\n if score < 16\n hit!(deck)\n auto_dealer(deck)\n end\n end",
"def show_visible_card\n puts \"*******************************************************************\"\n puts \" Dealer's visible card is: \" + num_to_rank(@hand[1])\n puts \"*******************************************************************\"\n end",
"def draw_final_card\n @card3 = Card.draw(@card1.id, @card2.id)\n puts \"The next card is the #{@card3}\"\n\n # player wins if card is Joker\n raise Rules::Win::Joker if @card3.joker?\n end",
"def start_game\n @deck_current = @deck_default\n @hand_dealer = []\n @hand_player = []\n get_card_and_put_in_hand(\"dealer\")\n get_card_and_put_in_hand(\"dealer\")\n get_card_and_put_in_hand(\"player\")\n get_card_and_put_in_hand(\"player\")\n\n display_board_screen(true)\n\n result_player = turn_player\n\n if result_player === \"over\"\n puts \"player is over 21, press enter to continue\"\n gets\n bet_attribution(\"lose\")\n display_betting_screen(false)\n elsif result_player === \"stay\"\n result_dealer = turn_dealer\n end\n \n if result_dealer === \"over21\"\n puts \"Dealer over 21, press enter to continue\"\n gets\n bet_attribution(\"win\")\n display_betting_screen(false)\n elsif result_dealer === \"over17\"\n final_result = check_who_wins(calculate_hand_total_value(@hand_dealer), calculate_hand_total_value(@hand_player))\n if final_result === \"draw\"\n puts \"It's a draw, press enter to continue\"\n bet_attribution(\"push\")\n elsif final_result === \"player\"\n puts \"Player wins, press enter to continue\"\n bet_attribution(\"win\")\n elsif final_result === \"dealer\"\n puts \"Dealer wins, press enter to continue\"\n bet_attribution(\"lose\")\n end\n \n gets\n display_betting_screen(false)\n end\n\nend",
"def dealer_draw\n\tdcard_new = deck.sample \n\tdealer_total_new = dealer_total + dcard_new \n\tputs \"Dealer drew a #{dcard_new}. His new total is #{dealer_total_new}.\"\n\t\tif dealer_total_new > 21 \n\t\t\tputs \"Dealer Busts\"\n\t\telsif dealer total < 21\n\t\t\tdealer_draw\n\t\telse dealer_total_new >= 17 && dealer_total_new <= 21 \n\t\t\tcompare_method\n\t\tend\nend",
"def dealer_blackjack_possible?(exposed_dealer_card)\n [\n CardGame::Card::NAME_VALUES[:ten], \n CardGame::Card::NAME_VALUES[:jack], \n CardGame::Card::NAME_VALUES[:queen], \n CardGame::Card::NAME_VALUES[:king],\n CardGame::Card::NAME_VALUES[:ace]\n ].include?(exposed_dealer_card.name)\n end",
"def dealer_game(player)\n @is_first_cards = false\n puts \"Your score is #{player.score}!\"\n puts \"Dealer's turn:\"\n @dealer.update_score\n self.print_scores(player)\n while @dealer.score. < 17\n sleep(1)\n @dealer.open_new_card\n puts \"Your score: #{player.score}; Dealer score: #{@dealer.score}\"\n end\n get_winner(player)\n end",
"def do_hit_or_stay(player_or_dealer)\n if player_or_dealer.class == Dealer #dealer's turn\n while !is_bust_or_blackjack?(player_or_dealer)\n sleep(2) #makes output seem more human\n if player_or_dealer.get_hand_score < 17\n puts \"Dealer score is #{player_or_dealer.get_hand_score}. Dealer must hit.\"\n player_or_dealer.hit(deck)\n player_or_dealer.display_hand\n else\n puts \"Dealer score is #{player_or_dealer.get_hand_score}. Dealer must stay.\"\n player_or_dealer.display_hand\n break\n end\n end\n else #player's turn\n while !is_bust_or_blackjack?(player_or_dealer)\n response = prompt_hit_or_stay\n if response == \"1\"\n player_or_dealer.hit(deck)\n player_or_dealer.display_hand\n else\n puts \"You stay.\" \n player_or_dealer.display_hand\n break\n end\n end\n end\n end",
"def play\n self.check\n while(\"unfinished\" == @status)\n if(@value < 17)\n @hand << @dealingmachine.deal_one_card\n end\n self.check\n end\n \n # output the dealer's hand\n i = 0\n dealerhand = \"dealer's hand contains: \"\n while i < @hand.length\n dealerhand += num_to_rank(@hand[i]) + \" \"\n i += 1\n end\n puts \"*******************************************************\"\n puts dealerhand\n if 50 == @value\n puts \"value: BLACKJACK\"\n elsif @value <= 21\n puts \"value: #{@value}\"\n else\n puts \"value: #{@value} Busted!!\"\n end\n puts \"*******************************************************\"\n end",
"def play_like_a_dummy\r\n # very brutal algorithm , always play the first card\r\n card = @cards_on_hand.pop\r\n return card\r\n end",
"def printDealerGetCards\n puts \"And now the dealer will reveal his cards...\"\n pressKeyToContinue\n printGameState(false)\nend",
"def play # << This method doesnt exist in any class - JH\n while @player.cards.count > 0 do # @player is going to be not defined out here - JH\n first_card = @player.cards.draw\n second_card = @player.cards.draw\n round = @bank - 10\n puts \"Your cards are #{first_card} and #{second_card}.\"\n\n third_card = @dealer.cards.draw\n fourth_card = @dealer.cards.draw\n puts \"Dealer's hand is #{third_card} and #{fourth_card}.\"\n if first_card + second_card == 21\n puts \"Outstanding! You win!\"\n elsif third_card + fourth_card == 21\n puts \"Dealer wins. You lose.\"\n elsif first_card + second_card > 21\n puts \"You lost kid.\"\n elsif third_card + fourth_card > 21\n puts \"House loses.\"\n #You don't need all these extra lines down here before your end -JH\n\n end\n end\nend",
"def show_hand(player_ID)\n card_ID = 0\n print_with_pause(\"Here are your cards...\".colorize(:red))\n print_with_pause(\"Choose wisely.\".colorize(:red))\n waits(2)\n puts `clear`\n while card_ID < @players[player_ID].cards.length\n line_number = card_ID + 1\n puts (line_number.to_s + \". \" + @players[player_ID].cards[card_ID].value).colorize(:black).on_white\n card_ID = card_ID + 1\n end\n end",
"def purchase_card(turn)\n own_money = turn.player.money\n keep_repeating = true\n while keep_repeating == true do\n keep_repeating = false \n @@cli.say \"Now it is time to purchase a card; you have <%= color('#{own_money}', BOLD) %> money.\"\n # Create a hash for the cards in the town\n town_cards = Hash[ @mk.town.deck.map {|e| [\"#{e[1]} x #{e[0].attribute[:name]} (#{e[0].attribute[:cost]})\", [:establishment, e[0], e[0].attribute[:cost]]]} ]\n card_name_list = town_cards.sort_by { |key, val| val[1].attribute[:from_roll] }.to_h\n # add the landmarks\n card_name_list.merge!(Hash[ turn.player.unbuilt_landmarks.map {|l| [\"#{l.name} (#{l.cost})\", [:landmark, l, l.cost]]} ])\n @@cli.choose do |menu|\n menu.prompt = \"Which card to do you want to buy? \"\n menu.choices(*card_name_list.keys) do |chosen|\n @@cli.say \"You have chosen <%= color('#{chosen}', BOLD) %>. \"\n if own_money < card_name_list[chosen][2]\n @@cli.say \"You can't afford that! It costs #{card_name_list[chosen][2]} but you only have #{own_money}\"\n keep_repeating = true\n else\n process_purchase_of_card(turn, card_name_list[chosen])\n end\n end\n menu.choice(:none, {:text => \"NOTHING TO ME, AH VIENNA\"}) { @@cli.say \"OK, you have chosen to not purchase any card.\"}\n menu.choice(:databank) { databank_menu; keep_repeating = true}\n end\n end\n end"
] | [
"0.7787684",
"0.7362852",
"0.72794175",
"0.7216833",
"0.7202246",
"0.70144176",
"0.6866023",
"0.683401",
"0.67140174",
"0.66904163",
"0.6627497",
"0.66192585",
"0.66174513",
"0.65922326",
"0.6584375",
"0.65674686",
"0.6558081",
"0.6553478",
"0.652138",
"0.65158176",
"0.65063006",
"0.6483635",
"0.64688945",
"0.64502263",
"0.6429671",
"0.6425197",
"0.6411372",
"0.6400162",
"0.63865227",
"0.6385306",
"0.6381643",
"0.63751405",
"0.6353978",
"0.63120055",
"0.63065416",
"0.6294606",
"0.62912685",
"0.62910855",
"0.62908965",
"0.62875706",
"0.62618667",
"0.62570703",
"0.6253154",
"0.62351453",
"0.6228618",
"0.6222451",
"0.62158096",
"0.62102103",
"0.6209223",
"0.6202914",
"0.6201284",
"0.61975986",
"0.61953753",
"0.6182935",
"0.6182059",
"0.6177481",
"0.61653996",
"0.6160219",
"0.6151717",
"0.61451095",
"0.613997",
"0.61386514",
"0.61308247",
"0.612243",
"0.61186016",
"0.6110603",
"0.60976785",
"0.6092627",
"0.6086871",
"0.6079618",
"0.6079401",
"0.60785544",
"0.60776067",
"0.6056775",
"0.6053381",
"0.6037664",
"0.6037038",
"0.6035355",
"0.6031449",
"0.60238284",
"0.60222876",
"0.60165864",
"0.60143256",
"0.6011919",
"0.5991901",
"0.59901077",
"0.5987643",
"0.5984352",
"0.5962689",
"0.5958058",
"0.5951263",
"0.59432817",
"0.59299207",
"0.5926095",
"0.59240746",
"0.5922499",
"0.5909155",
"0.59043336",
"0.59016997",
"0.5901262"
] | 0.78210616 | 0 |
end of displaying player card resets player's hand | def reset_players_hand(current_player)
if current_player == 1 then
@player1_hand = []
end
if current_player == 2 then
@player2_hand = []
end
if current_player == 3 then
@player3_hand = []
end
if current_player == 4 then
@player4_hand = []
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_hand\n @hand_cards.clear\n @points = 0\n end",
"def reset_hand\n @hand_played = []\n end",
"def reset!\n @hands.each(&:discard!)\n @cards += @used\n @used = []\n end",
"def reset_hand\n @hand = []\n end",
"def hand_finished\n\t\t\t\tloop do\n\t\t\t\t\tline = socket_get\n\t\t\t\t\tinterpret_acpc_matchstate(line) # update cards and things\n\t\t\t\t\tif line == '#END_HAND'\n\t\t\t\t\t\t# now the hand has really finished\n\t\t\t\t\t\tsuper\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def clear_hand!\n\t\t# restore balances and bet\n\t\t# values in case user forgets\n\t\t# to call win, lose, push etc.\n\t\[email protected] += @bet\n\t\t@bet = 0\n\n\t\t@standing = false\n\t\t@is_split = false\n\t\t@hand = Array.new\n\tend",
"def gameover\n op_hand.clear\n end",
"def clear_hands\n @player_hand = []\n @dealer_hand = []\n end",
"def reset\n @player_status = \"in\" \n @hands = [] \n @hands_status = [] \n @bets = [] \n @values = [] \n @cur = 0 \n end",
"def play\n @last_card_played = @my_hand.pick_random\n set_last_card_played @last_card_played\n end",
"def update_initial_data\n user.hand.cards = []\n dealer.hand.cards = []\n user.hand.total_score = 0\n dealer.hand.total_score = 0\n self.stop = false\n end",
"def return_cards\n @hand = []\n end",
"def discard\n player.hand.first\n end",
"def deal\n\t\tcase @phase\n\t\t\twhen 0 then new_hand\n\t\t\twhen 1 then flop\n\t\t\twhen 2 then turn_or_river\n\t\t\twhen 3 then turn_or_river\n\t\tend\n\t\t@current_position = @button\n\t\t@round_history = []\n\t\t@players_at_start_of_hand = @hands.size - @max_can_win.size\n\t\t@minimum_bet = big_blind\n\t\tif @phase == 0\n\t\t\tmove_position(3, true)\n\t\telse\n\t\t\tmove_position(1)\n\t\tend\n\t\t@phase += 1\n\t\t@moves_taken = 0\n\tend",
"def show_hands_final\n player.show_hand\n dealer.show_hand_for_turn\n end",
"def discard_card(player)\n if player.player_hand.size == 0\n nil\n else\n rand_index = rand(5)\n rand_index += 1\n Keepem.new(Image.new(\"keepem.gif\"), rand_index)\n end\n end",
"def restock_hand!\n return if Bot::CONFIG.hand_size == unplayed_cards.count\n (Bot::CONFIG.hand_size - unplayed_cards.count).times do\n add_player_card PlayerCard.create(answer: game.available_answers.sample)\n end\n end",
"def deal_hand\n 3.times do \n @players.each do |player|\n player.hand.draw_card\n end\n end\n end",
"def finish_round\n @hands = []\n end",
"def reset\n @hand = []\n @value = nil\n @status = \"unfinished\"\n end",
"def continue_game\n\t\thandle_no_set\n\t\tuntil @is_end\n\t\t\tshow_progress\n\t\t\tshow_hand\n\t\t\tuser_input = get_user_cards\n\t\t\tupdate user_input\n\t\t\thandle_no_set\n\t\tend\n\tend",
"def reset_self\r\n @hole_cards = []\r\n @folded = false\r\n @bet = 0\r\n end",
"def play_like_a_dummy\r\n # very brutal algorithm , always play the first card\r\n card = @cards_on_hand.pop\r\n return card\r\n end",
"def clear\n\t\t@save_time = 0.0\n\t\t@top_card = 0\n\t\t@number_of_hint = 0\n\t\t@number_of_correct = 0\n\t\t@number_of_wrong= 0\n\t\t@deck = []\n\t\t@hand = []\n\t\t@username = \"\"\n\t\t@total_hint=0\n\t\t@is_end=false\n\tend",
"def deal_card(player)\n if !self.is_empty?\n player.hand << cards.pop\n else\n self.initialize(1)\n end\n end",
"def show_hands_initial\n player.show_hand\n dealer.show_hand\n end",
"def hands\n dealer.hand = []\n player.hand = []\n end",
"def reset!\n self.cards = CARDS.dup\n end",
"def hand_over_player \r\n puts \"Player getting 1 random card...\"\r\n @random_card = @game_deck.random_card # def random card\r\n random_card_val = @game_deck.deck[@random_card]\r\n @player_deck[@random_card] = random_card_val # to player\r\n @game_deck.deck.delete(@random_card) \r\n puts \"@player_deck = #{@player_deck}\"\r\n\r\n end",
"def player_deal_card\n player.add_card(deck.deal_card)\n player.add_card(deck.deal_card)\n player.show_hand\n end",
"def deal_initial_hands\n INITIAL_CARDS.times do\n @players_in_round.each do |player|\n @deck.deal_to player\n end\n end\n end",
"def dealSelf(deck)\n \t@hands[0].addCard(deck.removeCard)\n end",
"def fold_hand\n @active_players[0].folded = true\n pot_adjustment\n @active_players[0].current_bet = 0\n @active_players[0].acted = false\n system 'clear'\n puts 'You have folded your hand.'\n sleep(3)\nend",
"def show_hand(player_ID)\n card_ID = 0\n print_with_pause(\"Here are your cards...\".colorize(:red))\n print_with_pause(\"Choose wisely.\".colorize(:red))\n waits(2)\n puts `clear`\n while card_ID < @players[player_ID].cards.length\n line_number = card_ID + 1\n puts (line_number.to_s + \". \" + @players[player_ID].cards[card_ID].value).colorize(:black).on_white\n card_ID = card_ID + 1\n end\n end",
"def reset!\n @cards = load_cards\n end",
"def reset\n @shoe = Shoe.new(7)\n player.hand.clear;\n player.bust = false\n dealer.hand.clear;\n dealer.bust = false\n play\n end",
"def deal_hand(players)\n players.each do |player|\n player.clear_hand\n end\n\n 2.times do \n players.each do |player|\n deal_card(player)\n end\n end\n end",
"def complete_player_hand(playerHand, dealerHand)\r\n\r\n loop do #Loop forever\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Show the current state of the player and dealer's hands\r\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\r\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\r\n print \"Would you like another card? (Y/N) \"\r\n\r\n reply = STDIN.gets #Collect the player's answer\r\n reply.chop! #Remove any extra characters appended to the string\r\n\r\n #See if the player decided to ask for another card\r\n if reply =~ /y/i then\r\n #Call method responsible for getting a new card and add it to the\r\n #player's hand\r\n playerHand = playerHand + get_new_card\r\n end\r\n\r\n #See if the player has decided to stick with the current hand\r\n if reply =~ /n/i then\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n if playerHand > 21 then\r\n break #Terminate the execution of the loop\r\n end\r\n\r\n end\r\n\r\n #Return the value of the player's hand\r\n return playerHand\r\n\r\n end",
"def reset\n\t\t@hand = Array.new\n\t\t@total = 0\n\tend",
"def deal_player_card(current_player)\n\n card = @deck.delete_at(0)\n if current_player == 1 then\n @player1_hand << card\n end\n if current_player == 2 then\n @player2_hand << card\n end\n if current_player == 3 then\n @player3_hand << card\n end\n if current_player == 4 then\n @player4_hand << card\n end\n\n end",
"def display_final_hands(player_hand, computer_hand, player_name)\n sleep(1)\n system 'clear'\n\n puts \"\\n*** Computer's Hand -- Value: #{calculate_hand_value(computer_hand)} ***\"\n computer_hand.each_key do |card|\n puts \"#{card}\"\n end\n\n show_player_hand(player_hand, player_name)\n puts \"\"\nend",
"def deal_cards\n Print.heading('Dealing initial cards')\n deal_card_to_players\n dealer_card_to_dealer(false) #false to hide first dealer card\n deal_card_to_players\n dealer_card_to_dealer(true)\n end",
"def deal()\n loop_size = Constant::CARD_COUNT / 6\n loop_size.times do\n @players.each do |player|\n break if @deck.cards.empty?\n player.hand += @deck.cards.pop(2)\n end\n end\n end",
"def deal_card(game_deck,player)\n card = game_deck.deck.pop\n ace_checker(card,player)\n player.hand.push(card)\n puts\"#{player.player_name} received #{card.identify}\"\n puts \"Current hand: #{player.display_hand}\"\n win_or_bust(player)\n hit_or_stay(player)\nend",
"def complete_player_hand(playerHand, dealerHand)\n \n loop do #Loop forever\n \n Console_Screen.cls #Clear the display area\n \n #Show the current state of the player and dealer's hands\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\n print \"Would you like another card? (Y/N) \"\n \n reply = STDIN.gets #Collect the player's answer\n reply.chop! #Remove any extra characters appended to the string\n\n #See if the player decided to ask for another card\n if reply =~ /y/i then\n #Call method responsible for getting a new card and add it to the \n #player's hand\n playerHand = playerHand + get_new_card\n end\n\n #See if the player has decided to stick with the current hand\n if reply =~ /n/i then\n break #Terminate the execution of the loop\n end\n \n if playerHand > 21 then\n break #Terminate the execution of the loop\n end\n \n end\n \n #Return the value of the player's hand\n return playerHand\n \n end",
"def update_hands\n\t\tplayers.each do |player|\n\t\t\tnext if player.folded?\n\t\t\tdiscard_idx = player.get_discard\n\t\t\tplayer.update_hand(discard_idx, @deck)\n\t\tend\n\tend",
"def drawCard\n\t\t@hand = @hand.push(@deck.pop)\n\tend",
"def current_player_effect\n # Retire 1 au nombre de cartes a piocher du joueur en cours\n if @current_player.draw_card_count >= 1\n @current_player.draw_card_count -= 1\n end\n # Enleve une carte mixed de la main du joueur en cours\n @current_player.cards.delete_at(@current_player.cards.index(\"lock_down\"))\n end",
"def deal_card\n @deck.remove(:front)\n end",
"def hand_of_poker\n players_in_hand = @players.dup\n @players.each {|player| deal(player, 5)}\n remaining_players = betting_round(players_in_hand)\n unless remaining_players.count == 1\n exchange_cards\n remaining_players = betting_round(remaining_players)\n unless remaining_players.count == 1\n remaining_players = compare_hands(remaining_players)\n end\n end\n winner = remaining_players.first\n puts \"#{winner.name} wins!\"\n print \"\\n\\n\\n\"\n pay_out(winner)\n reset_deck\n end",
"def play_game\n\n Console_Screen.cls #Clear the display area\n \n #Assist the player and dealer an initial starting card\n playerHand = get_new_card\n dealerHand = get_new_card\n \n #Call the method responsible for dealing new cards to the player\n playerHand = complete_player_hand(playerHand, dealerHand)\n \n #If the player has not gone bust, call the method responsible for managing\n #dealer's hand\n if playerHand <= 21 then\n dealerHand = play_dealer_hand(dealerHand)\n end\n\n #call the method responsible for determining the results of the game\n determine_winner(playerHand, dealerHand)\n\n end",
"def dealer_play_hand\n while @dealer.hand.active?\n take_turn(@dealer, @dealer.hand)\n end\n end",
"def poker_hand\n # If a hand hasn't been played yet, display a welcome message with some key information.\n welcome_message(@player_positions) unless @hand_played\n\n # Do the players want to start a new hand?\n new_hand_check\n\n # If they do, let's play!\n if @game_running\n\n # Resets and reinitializes everything required for the start of a new hand.\n reset_values\n set_blinds\n init_deck\n deal_hole_cards\n system 'clear'\n puts 'Dealing the cards..'\n sleep(2)\n\n # Starts a loop that checks to see whether a winner needs to be determined.\n while @active_players.length > 1 && @stage_of_play < 4\n # Each time it loops back to this point means we've progressed to the next stage of play and cards need to be dealt.\n deal_community_cards\n\n # If a player has gone all in in the last round of betting, sets the maximum amount that player can win this hand.\n @active_players.map do |player|\n next unless player.chip_stack == 0 && player.max_pot != 0\n\n player.max_winnings = (@pot_size - @committed) + (player.max_pot * @active_players.length)\n player.max_pot = 0\n end\n\n # Resets the committed value AFTER max_winnings has been calculated.\n @committed = 0 if @stage_of_play.positive?\n\n loop do\n # If a player has folded they are no longer active in this hand.\n @active_players.map do |player|\n @active_players.delete(player) if player.folded == true\n end\n\n # If a player is still active and has no chips left, they are all in.\n @all_in_players = 0\n @active_players.map do |player|\n @all_in_players += 1 if player.chip_stack.zero?\n end\n\n # If the player is all in and there are players who aren't all in rotate the array to check the next player.\n if @active_players[0].acted == true && @active_players[0].chip_stack.zero? && @active_players.length != @all_in_players\n @active_players.rotate!\n\n # If the player was the initial raiser and they haven't had their bet raised, move onto the next stage of the hand.\n elsif (@active_players[0].acted == true) && (@active_players[0].current_bet == @table_current_bet)\n @stage_of_play += 1\n\n # Resets everyone so they haven't acted for the next round of betting, except for those who are all in.\n @active_players.map do |player|\n if player.current_bet == @table_current_bet\n player.acted = false unless player.chip_stack.zero?\n end\n player.current_bet = 0\n end\n @table_current_bet = 0\n break\n\n else\n # If all of the above conditions fail, it means the player needs to make a move.\n ready_check(@active_players[0])\n player_action\n end\n end\n end\n end\n end",
"def lay_card\n @hand.shift\n end",
"def display_hands(player_hand, computer_hand, player_name)\n sleep(1)\n system 'clear'\n i = 0\n puts \"\\n*** Computer's Hand ***\"\n puts \"* of ******\"\n computer_hand.each_key do |card|\n puts \"#{card}\"if i > 0\n i += 1\n end\n\n show_player_hand(player_hand, player_name)\n puts \"\"\nend",
"def take_turn(player)\n p player.render_hand\n #render their hand\n p \"Which cards do you want to discard? (first, second..etc) i.e. '1,2' If none, reply 'none'\"\n discarded_cards = gets.chomp\n indices = parse(discarded_cards)\n discard(indices, player)\n #promt for how many new cards? => quantity\n #rerender the hand\n #promt for fold?\n #prompt them for a bet.. show their current bet\n end",
"def play_game\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Assign the player and dealer an initial starting card\r\n playerHand = get_new_card\r\n dealerHand = get_new_card\r\n\r\n #Call the method responsible for dealing new cards to the player\r\n playerHand = complete_player_hand(playerHand, dealerHand)\r\n\r\n #If the player has not gone bust, call the method responsible for managing\r\n #dealer's hand\r\n if playerHand <= 21 then\r\n dealerHand = play_dealer_hand(dealerHand)\r\n end\r\n\r\n #call the method responsible for determining the results of the game\r\n determine_winner(playerHand, dealerHand)\r\n\r\n end",
"def starting_hands\n @dealer_hand.push(random_card)\n @player_hand.push(random_card, random_card)\n end",
"def deal\n end_round()\n shuffle()\n rounds_dealt = 0\n while rounds_dealt < @hand_size\n @players.each do | player |\n if card = @deck.draw()\n player.hand << card\n else\n return\n end\n end\n rounds_dealt += 1\n end\n end",
"def deal_cards(cards)\n @players.each do |player|\n player.hand += @deck.cards.pop(cards)\n end\n end",
"def reset_players\n # Replaces the hands array with a new array, with only one hand in it.\n @players.each {|p| p.hands = [p.hand.reset!] }\n\n # Resets the dealers only hand.\n @dealer.hand.reset!\n end",
"def deal_cards\n\t\t\tend",
"def end_round\n @hands.each{ |hand| hand.stand }\n end",
"def deal_card(hand)\n #hand is a string whose valid values are 'player_cards' and 'dealer_cards' \n\n if !['player_cards','dealer_cards'].include?(hand)\n raise \"Unknown hand #{hand}\"\n end \n\n #Check for an empty deck and reshuffle if necessary\n if (session['game_cards'].length == 0) \n\n session['game_cards'] = session['discard']\n session['game_cards'].shuffle!\n session['discard'] = []\n append_message(\"Dealer shuffled the cards.\") \n\n end \n\n #Move the card\n session[hand] << session['game_cards'].pop \n\n end",
"def deal\n hit = bjdeck.draw\n self.player_hand << hit\n hit = bjdeck.draw\n self.computer_hand << hit\n end",
"def deal_card\n @deck.pop\n end",
"def drawcard\n @deck.pop\n end",
"def deal_hand\n dealt = 0\n while dealt < @hand_size \n for player in @players\n player.cards.push(deal_answer_card)\n end \n dealt = dealt + 1\n end\n return @players\n \n end",
"def show_hand\r\n\t\tputs \"#{name} was dealt:\"\r\n\t\thand.cards.each{|c| c.display_card}\r\n\t\tputs \"Hand value: #{hand.hand_value.to_s}\\n\\n\"\r\n\tend",
"def show_hand\n if @hand.point == \"Blackjack\" # the dealer should reveal both cards when it has blackjack\n @hand.turn_all_cards_up\n puts \" #{@hand.to_s} Blackjack\\n\" \n else\n puts \" #{@hand.to_s}\\n\"\n end\n end",
"def deal_cards\n MAX_CARDS.times do |d|\n @player_manager.players.each do |player| \n player.rack.add_card(@decks_manager.draw_pile.draw_card)\n end\n end\n\n # prep the discard pile with one card from the top of the draw pile\n @decks_manager.discard_top_card\n end",
"def deal_card\r\n\t\tcards.pop\r\n\tend",
"def draw\n @cards.pop\n end",
"def reveal_final_hand\n linebreak('-')\n @players.each{ |p| puts p; linebreak; }\n puts \"Dealer reveals #{@dealer.hand}. #{@dealer.hand.count}!\"\n puts \"Dealer BUSTED!\" if @dealer.hand.busted?\n linebreak\n end",
"def first_hand\n @player_hand = deck.cards.pop(2)\n @dealer_hand = deck.cards.pop(2)\n puts \"House will now deal you two cards..Press any key.\"\n #Dumb speech, might take out.\n %x(say 'to lose')\n gets\n #Shows the first two cards you receive\n puts \"Dealer showing #{dealer_hand[0].face} of #{dealer_hand[0].suit}.\"\n puts \"You have a #{player_hand[0].face} of #{player_hand[0].suit} and a #{player_hand[1].face} of #{player_hand[1].suit}. \"\n two_aces\n if dealer_score == 21\n puts \"Well you lost, I got #{dealer_score} already. That was quick huh.\"\n dealer_win\n play_again\n elsif player1_score == 21\n puts \"You win. with a total of #{player1_score}. I didn't even get to deal :(\"\n player_win\n play_again\n else\n play\n end\n end",
"def initial_hand(hand,name)\n puts\n hand.cards.each do |card|\n puts \"#{name} was dealt #{card.rank}#{card.suit}\"\n end\n puts \"#{name}'s score: #{hand.determine_score}\\n\"\n end",
"def use_card\n waiting_to_confirm_placement = true\n waiting_to_use_card = true\n invalid_usage = nil\n invalid_confirmation = nil\n remind_cannot_discard = nil\n \n while waiting_to_confirm_placement\n while waiting_to_use_card\n DisplayManager.prepare_ingame_display\n show_state\n puts \"Newest Card: #{@selected_card.to_s} #{'* you cannot discard this card' if @drew_from_discard}\" unless @selected_card.nil?\n puts \"You cannot discard this card because you drew it from the discard pile.\" if remind_cannot_discard\n remind_cannot_discard = false\n \n @card_to_replace = nil\n @card_to_discard = nil\n\n puts InputManager.input_options({ negative: 'Discard this Card', rack_positions: 'Switch With Card at Position' }, invalid_usage)\n invalid_usage = nil\n\n @placement_response = InputManager.get\n\n # If player chooses a location in their rack\n # Get ready to exchange those cards\n if InputManager::INPUTS[:rack_positions].include?(@placement_response)\n prep_place_card_in_rack(@placement_response)\n waiting_to_use_card = false\n\n # If player chooses to discard their card\n # get ready to discard their card\n # Disallow discard if card was drawn from the discard pile\n elsif InputManager.negative?(@placement_response)\n if @drew_from_discard\n remind_cannot_discard = true\n else\n prep_discard_drawn_card\n waiting_to_use_card = false\n end\n else\n invalid_usage = @placement_response\n end\n end\n\n DisplayManager.prepare_ingame_display\n show_state\n puts \"Newest Card: #{@selected_card.to_s}\"\n\n if @card_to_replace\n puts \"You want to exchange #{@card_to_replace.to_s} with #{@selected_card.to_s}.\"\n else\n puts \"You do not want to use #{@selected_card.to_s}.\"\n end\n\n puts \"You are discarding #{@card_to_discard.to_s}.\"\n\n puts InputManager.input_options({ affirmative: 'Save and Complete Turn', negative: 'Do Something Different' }, invalid_confirmation)\n invalid_confirmation = nil\n confirm_response = InputManager.get\n\n # If player confirms their decision\n # persist their decision\n if InputManager.affirmative?(confirm_response)\n save_and_discard(@placement_response)\n waiting_to_confirm_placement = false\n \n # If player changes their mind\n # allow them to choose how to use their card again \n elsif InputManager.negative?(confirm_response)\n waiting_to_use_card = true\n else\n invalid_confirmation = confirm_response\n end\n end\n end",
"def player_hit\n player_hand << deck.cards.pop\n puts \"you drew a #{player_hand.last.face} of #{player_hand.last.suit}.\"\n end",
"def deal\r\n @cards.shift\r\n end",
"def card_from_user(hand, cards_played)\n next_card_prompt(hand)\n\n puts \"What card would you like to play?\"\n card = get_card_following_suit(hand, cards_played)\n\n puts \"You picked #{card}\"\n hand.delete(card)\n\n card\n end",
"def play(deck)\r\n\t\taction = get_user_action if hand.hand_value < 21\r\n\t\twhile (hand.hand_value) < 21 && (action == \"H\") do\r\n\t\t\tdraw_card(deck.deal_card)\r\n\t\t\tshow_hand\r\n\t\t\taction = get_user_action if hand.hand_value < 21\r\n\t\tend\r\n\tend",
"def turn_card(guess)\n @board[guess].reveal\n @player.store_cards(guess, @board[guess].value)\n p @player.store\n end",
"def deal_hand\n\t\thand = Array.new\n\t\t@num_cards.times do\n\t\t\tcard = get_card(get_random_number)\n\t\t\thand << card\n\t\t\tremove_card_from_deck(card)\n\t\tend\n\t\thand\n\tend",
"def deal\r\n @deck_of_cards.shift\r\n end",
"def deal_hand no_of_cards\r\n @card_list.deal_hand no_of_cards\r\n end",
"def clear()\n @hands = Array.new\n end",
"def deal_card_to_player(player, card, show)\n if show\n puts \"Dealing to #{player.name}: #{card}\"\n elsif\n puts \"Dealing hidden card to #{player.name}\"\n end\n player.hands[0].add_card(card, false)\n end",
"def deal_cards(cards)\n super\n @pipe.puts cards.join $/\n @pipe.puts\n @pipe.flush\n end",
"def play(deck)\r\n\t\twhile hand.hand_value < 17 do\r\n\t\t\tdraw_card(deck.deal_card)\r\n\t\tend\r\n\tend",
"def play\n deal( INITIAL_CARDS )\n while hand.deck.size >= CARD_SET\n compare_cards\n deal( CARDS )\n end\n end",
"def draw_final_card\n @card3 = Card.draw(@card1.id, @card2.id)\n puts \"The next card is the #{@card3}\"\n\n # player wins if card is Joker\n raise Rules::Win::Joker if @card3.joker?\n end",
"def reset_discard_pile(deck)\n @cards = []\n @cards << deck.take_card\n while @cards[0].color == 'Wild' || @cards[0].number.is_a?(String)\n deck.cards.unshift(@cards.pop)\n @cards << deck.take_card\n end\n @cards\n end",
"def printEmptyHandMessage(player, dealer)\n puts dealer.printHands(true)\n puts player.printHands\n puts \"Uh oh. This hand is now over 21. Sorry :(\"\n pressKeyToContinue\nend",
"def deal_hand no_of_cards\n @card_list.deal_hand no_of_cards\n end",
"def return\n @cards += @discard\n @discard.clear\n @cards.shuffle\n end",
"def save_card_win(aux_card)\n if aux_card.nil?\n else\n card_win = aux_card\n end\n card_win\n end",
"def set_hands(hand_size = 2)\n puts \"Dealing cards\"\n @player.new_hand\n @dealer.new_hand\n\n @dealer.update_deck if @deck.cards_left < ((hand_size * 2) + 1) # Rebuilds deck if empty\n hand_size.times do\n @player.hand.hit\n @dealer.hand.hit\n end\n end",
"def discard(card)\n hand.transfer!(card: card, to: discard_pile)\n end",
"def deal_one_card\n player.hands.each do |hand|\n # return nil if hand.bust?\n deck.deal(hand.cards)\n puts \"#{player.name} got #{hand.cards[-1].output_card}\"\n end\n deck.deal(house.hand.cards)\n puts \"#{house.name} got #{house.hand.cards[-1].output_card}\"\n end",
"def playCard()\n if (@hand.length == 0)\n puts \"#{@name} RAN OUT OF CARDS\"\n return false\n end\n topCard = @hand.shift\n return topCard\n end"
] | [
"0.7663884",
"0.7539696",
"0.73500526",
"0.73055166",
"0.7229147",
"0.71547246",
"0.7144904",
"0.7088463",
"0.7042899",
"0.7007274",
"0.6996447",
"0.69890136",
"0.69469804",
"0.6937299",
"0.69277155",
"0.69094914",
"0.6899752",
"0.6873629",
"0.68638563",
"0.68516827",
"0.68047047",
"0.680047",
"0.680028",
"0.676223",
"0.67509085",
"0.67483807",
"0.673158",
"0.669973",
"0.6684848",
"0.6682893",
"0.6659317",
"0.6653831",
"0.6619508",
"0.65956014",
"0.65939987",
"0.657937",
"0.65736556",
"0.65728307",
"0.65613085",
"0.6535816",
"0.652342",
"0.65217423",
"0.65216446",
"0.65095377",
"0.6507503",
"0.650171",
"0.65010935",
"0.6499763",
"0.6487846",
"0.64855564",
"0.64810884",
"0.64714295",
"0.6467644",
"0.6459375",
"0.645322",
"0.6450863",
"0.6445862",
"0.64411134",
"0.6437161",
"0.6429667",
"0.64270335",
"0.642607",
"0.64225835",
"0.64179367",
"0.6417866",
"0.64083254",
"0.6394154",
"0.63930255",
"0.63909894",
"0.6386447",
"0.6367908",
"0.63538635",
"0.63533765",
"0.6344184",
"0.63407904",
"0.63373834",
"0.6326805",
"0.63255703",
"0.63242745",
"0.63215405",
"0.6319423",
"0.6315666",
"0.6315295",
"0.6308859",
"0.63082165",
"0.6302949",
"0.6301963",
"0.6296974",
"0.62948215",
"0.6269282",
"0.6268601",
"0.62635386",
"0.62511957",
"0.6250993",
"0.6250876",
"0.6244993",
"0.6237545",
"0.6236913",
"0.6235195",
"0.6232284"
] | 0.70044774 | 10 |
end of reset player's hand Sum of Dealer's Lowest total | def determine_dealers_lowest_total
sum_of_dealers_hand = 0
@dealer_hand.each {|x|
card_value = @deckhash.fetch(x)
if card_value == 1 then card_value = 11
end
sum_of_dealers_hand = sum_of_dealers_hand + card_value
}
# ### This method returns sum of dealer's hand
return sum_of_dealers_hand
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def add_players_lowest_hand(current_player)\n sum_of_players_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 1\n if current_player == 2 then\n @player2_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 2\n if current_player == 3 then\n @player3_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 3\n if current_player == 4 then\n @player4_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 4\n# ### This method returns sum of player's hand\n return sum_of_players_hand\n end",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def get_hand_sum(curr_hand) \n curr_hand.inject(0) { |sum, card| sum + card }\n end",
"def getDealTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $dealerCards.length\n\t\tx = $dealerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end",
"def dealer_score\n dealer_hand.inject(0){|sum,n| sum + n.value }\n end",
"def de_total\n @printer << \"Dealer has #{session[:dealer].hand_total}\" if !session[:dealer].blackjack?\n @printer << \"Dealer busts!\" if session[:dealer].bust? \n if session[:dealer].blackjack?\n @printer << \"Dealer has BlackJack.\"\n session[:player].make_unlucky\n end\n nil\n end",
"def player1_score\n player_hand.inject(0){|sum,n| sum + n.value }\n end",
"def show_hands\n player_final_value = player_hand.reduce(:+)\n dealer_final_value = dealer_hand.reduce(:+)\n puts \"Player has a total of #{player_final_value}. Dealer has a total of #{dealer_final_value}\"\n if player_final_value > dealer_final_value\n puts \"You win, congrats on beating a program built by a novice.\"\n else\n puts \"I have bested you.\"\n end\n end",
"def reduce_HP\n @points -= 10\n end",
"def total\n calculate_hand_totals\n if @hand.empty?\n puts \"Your hand is empty.\"\n return\n end\n\n puts \"Your hand is #{@hand.to_s}\" \n\n if !in_good_standing?\n puts \"*** YOU LOSE! ***\"\n end\n\n puts \"You have #{@hand_totals.count} possible total(s) with #{@hand_totals.count - 1} Aces:\"\n @hand_totals.each do | total, ace_distrobution |\n if total > 21\n puts \"BUSTED!- #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21 && @hand.count == 2\n puts \"BLACKJACK - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21\n puts \"WINNING HAND - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n else\n puts \"#{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n end\n end\n end",
"def sum_player_hand(player_hand)\n player_hand.reduce(:+)\n end",
"def get_player_total(player_hand)\n\tplayer_total = 0 \t\t# Total value of player's hand\n\n\tfor i in 0..player_hand.length - 1\n\t\tplayer_total += $cards[player_hand[i]]\n\tend\n\treturn player_total\nend",
"def hand_score\n score = self.tricks\n if !self.got_set\n score += 10\n end\n return score\n end",
"def hand_total(hand) \n\n #A flag to see if the hand contains an ace\n have_ace = ! ( session[hand].select{|card| card['rank'] == \"ace\"}.empty? ) \n\n total = 0 \n\n #Look up the point value of each card in the hand\n session[hand].each do |card|\n total += RANK_TO_POINTS[ card['rank']]\n end\n \n #Convert from hard (ace=1) to a soft (ace=11) \n #score if hand contains an ace\n #and it won't cause the hand to bust\n if (total <= 11 && have_ace) then total += 10 end \n\n return total \n\n end",
"def current_total_amount\n\n if calculate_total(session[:player_cards]).to_i == BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:player_cards]).to_i > BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:dealer_cards]).to_i > BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i == BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:player_cards]).to_i > calculate_total(session[:dealer_cards]).to_i\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i > calculate_total(session[:player_cards]).to_i\n session[:player_pot] -= session[:player_bet].to_i \n else\n session[:player_pot]\n end # ends if statement\n end",
"def dealer_round (dealer_cards, dealer_total, deck)\n puts \"Now it's the dealer's turn to play...\"\n dealer_total = total(dealer_cards, dealer_total)\n while dealer_total <= 17\n puts \"Dealing another card...\"\n dealer_cards << deal_cards(1,deck)\n value_string = dealer_cards.last.last[1]\n puts \"Dealer has been dealt a #{value_string}.\"\n dealer_total += get_int_value(value_string, dealer_total)\n puts \"New dealer total: #{dealer_total}\"\n end\n dealer_total\nend",
"def total_on_hand\n if @variant.should_track_inventory?\n stock_items.sum(:count_on_hand)\n else\n Float::INFINITY\n end\n end",
"def determine_players_best_total(current_player)\n # @player1_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n sum_of_players_hand = 0\n number_of_aces_in_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n\n sum_of_players_hand = sum_of_players_hand - 10\n\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 1\n\n if current_player == 2 then\n @player2_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 2\n\n if current_player == 3 then\n @player3_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 3\n\n if current_player == 4 then\n @player4_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 4\n # ### This method returns sum of player's best hand\n return sum_of_players_hand\n end",
"def total_query\n\t\t@total = 0\n\t\t@cards_held.times do |x|\n\t\t\t@total += hand_query(x,1,0)\n\t\tend\n\t\treturn @total\n\tend",
"def player_turn\n player_hand.each do |card|\n puts card\n end\n # hand_value = player_hand.reduce(:+)\n hand_value = player_hand.reduce(0){|sum, num| sum + num.value}\n puts \"You have #{hand_value}\"\n\n puts \"Hit or Stay\"\n answer = gets.chomp.downcase\n if answer == \"hit\"\n hit_phase\n # puts hand_value\n end\n # puts hand_value\n end",
"def deal_and_total(name, hand_array, deck_hash)\n read_hand(name, hand_array, deck_hash)\n new_hand_value = sum_cards(hand_array, deck_hash)\nend",
"def total\n sum = 0\n hand.each do |card|\n sum += card.find_face_value\n end\n sum = correct_for_aces(sum)\n end",
"def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend",
"def pl_total\n @printer << \"You have #{session[:player].hand_total}\" if !session[:player].blackjack?\n @printer << \"You bust.\" if session[:player].bust?\n if session[:player].blackjack?\n @printer << \"BlackJack!\" \n session[:player].make_lucky\n end\n nil\n end",
"def eval_hand(player, player_hand)\n d = @dealer.hand.count\n p = player_hand.count\n\n if p > 21 || (d > p && d <= 21) # LOSE!\n puts \"You lost $#{player_hand.bet}.\"\n elsif d == p # PUSH!\n player.wallet += player_hand.bet\n puts :Push\n elsif p == 21 && player_hand.size == 2 # BLACKJACK!\n # Blackjack pays out 3/2.\n player.wallet += (player_hand.bet*2.5).to_i\n puts \"You won $#{player_hand.bet*1.5}!\"\n else # WIN!\n player.wallet += (player_hand.bet*2)\n puts \"You won $#{player_hand.bet}!\"\n end\n end",
"def get_dealer_total(dealer_hand,dealer_turn)\n\tdealer_total = 0\t# Total value of dealer's visible cards\n\n\tif !dealer_turn\n\t\tdealer_total = $cards[dealer_hand[0]]\n\telse\n\t\tfor i in 0 .. dealer_hand.length - 1\n\t\t\tdealer_total += $cards[dealer_hand[i]]\n\t\tend\n\tend\n\treturn dealer_total\nend",
"def winning_hand\n if !(@player.hand.bust)\n if @player.hand.value > @dealer.hand.value\n player_win\n elsif @player.hand.value == @dealer.hand.value\n if @player.hand.blackjack? && [email protected]?\n player_win\n else\n puts \"The hand pushed\"\n @player.push_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You lost the hand\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You busted\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n end",
"def play_as_dealer(deck)\r\n if value < 17\r\n hit!(deck)\r\n play_as_dealer(deck)\r\n else\r\n puts \"Dealer Total is #{value}\"\r\n end\r\n end",
"def getPlayTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $playerCards.length\n\t\tx = $playerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def pl_high?\n session[:player].hand_total > session[:dealer].hand_total\n end",
"def total_high\n if is_soft\n return total[1]\n end\n return total\n end",
"def initial_round\n total = deal_card + deal_card\n display_card_total(total)\n return total\nend",
"def reset_game()\n # If money in pot, distribute\n while (self.pot > 0)\n winners = []\n # In case where everyone has folded, set the winner to whoever is left\n if self.players.where(:in_hand => true).length <= 1\n winners = self.players.where(:in_hand => true)\n else\n #gets people with highest score\n winners = get_winners()\n end\n winners.each do |winner|\n #TO IMPLEMENT: more advanced side pots\n winner.money += self.pot / winners.length()\n winner.save\n end\n self.pot = 0\n end\n # reset deck of cards\n self.cards.where.not(:location => -1).each do |card|\n card.location = -1\n card.save\n end\n # reset amount each player has in the pot to 0\n self.players.each do |player|\n player.in_hand = true\n player.in_pot_hand = 0\n player.in_pot_current = 0\n player.hand = ''\n player.save\n end\n # reset pot to empty, increment dealer if not first hand\n if self.round != -1\n self.dealer = (self.dealer + 1)%10 + 10\n end\n # makes sure a player exists where the dealer is set\n while self.players.where(:location => self.dealer).length == 0\n self.dealer = (self.dealer + 1)%10 + 10\n end\n self.round = 0\n self.high_bet = 0\n self.high_better = get_next_player(self.dealer)\n self.save\n deal(self.round)\n end",
"def hand_value\n @hand_value = @player_hand.hand.flatten.map { |x| Integer(x) rescue nil}.compact.inject(:+)\n end",
"def initial_round\n total = deal_card + deal_card\n display_card_total(total)\n total\nend",
"def initial_round\n card_total = deal_card + deal_card\n display_card_total(card_total)\n card_total\nend",
"def flush(hand)\n\t\thand_num = check_num(hand)\n\t\tif !check_consecutive(hand_num) and same_suit(hand)\n\t\t\treturn 5\n\t\tend\n\t\treturn 0\n\tend",
"def finish_round!\n raise Exceptions::NoWinner if @players_in_round.nil?\n # The winner is the Player with the highest hand_value.\n @round_winner = @players_in_round.sort_by do |player|\n hand_value(player.hand)\n end.reverse.first\n @round_winner.chips += @pot\n @pot = INITIAL_POT\n end",
"def hand_value(hand)\n sum = 0\n hand.each do |card|\n sum += card\n end\n sum\n end",
"def get_hand_value\n cards.reduce(0) { |hand_value, card| hand_value += card.value }\n end",
"def check_who_wins(hand_total_dealer, hand_total_player)\n hand_to_use_dealer = 0\n hand_to_use_player = 0\n\n if hand_total_dealer[1] <= 21\n hand_to_use_dealer = hand_total_dealer[1]\n else\n hand_to_use_dealer = hand_total_dealer[0]\n end\n\n if hand_total_player[1] <= 21\n hand_to_use_player = hand_total_player[1]\n else\n hand_to_use_player = hand_total_player[0]\n end\n\n if hand_to_use_player < hand_to_use_dealer\n return \"dealer\"\n elsif hand_to_use_dealer < hand_to_use_player\n return \"player\"\n elsif hand_to_use_player = hand_to_use_dealer\n return \"draw\"\n end\n\nend",
"def total_hands\n return @@total_hands\n end",
"def calcScore(hand)\n return hand.inject(0) { |sum, n| sum + n.points }\nend",
"def reset\n\t\t@hand = Array.new\n\t\t@total = 0\n\tend",
"def hand_value\n\t\tadd_card_value(all_sums = [[]])\n\t\tconvert_aces(all_sums)\n\t\tall_sums.map! do |value_set|\n\t\t\tvalue_set.inject :+\n\t\tend\n\t\treturn_sum(all_sums)\n\tend",
"def results\n\t\t# reset totals\n\t\t@dealer_total = 0\n\t\t@player_total = 0\n\t\t# display results\n\t\tputs \"\\nDEALER:\\n-------\"\n\t\tif @player_done.nil?\n\t\t\tputs \"/// hidden card ///\"\n\t\t\tcard = @dealer_hand[1]\n\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t@dealer_total += card.value\n\t\telse\n\t\t\t@dealer_hand.each do |card|\n\t\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t\t@dealer_total += card.value\n\t\t\tend\n\t\tend\n\t\tputs \"---> TOTAL (#{@dealer_total})\"\n\t\tputs \"\\nPLAYER:\\n-------\"\n\t\t@player_hand.each do |card|\n\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t@player_total += card.value\n\t\tend\n\t\tputs \"---> TOTAL (#{@player_total})\"\n\t\tprint \"\\nYou have #{@player_total}. \"\n\t\t# determine how to proceed based on totals\n\t\tif @player_total == 21\n\t\t\tputs \"BLACKJACK!! You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif @player_total > 21\n\t\t\tputs \"BUST!! You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total == 21\n\t\t\tputs \"Dealer has BLACKJACK. You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total > 21\n\t\t\tputs \"Dealer BUSTS. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif (@dealer_total < @player_total && @player_total <= 21) && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif (@dealer_total > @player_total && @player_total <= 21) && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total == 21 && @player_total == 21\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif @dealer_total == @player_total && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telse\n\t\t\tself.hit_or_stand?\n\t\tend\n\t\tputs \"Score:\"\n\t\tputs \"Player: #{player_wins} --- Dealer: #{dealer_wins}\"\n\t\t# prompt to start new game or end\n\t\tself.continue?\n\tend",
"def hand_of_poker\n players_in_hand = @players.dup\n @players.each {|player| deal(player, 5)}\n remaining_players = betting_round(players_in_hand)\n unless remaining_players.count == 1\n exchange_cards\n remaining_players = betting_round(remaining_players)\n unless remaining_players.count == 1\n remaining_players = compare_hands(remaining_players)\n end\n end\n winner = remaining_players.first\n puts \"#{winner.name} wins!\"\n print \"\\n\\n\\n\"\n pay_out(winner)\n reset_deck\n end",
"def player_round (player_cards, dealer_cards, player_total, player_name, deck)\n # display the first round of cards, only show dealer's top card\n puts \"Welcome, #{player_name}!\"\n puts \"Dealer has: #{dealer_cards[0]} and #{dealer_cards[1]}\"\n puts \"You have: #{player_cards[0]} and #{player_cards[1]}\"\n player_total = total(player_cards, player_total)\n if blackjack(player_total) != true\n puts \"Your total is #{player_total}, would you like to hit or stay? (hit or stay response only allowed)\"\n # add validation for this\n hit_stay = gets.chomp.downcase\n while hit_stay == \"hit\"\n player_cards << deal_cards(1,deck)\n # IMPORTANT: WHY IS EXTRA LAST NECESSARY HERE, EXTRA BLANK ARRAY?\n value_string = player_cards.last.last[1]\n puts \"You've been dealt a #{value_string}.\"\n player_total += get_int_value(value_string, player_total)\n if player_total < 21\n puts \"Your total is now #{player_total}, would you like to hit or stay?\"\n hit_stay = gets.chomp.downcase\n elsif player_total > 21\n hit_stay = \"bust\"\n else\n hit_stay = \"blackjack\"\n end\n end\n end\n player_total\nend",
"def pays_players\n self.players.inject(0) {|sum, player| sum += player.pay}\n end",
"def win_insurance_bet(hand, winnings)\n @bankroll += winnings\n @@bankroll += winnings\n #hand.insurance_bet = 0\n end",
"def dealer_turn\n puts \"Dealer's Turn. Showing #{dealer_hand[0]}\"\n dealer_value = dealer_hand.reduce(0) {|sum, num| sum + num.value}\n if dealer_value < 16\n d_hit_phase\n end\n puts dealer_value\n end",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def compute_sum_for player\r\n if player == nil || player[:cards] == nil || player[:cards].length == 0\r\n return 0\r\n end\r\n \r\n #Compute initial points\r\n sum = 0\r\n i = 0\r\n \r\n while i < player[:cards].length\r\n card = player[:cards][i]\r\n sum = sum + (card[:face] > 10 ? 10 : ((card[:face] == 1)? 11 : card[:face]))\r\n\ti = i + 1\r\n end\r\n \r\n #Fix the sum if possible, when the points is larger than 21\r\n j = player[:cards].length - 1\r\n while sum > 21 && j >= 0\r\n\tcard = player[:cards][j]\r\n\tif card[:face] == 1 #There is an Ace\r\n\t sum = sum - 11 + 1\r\n\tend\r\n\tj = j - 1\r\n end\r\n\t\r\n sum\r\nend",
"def calculate_difference\n unless final?\n self.difference = stocked? ? current - on_hand : current\n end\n self\n end",
"def final_round()\n d = value(@dealer)\n puts \"--- Check Round --- \"\n puts \"Dealers' cards are #{@dealer.join(',')} for a value #{d}\"\n\n # Iterate over all players who are still in the game,\n # as in they haven't lost in the initial round doing 'hits'\n #\n # Precondition: forall p in players where p.cur_playing == false, value(p.cards) <= 21\n @players.find_all{|p| p.cur_playing}.each do |p|\n if value(p.cards) < d && d <= 21 # Dealer Wins\n puts \"Player #{p.index} has deck worth #{value p.cards}, and loses to the dealer...\"\n debit_player(p)\n elsif (value(p.cards) > d && d <= 21) || d > 21 # Player Wins\n puts \"Player #{p.index} has deck worth #{value p.cards}, and wins with the dealer...\"\n credit_player(p)\n elsif value(p.cards) == d\n puts \"Player #{p.index} has deck worth #{value p.cards}, and draws with the dealer...\"\n end\n end\n end",
"def game_score\n previous_hands = self.game_player.hand_players.joins(:hand).where(\n \"hands.position <= ?\", self.hand.position\n )\n gs = 0\n for h in previous_hands\n gs += h.hand_score\n end\n return gs\n end",
"def distribute_money_internal_2(dealer_total, player , hand_index)\n i = hand_index\n dt = dealer_total\n hv = player.get_value(i)\n bet = player.get_bet(i)\n pn = player.player_number\n\n # instead of modifiying amount directly, should use a function call to increment player amount by payoff factor\n if (hv == 21 and (dt > 21 or dt < 21) )\n #player.amount += (bet * 2.5)\n player.modify_account(bet,2.5)\n puts \"Player #{pn} H#{i} #{hv} Blackjack - Dealer #{dt} , Amount= #{player.amount}\"\n elsif (hv < 21 and dt > 21) or (dt <= 21 and hv <= 21 and hv > dt)\n #player.amount += (bet * 2)\n player.modify_account(bet,2)\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n elsif (dt > 21 and hv > 21) or ((hv == 21) and dt == 21 ) or (hv == dealer_total and dt <= 21 and hv <= 21)\n #player.amount += (bet * 1)\n player.modify_account(bet,1)\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n else\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n end\n\n end",
"def hand_value(hand)\n return 0 if hand.empty?\n value = 0\n\n # Add up the face values\n hand.each do |card|\n value += FACE_VALUES[card.face]\n end\n\n # Handle any needed Ace changes.\n while value > BUST\n hand.each do |card|\n if card.face == 'A'\n # Subtract the difference between high and low ace (10).\n value -= (FACE_VALUES['A'] - FACE_VALUES['L'])\n end\n end\n break # no aces to change, bail\n end\n\n return value\n end",
"def haul\n @totalhaul = @silvercounter * SILVERVAL + @goldcounter * GOLDVAL\n @totalhaul\n end",
"def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end",
"def reset_stats\n self.rounds = 0\n self.wins = 0\n self.losses = 0\n self.total_points = 0\n self.rank = 0\n end",
"def detect_result(dealer_hand, player_hand)\n player_total = calculate_total(player_hand)\n dealer_total = calculate_total(dealer_hand)\n\n if player_total > 21\n :player_busted\n elsif dealer_total > 21\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif player_total < dealer_total\n :dealer\n else\n :tie\n end\nend",
"def bookkeeping_before_betting()\n @dealer.reset() ## very important to reset dealer\n @players.delete_if{|player| player.amount <= 0} ## remove broke players\n if @players.size == 0\n puts \"**********WE NEED MORE PLAYERS**************\"\n exit() # exit if no more players left\n end\n @players.each do | player|\n player.reset() ## reset remaining players\n end # end reset\n end",
"def dealer_turn\r\n dealer.reveal_hand\r\n if dealer.total_for_hand < 17\r\n loop do\r\n dealer.add_to_hand(deck)\r\n break if dealer.total_for_hand > 16\r\n end\r\n puts \"#{dealer.name} has #{dealer.total_for_hand}\"\r\n end\r\n end",
"def round()\n\t\t#array of used cards\n\t\t@used = []\n\t\t#loop through players array\n\t\tfor i in 0...@num_players\n\t\t\t#reset player variables\n\t\t\t@players[i].reset()\t\n\t\t\t#populate hand\n\t\t\t@players[i].populate(@used,52,5)\n\t\t\t#get hand rank\n\t\t\t@players[i].get_rank()\n\t\t\t#add hand to array of used cards\n\t\t\t@used += @players[i].hand\n\t\tend\n\t\t#increment round number\n\t\t@roundnum += 1 \n\tend",
"def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def calculate_hand_value(hand)\n value = 0\n if hand.values.reduce(:+) <= 21\n value = hand.values.reduce(:+)\n elsif hand.values.reduce(:+) > 21 && hand.keys.any? {|card| card.include?(\"A\") }\n hand.keys.each do |card|\n hand[card] = 1 if card.include?(\"A\")\n value = hand.values.reduce(:+)\n break if value <= 21\n end\n value\n else\n value = hand.values.reduce(:+)\n end\n\nend",
"def remaining_total\n total\n end",
"def player_hits(deck, player_cards, dealer_cards, hand_totals)\n player_cards << deck.pop\n update_hand_totals(player_cards, dealer_cards, hand_totals)\nend",
"def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end",
"def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend",
"def sum\n\t\t#sets sum at 0\n\t\tsum = 0\t\t\n\n\t\t#adds each card to the sum\n\t\t@hand_contents.each do |card|\n\t\t\tsum += card.number\n\t\tend\n\n\t\t@hand_contents.each do |card|\n\t\t\tif card.number.eql? 1 then\n\t\t\t\tif sum + 10 <= 21 then\n\t\t\t\t\tsum += 10\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t#return the sum\t\t\n\t\treturn sum\n\tend",
"def hit\n new_card = @deck.cards.pop\n @current_hand << new_card\n @total += new_card.value\n puts \"drew #{@current_hand[-1].card_id}\"\n\n @current_hand.each do |card|\n if @total > 21\n if card.value == 11 && card.ace_low == false\n @total -= 10\n card.ace_low = true\n end\n end\n end\n end",
"def double_bet(hand)\n hand.bet += @bet\n @bankroll -= @bet\n @@bankroll -= @bet\n end",
"def check\n curhand = \"hand ##{@cur+1} contains: \"\n containAce = false;\n sum = 0\n i = 0\n while i<@hands[@cur].length\n if 1 == num_to_value(@hands[@cur][i])\n containAce = true\n end\n sum += num_to_value(@hands[@cur][i])\n curhand += num_to_rank(@hands[@cur][i]) + \" \"\n i += 1\n end\n\n puts \"---------------------------------------------------------\"\n puts curhand\n\n if containAce\n if sum < 11\n puts \"hand ##{@cur+1} value: #{sum}/#{sum+10}\"\n @values[@cur] = sum + 10 # store the higher value which benefits the player\n elsif 11 == sum \n if 2 == @hands[@cur].length && 1 == @hands.length # a blackjack!! no split and only contain two cards\n puts \"hand ##{@cur+1} value: BLACKJACK!!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 50 # use 50 to represent a blackjack\n else\n puts \"hand ##{@cur+1} value: 21\"\n @values[@cur] = 21\n @hands_status[@cur] = \"finished\"\n end\n elsif sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum \n end\n else\n if sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum\n end\n end\n\n\n puts \"bets for hand ##{@cur+1}: #{@bets[@cur]}\"\n puts \"---------------------------------------------------------\"\n\n if \"finished\" == @hands_status[@cur] \n puts \"hand ##{@cur+1} finished\"\n puts \"\"\n if @cur < @hands.length - 1\n @cur += 1 \n self.check # this recursion is to output the information about newly splitted hand's initial status\n end\n end\n\n end",
"def lose!\n\t\t@bet = 0\n\tend",
"def union_dues_amount\n if (uniondues == true)\n return ( find_base_wage() * SystemVariable.value(:union_dues) ).floor\n else\n return 0\n end\n end",
"def total\n @frame.inject(0){|rez, item| item ? rez + item[:score] : rez }\n end",
"def defend(attacking_card)\n min = 15\n min_c = nil\n if attacking_card.suit == @trump_suit\n self.trump_cards.each do |c|\n if c.int_val > attacking_card.int_val &&\n c.int_val < min\n min_c = c\n min = c.int_val\n end\n end\n else\n self.non_trump_cards.each do |c|\n if c.int_val > attacking_card.int_val &&\n c.int_val < min && attacking_card.suit == c.suit\n min_c = c\n min = c.int_val\n end\n end\n end\n @cards.delete(min_c)\n min_c\n end",
"def dealer_action\n # Dealer stands on soft 17's.\n while @dealer.hand.count < 17\n @dealer.take(@shoe.hit)\n end\n\n # The first card is drawn silently. This fixes the count.\n @shoe.adjust_count(@dealer.hand.cards[0])\n end",
"def on_hand_stock(outstanding_orders)\n self.movie_copies.pluck(:stock).sum - outstanding_orders\n end",
"def calculate_previous_total\n return unless frame.frame_has_finished?\n\n return if frame.number == 1 # nothing to calculate if it is the first frame\n\n return unless previous_frame_was_strike_or_spare?\n\n if frame.previous_frame.strike\n new_total = frame.first_roll + frame.second_roll + frame.previous_frame.total\n frame.previous_frame.update_columns(total: new_total)\n end\n\n if frame.previous_frame.spare\n new_total = frame.first_roll + frame.previous_frame.total\n frame.previous_frame.update_columns(total: new_total)\n end\n end",
"def best_hand\n @active_players.map do |player|\n # Creates an array storing all possible 5 card combinations.\n @all_combos = (player.hole_cards + @community_cards).combination(5).to_a\n @best_hand = PokerHand.new\n @current_hand = nil\n\n # Loops through every hand combination, comparing the current hand to the best hand. If the current hand is better than the best hand, it becomes the best hand, otherwise it is deleted.\n @all_combos.map do |hand|\n next unless @all_combos.length > 1\n\n @current_hand = PokerHand.new(hand)\n if @current_hand > @best_hand\n @best_hand = @current_hand\n else\n @all_combos.delete(hand)\n end\n end\n\n # After finding the best hand it stores it for the player and outputs it.\n player.strongest_hand = @best_hand\n puts \"#{player.player_name} has #{player.strongest_hand}\"\n sleep(1)\n end\nend",
"def calc_odds(hand, result)\n current = hand_value(hand)\n return 1.0 if current == result\n return 0.0 if current >= 17\n\n # Remove hand cards from full shute\n cards = new_shute\n hand.each {|c| cards.delete_at(cards.index(c))}\n\n odds = 0.0\n CARDS.each do |c|\n odds_of_card = odds_of(cards, c)\n if odds_of_card > 0.0\n hand.push c\n odds_of_result = calc_odds(hand, result)\n odds += odds_of_card * odds_of_result\n hand.pop\n end\n end\n\n return odds\nend",
"def current_hp\n\t\t@current_hp + temp_hp\n\tend",
"def runner\n welcome\n sum = initial_round\n until sum > 21\n current_hand = hit?(sum)\n sum = current_hand if current_hand.is_a?(Integer)\n display_card_total(sum)\n end\n end_game(sum)\nend",
"def calculate_conditions\n if hand_value(@dealer_hand) > 21\n puts \"\\ndealer busts! You WIN!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) == hand_value(@dealer_hand)\n puts \"\\nHand is a push! You get your money back\"\n elsif hand_value(@player_hand) > hand_value(@dealer_hand)\n puts \"\\nYou Win!\"\n @user[:balance] += @wager\n puts \"\\nYour new balance is $#{@user[:balance]}\"\n elsif hand_value(@player_hand) < hand_value(@dealer_hand)\n puts \"HOUSE WINS. Try again\"\n @user[:balance] -= @wager\n puts \"Your new balance is $#{@user[:balance]}\"\n else\n puts \"Something went wrong\"\n end\n end",
"def total\n wins + losses\n end",
"def score\n while @current_roll < @rolls.size - 1\n init_roll\n\n if strike?\n score_strike\n elsif spare?\n score_spare\n else\n score_roll\n end \n end\n \n return @total_score\n end",
"def payout\n until @pot_size.zero?\n\n # If the winning player has gone all in this round, they are only paid out the maximum amount they could possibly win from the pot.\n if @active_players[0].max_winnings < @pot_size && @active_players[0].max_winnings != 0\n puts \"#{@active_players[0].player_name} won #{@active_players[0].max_winnings} with high hand: #{@active_players[0].strongest_hand}.\"\n @active_players[0].chip_stack += @active_players[0].max_winnings\n @pot_size -= @active_players[0].max_winnings\n @active_players[0].max_winnings = 0\n\n # Deletes the player who has been paid out from the array so that they do not get paid out twice.\n @active_players.shift\n\n # If the winning player didn't need to go all in, they simply win the whole pot.\n else\n if @active_players.length > 1\n puts \"#{@active_players[0].player_name} won #{@pot_size} chips with high hand: #{@active_players[0].strongest_hand}.\"\n else\n puts \"#{@active_players[0].player_name} won #{@pot_size} chips.\"\n end\n @active_players[0].chip_stack += @pot_size\n @pot_size = 0\n puts \"#{@active_players[0].player_name} now has #{@active_players[0].chip_stack} chips.\"\n end\n end\n sleep(5)\nend",
"def score\n # make a local array that will disappear when not in this method\n tally = []\n # for each of the cards in the hand, add their score to the tally from points\n @hand.each do |card|\n tally.push(@points[card])\n end\n # return the tally of the scores\n return tally.sum\nend",
"def reset\n @gold_coins = 0\n @health_points = 10\n @lives = 5\n end",
"def total_score\n\t\tall_scores = picks.collect { |pick|\n\t\t\tpicks_golfers = TournamentGolfer.where(golfer_id: pick.golfer_id, tournament_id: pick.pool.tournament_id).pluck(:total)[0]\n\t\t} - [nil] - [\"CUT\"]\n\t\tif all_scores.count < 5\n\t\t\treturn \"DQ\"\n\t\telse \n\t\t\tall_scores = all_scores.map {|score| score.to_i}\n\t\t\tall_scores = all_scores.sort\n\t\t\treturn all_scores[0..(pool.number_golfers_for_scoring-1)].sum\n\t\tend\n\tend",
"def amount_remaining\n @desired_amount - @bought_amount\n end",
"def runner\n welcome\n card_sum = initial_round\nuntil card_sum > 21\n new_value = hit?(card_sum)\n card_sum = new_value\n display_card_total(card_sum)\nend\nend_game(card_sum)\nend",
"def blind_score\n p_score = player_hand.collect{|x| x.value}.inject(:+)\n c_score = computer_hand.collect{|x| x.value}.inject(:+)\n puts \"You have #{player_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{p_score}\"\n puts \"The computer has #{computer_hand[1].face}#{computer_hand[1].suit} & [#]\"\n puts \" \"\n end",
"def remaining_pints\n ((current_weight-14.25)/0.45).to_i > 0 ? ((current_weight-14.25)/0.45).to_i : 0\n end"
] | [
"0.7092059",
"0.702379",
"0.689563",
"0.6800404",
"0.6776867",
"0.6775392",
"0.67534953",
"0.67503077",
"0.6670954",
"0.6640104",
"0.66092175",
"0.6577457",
"0.65701336",
"0.65369356",
"0.65296155",
"0.6514623",
"0.64995784",
"0.64392304",
"0.641659",
"0.63874984",
"0.6370802",
"0.6344733",
"0.63382715",
"0.6326267",
"0.6325582",
"0.63227034",
"0.63140017",
"0.62923634",
"0.62912846",
"0.62890613",
"0.6286246",
"0.62799716",
"0.62624633",
"0.62510276",
"0.6224721",
"0.62082547",
"0.6183798",
"0.61830235",
"0.61817586",
"0.61767185",
"0.6169117",
"0.6159837",
"0.61275387",
"0.6113524",
"0.60971195",
"0.6079056",
"0.6033225",
"0.603068",
"0.60261184",
"0.60127586",
"0.60080683",
"0.59950686",
"0.5983121",
"0.59725803",
"0.59659415",
"0.59609973",
"0.59414524",
"0.5937392",
"0.59328115",
"0.59305155",
"0.5913565",
"0.59102803",
"0.58882385",
"0.58834773",
"0.58828616",
"0.5875626",
"0.5872545",
"0.58699495",
"0.5861518",
"0.5854241",
"0.58536553",
"0.5849343",
"0.5848795",
"0.5846009",
"0.58378905",
"0.5828245",
"0.5813774",
"0.58113223",
"0.5801246",
"0.57989866",
"0.5794947",
"0.5787551",
"0.57836086",
"0.5779677",
"0.57775605",
"0.5775023",
"0.57721394",
"0.57690495",
"0.5768445",
"0.5758378",
"0.5748547",
"0.57467616",
"0.5740071",
"0.5738628",
"0.5736168",
"0.57327145",
"0.57317334",
"0.5728308",
"0.5725266",
"0.5723866"
] | 0.7519934 | 0 |
end of add dealer's hand This method returns sum of dealer's best total | def determine_dealers_best_total
# @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']
# @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']
# @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']
# @dealer_hand = ['king of hearts', '6 of diamonds']
sum_of_dealers_hand = 0
number_of_aces_in_hand = 0
@dealer_hand.each {|x| # begin loop adding dealers hand
card_value = @deckhash.fetch(x)
if card_value == 1 then # adjust aces to a value of 11
card_value = 11
number_of_aces_in_hand = number_of_aces_in_hand + 1
end
sum_of_dealers_hand = sum_of_dealers_hand + card_value
} #end of loop adding dealers hand
if sum_of_dealers_hand > 21 then # must set one or more aces back to one
loop do
if number_of_aces_in_hand == 0 then break end
sum_of_dealers_hand = sum_of_dealers_hand - 10
if sum_of_dealers_hand < 22 then break end
number_of_aces_in_hand = number_of_aces_in_hand - 1
end #end of loop do
end #end of sum_of_dealers_hand > 21
# $stdout.write("Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \n")
# ### this method returns of the dealer's best hand'
sum_of_dealers_hand = sum_of_dealers_hand + 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end",
"def dealer_score\n dealer_hand.inject(0){|sum,n| sum + n.value }\n end",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def getDealTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $dealerCards.length\n\t\tx = $dealerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def total_high\n if is_soft\n return total[1]\n end\n return total\n end",
"def houseRobber(arr)\n \toldBest = 0\n \tnewBest = 0\n \tsteal = 0\n\n \tfor loot in arr\n \t\tsteal = loot + oldBest\n \t\toldBest = newBest\n \t\tnewBest = [steal,oldBest].max \n \tend\n \n return newBest\nend",
"def total_score\n\t\tall_scores = picks.collect { |pick|\n\t\t\tpicks_golfers = TournamentGolfer.where(golfer_id: pick.golfer_id, tournament_id: pick.pool.tournament_id).pluck(:total)[0]\n\t\t} - [nil] - [\"CUT\"]\n\t\tif all_scores.count < 5\n\t\t\treturn \"DQ\"\n\t\telse \n\t\t\tall_scores = all_scores.map {|score| score.to_i}\n\t\t\tall_scores = all_scores.sort\n\t\t\treturn all_scores[0..(pool.number_golfers_for_scoring-1)].sum\n\t\tend\n\tend",
"def dealer_round (dealer_cards, dealer_total, deck)\n puts \"Now it's the dealer's turn to play...\"\n dealer_total = total(dealer_cards, dealer_total)\n while dealer_total <= 17\n puts \"Dealing another card...\"\n dealer_cards << deal_cards(1,deck)\n value_string = dealer_cards.last.last[1]\n puts \"Dealer has been dealt a #{value_string}.\"\n dealer_total += get_int_value(value_string, dealer_total)\n puts \"New dealer total: #{dealer_total}\"\n end\n dealer_total\nend",
"def get_dealer_total(dealer_hand,dealer_turn)\n\tdealer_total = 0\t# Total value of dealer's visible cards\n\n\tif !dealer_turn\n\t\tdealer_total = $cards[dealer_hand[0]]\n\telse\n\t\tfor i in 0 .. dealer_hand.length - 1\n\t\t\tdealer_total += $cards[dealer_hand[i]]\n\t\tend\n\tend\n\treturn dealer_total\nend",
"def min_next_bid_amount\n highest_bid_value = self.highest_bid.bid_amount \n if highest_bid_value.present? \n highest_bid_value+highest_bid_value*0.05\n else\n self.cost\n end\n end",
"def getMoneySpent(keyboards, drives, budget)\n #\n # Write your code here.\n #\n highest_combination = -1\n keyboards.each do |keyboard|\n drives.each do |drive|\n sum = keyboard + drive\n highest_combination = sum if sum <= budget && sum > highest_combination\n end\n end\n highest_combination;\nend",
"def cost \n\n \[email protected](0) do |sum,hm|\n \t\tsum+=hm \n end\n puts total\n end",
"def total_earnings\n # pull all trips from driver\n driver_trips = self.trips\n # driver.trips\n # iterate and determine total for each trip grab the total cost and do math\n trips_total_cost = 0\n driver_trips.each do |trip|\n if trip.cost != nil\n trips_total_cost += ((trip.cost - (1.65*100))*0.8)\n end\n end\n \n trips_total_cost /= 100\n trips_total_cost.round(2)\n return trips_total_cost\n end",
"def amt_per_driver(red)\nsum_array = []\nnames_array = []\n red.each do |key,value|\n sum = 0\n value.each do |hash|\n sum += hash.fetch(:\"cost\")\n end\n puts \"Driver #{key} has earned $#{sum}.\"\n sum_array << sum\n names_array << key\n end\nr = sum_array.max\nwinner = names_array[sum_array.find_index(r)]\nreturn winner\nend",
"def driver_with_cash(total_earned)\n return total_earned.max_by { |driver_earning| driver_earning[:amount]}\nend",
"def baserunning_total\n self.rating_15 + \n self.rating_16 +\n self.rating_17 +\n self.rating_18\n end",
"def cost \n return @extra_cost + @basic_drug.cost\n end",
"def de_total\n @printer << \"Dealer has #{session[:dealer].hand_total}\" if !session[:dealer].blackjack?\n @printer << \"Dealer busts!\" if session[:dealer].bust? \n if session[:dealer].blackjack?\n @printer << \"Dealer has BlackJack.\"\n session[:player].make_unlucky\n end\n nil\n end",
"def update_best\n if @best_price < @ep.max\n @best_price = @ep.max\n res_i = @ep.index(@best_price)\n @best_weight = @bw[res_i]\n @best_baggage = in_bag(@cg[res_i])\n end\n end",
"def total_charged\n return self.trips.sum(&:cost)\n end",
"def biggest_investment()\n funding_rounds = self.funding_rounds.select {|funding| funding.amount}\n amount = 0\n\n funding_rounds.select do |funding|\n\n if funding.amount >= amount\n amount = funding.amount\n funding\n end\n \n end\n end",
"def total_cost\n @meal_cost + @tip_amount\n end",
"def highest_earned(drivers)\n max = 0\n highest_driver = \"\"\n\n drivers.each do |driver|\n sum = 0\n\n driver[:trips].each do |trip|\n sum += trip[:cost]\n #----> TEST: puts \"current: #{driver[:driver_id]} and #{sum}\"\n end\n\n if max < sum\n max = sum\n highest_driver = driver[:driver_id]\n end\n\n end\n\n puts \"#{highest_driver} earned the most with $#{max}.\"\nend",
"def cost \n return @extra_cost + @basic_booking.cost\n end",
"def cost \n return @extra_cost + @basic_booking.cost\n end",
"def computeTotal\n # get rule for total\n rule = @rules.find{ |obj| obj.getCode == \"total\" } \n # sum item prices\n total = @items.inject(0){|sum, x| sum + x.getPrice} \n # if rule exists and condition is met, apply discount\n if rule && total > rule.getThreshold \n total = rule.getPercent ? total * (1-rule.getValue) : total - rule.getValue\n end\n return total\n end",
"def highest_options_sum\n possibilities = possibilites_matrix\n ( highest_total, highest_possibilities ) = highest_possibility_price( possibilities )\n highest_total\n end",
"def total_cost\n @cost + tip\n end",
"def cost\n return @extra_cost + @basic_booking.cost\n end",
"def penalty_total\n self.added_penalties.each{|added_penalty| self.calculate_penalties if added_penalty.count_generated_at < MyDate::today}\n if self.added_penalties == []\n return\n elsif self.added_penalties[0].sum == 0\n return\n else\n self.added_penalties[0].sum\n end\n end",
"def deductible_points_for_this_(total)\n max = self.deductible_points\n total > max ? max : total\n end",
"def determine_players_best_total(current_player)\n # @player1_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n sum_of_players_hand = 0\n number_of_aces_in_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n\n sum_of_players_hand = sum_of_players_hand - 10\n\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 1\n\n if current_player == 2 then\n @player2_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 2\n\n if current_player == 3 then\n @player3_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 3\n\n if current_player == 4 then\n @player4_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 4\n # ### This method returns sum of player's best hand\n return sum_of_players_hand\n end",
"def total\n base_query.sum('max_candidates')\n end",
"def total_cost\n [executor_cost, team_lead_cost, account_manager_cost].compact.inject(&:+)\n end",
"def calc_total_cost()\n\t\ttotal_cost = @cost.to_i * 0.9\n\tend",
"def optimize(weight)\r\n return 0 if weight <= 0\r\n\r\n best = nil\r\n $items.each do |item|\r\n c = optimize(weight - item.weight) + item.cost\r\n best = c if best.nil? || c < best\r\n end\r\n best\r\nend",
"def cost\r\n\t\treturn @extra_cost + @real_need.cost\r\n\tend",
"def update_total\n self.total = self.shipments.map(&:item_cost).sum\n end",
"def money_earned_by_driver(driver)\n sum = 0.0\n\n driver.each do |money|\n earned = money[:cost]\n sum += earned.round(2)\n end\n\n return sum\nend",
"def total_drinking\n breast_feedings.sum(:quantity)\n end",
"def most_money(rideshare)\n highest_earned = 0.0\n high_earner = \"\"\n # call method from #2\n money_made(rideshare).map do |driver, cost|\n if cost > highest_earned\n highest_earned = cost\n high_earner = driver\n end\n end\n return high_earner\nend",
"def total_fuel_cost\n self.inject(0) do |accum,trip|\n accum += trip.fuel_cost_usd\n accum\n end\n end",
"def get_total_expense\n\t\tbills.pluck(:amount).inject(:+) rescue 0\n\tend",
"def spread\n best_ask.fetch(:price) - best_bid.fetch(:price)\n end",
"def getMoneySpent(keyboards, drives, b)\n arrK = keyboards.sort.reverse\n arrD = drives.sort.reverse\n\n return -1 if keyboards.length == 1 && drives.length == 1 && (keyboards.sum + drives.sum) > b\n\n max = 0\n arrK.each do |k|\n arrD.each do |d|\n sum = k + d\n max = sum if sum <= b && sum > max\n end\n end\n\n max\nend",
"def total_cost\n lifter_membership.reduce(0){ |total, pay| \n total + pay.cost}\n end",
"def getMoneySpent(keyboards, drives, b)\n\n# pair_sum stores the possible pair prices\n pair_sum= []\n \n# The product method does the combining for us \n combinations = keyboards.product(drives)\n \n# Then we reduce(:+) each pair subarray and push it to the sum array if it's not above our budget\n combinations.each { |pair| pair_sum << pair.reduce(:+) if pair.reduce(:+) <= b } \n\n# Finally we return -1 if the sum array is empty, meaning all pairs are above budget.\n# Otherwise we return the max\n pair_sum.empty? ? -1 : pair_sum.max\nend",
"def total_cost\n \tingredients_cost + components_cost\n end",
"def total_cost\n ingredients_cost + components_cost\n end",
"def total\n sum = 0\n hand.each do |card|\n sum += card.find_face_value\n end\n sum = correct_for_aces(sum)\n end",
"def profit_calculation\r\n @total_profit = @cocktail_profit + @beer_profit + @water_profit\r\n end",
"def initial_round\n total = deal_card + deal_card\n display_card_total(total)\n return total\nend",
"def max_duffel_bag_value(cake_arrays, weight_capacity)\n value = 0\n remaining_capacity = weight_capacity\n cake_arrays.sort_by! { |arr| arr[1] / arr[0] }\n cake_arrays.reverse!\n cake_arrays.each do |arr|\n number_fit = remaining_capacity / arr[0]\n\n remaining_capacity -= (number_fit * arr[0])\n value += (number_fit * arr[1])\n # return value if remaining_capacity == 0\n end\n value\nend",
"def deal_and_total(name, hand_array, deck_hash)\n read_hand(name, hand_array, deck_hash)\n new_hand_value = sum_cards(hand_array, deck_hash)\nend",
"def total\n return (@listOfItem.inject(0){|sum,e| sum += e.total}).round_to(2)\n end",
"def profit(retailer)\n begin\n (self.line_items.collect {|line_item| line_item.profit(retailer) }).sum\n rescue\n 0\n end\n end",
"def sum\n return chosen_options.collect(&:price).sum\n end",
"def cost\r\n 0\r\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def calc_return(total, pool, commission)\n if pool == 0\n return 0\n elsif total == 0\n return ( pool - (pool*commission) ) \n else\n return ( pool - (pool*commission) ) / total.to_f\n end\n end",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def store_credit_maximum_amount\n item_total\n end",
"def final_total\n fees = [ticket_fees_in_cents, delivery_fee_in_cents].sum\n reductions = [reduction_code_credit_total].sum\n\n discounted_total + fees - reductions\n end",
"def get_alternative_total_score()\n # TODO The method get_total_score() above does not seem correct. Replace with this method.\n total_score = 0\n\n self.scores.each { |score| total_score = total_score + score.score }\n\n total_score\n end",
"def calc_total_weight\n 0\n end",
"def initial_round\n total = deal_card + deal_card\n display_card_total(total)\n total\nend",
"def store_credit_maximum_amount\n item_total - 0.01\n end",
"def benefits_transfers\n self.offers_as_seller.accepted.inject(0) {|sum, offer| sum += offer.pay}\n end",
"def profitability\n # based on \n # @pools.map { |p| }.sum\n end",
"def cost\n @beverage.cost + 0.20\n end",
"def hitting_total\n self.rating_19 +\n self.rating_20 +\n self.rating_21 +\n self.rating_22 +\n self.rating_23 +\n self.rating_24 +\n self.rating_25 +\n self.rating_26 +\n self.rating_27\n end",
"def cost\n @beverage.cost + 0.15\n end",
"def remaining_total\n total\n end",
"def total_worth\n find_amount = funding_rounds.map{|funding| funding.investment}\n find_amount.inject{|sum, el| sum + el}\n end",
"def total_points\n if self.has_paid?\n sum = 0\n self.bets.each { |b| sum+=b.points }\n self.answers.each { |a| sum+=a.points }\n sum\n else\n -1\n end\n end",
"def highest_total_score\n @game_manager.highest_total_score\n end",
"def throwing_total\n self.rating_1 +\n self.rating_2 +\n self.rating_3 +\n self.rating_4 +\n self.rating_5\n end",
"def cost(recalculate=false)\n ((!recalculate && super()) || (line_items.map(&:cost).sum + postage_cost.try(:cost).to_i))-gift_card_value\n end",
"def cost\n @beverage.cost + 0.10\n end",
"def cost\n @beverage.cost + 0.10\n end",
"def earnings\n drivers_trips = self.all(id: params[:id].to_i)\n fee = drivers_trips.length * 1.65 #a fee is subtracted for each trip, multiplied by total trips\n gross_earnings = drivers_trips.cost.reduce(:+) - fee\n net_earnings = gross_earnings * 0.80\n\n return net_earnings\n end",
"def cost\n\t\treturn @extra_cost + @real_donation.cost\n\tend",
"def sell_bonus\n bonus = 0.0\n battle_members.each { |member| bonus += member.sell_bonus }\n bonus\n end",
"def max_buy\r\n max = $game_party.max_item_number(@item) - $game_party.item_number(@item)\r\n buying_price == 0 ? max : [max, money / buying_price].min\r\n end",
"def results\n\t\t# reset totals\n\t\t@dealer_total = 0\n\t\t@player_total = 0\n\t\t# display results\n\t\tputs \"\\nDEALER:\\n-------\"\n\t\tif @player_done.nil?\n\t\t\tputs \"/// hidden card ///\"\n\t\t\tcard = @dealer_hand[1]\n\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t@dealer_total += card.value\n\t\telse\n\t\t\t@dealer_hand.each do |card|\n\t\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t\t@dealer_total += card.value\n\t\t\tend\n\t\tend\n\t\tputs \"---> TOTAL (#{@dealer_total})\"\n\t\tputs \"\\nPLAYER:\\n-------\"\n\t\t@player_hand.each do |card|\n\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t@player_total += card.value\n\t\tend\n\t\tputs \"---> TOTAL (#{@player_total})\"\n\t\tprint \"\\nYou have #{@player_total}. \"\n\t\t# determine how to proceed based on totals\n\t\tif @player_total == 21\n\t\t\tputs \"BLACKJACK!! You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif @player_total > 21\n\t\t\tputs \"BUST!! You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total == 21\n\t\t\tputs \"Dealer has BLACKJACK. You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total > 21\n\t\t\tputs \"Dealer BUSTS. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif (@dealer_total < @player_total && @player_total <= 21) && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif (@dealer_total > @player_total && @player_total <= 21) && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total == 21 && @player_total == 21\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif @dealer_total == @player_total && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telse\n\t\t\tself.hit_or_stand?\n\t\tend\n\t\tputs \"Score:\"\n\t\tputs \"Player: #{player_wins} --- Dealer: #{dealer_wins}\"\n\t\t# prompt to start new game or end\n\t\tself.continue?\n\tend",
"def cost\n\t\treturn @extra_cost + @real_shake.cost\n\tend",
"def reward\n -queue.sum.to_f if feasible?\n end",
"def sum_eft_amount (opt=true)\n total_eft_amt = 0\n if @client.name.upcase == \"GOODMAN CAMPBELL\"\n @checks.each do |check|\n if check.payment_method == 'EFT'\n get_gcbs_insurance_eobs(check)\n check_amount = complete_check_amount_condition ? check.check_amount.to_f : check.eob_amount_calculated(@eobs, @nextgen_insurance)\n total_eft_amt += check_amount.to_f\n else\n total_eft_amt += 0.00\n end\n end\n @total_eft_amount = @total_eft_amount + total_eft_amt if opt\n else\n @checks.each do |check|\n if check.payment_method == 'EFT'\n total_eft_amt += check.check_amount.to_f\n else\n total_eft_amt += 0.00\n end\n end\n @total_eft_amount = @total_eft_amount + total_eft_amt if opt\n end\n total_eft_amt\n end",
"def play_as_dealer(deck)\r\n if value < 17\r\n hit!(deck)\r\n play_as_dealer(deck)\r\n else\r\n puts \"Dealer Total is #{value}\"\r\n end\r\n end",
"def profit\n return 0.0 unless self.deliverables.size > 0\n \n # Covers fixed and percentage profit though the +profit+ method being overloaded on the Deliverable types\n return self.deliverables.collect(&:profit).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0\n end",
"def compute(object)\n @seller = self.calculable.seller if self.calculable && self.calculable.respond_to?(:seller)\n weight = object.weight(@seller)\n # find weight range\n arr = JSON.parse(preferred_interval)\n # sort by inerval from smalles to biggest\n arr = arr.to_enum.sort_by {|x| x['int']}\n arr.each do |h|\n if weight.to_f < h['int'].to_f\n cost = h['cost'].to_f\n break\n end\n end\n # if not find range - maximum cost\n cost = arr.map {|x| x['cost']}.max.to_f unless cost\n cost\n end",
"def best_bid\n @bids.max_by { |x| x.fetch(:price) }\n end",
"def max_buy\n max = $game_party.max_item_number(@item) - $game_party.item_number(@item) \n max_crafts = HudellBazaar::get_max_crafts(@item)\n max = [max, max_crafts].min\n\n buying_price == 0 ? max : [max, money / buying_price].min\n end",
"def highest_total_score\n total_goals.max\n end",
"def profit\n \tself.bid - self.payout\n end",
"def fitness\n if dog_count == 0 || cat_count == 0 || mouse_count == 0\n return 0;\n end\n count_error = (100 - total_count).abs\n amount_error = (100 - total_cost).abs\n if count_error > 50 || amount_error > 50\n return 0\n else\n return 100 - (count_error + amount_error) \n end\n end",
"def get_hand_sum(curr_hand) \n curr_hand.inject(0) { |sum, card| sum + card }\n end",
"def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end",
"def initial_round\n card_total = deal_card + deal_card\n display_card_total(card_total)\n card_total\nend",
"def potential_revenue\n @inventory.inject(0) do |total, inventory|\n total += inventory.first.price * inventory.last\n end\n end"
] | [
"0.73483783",
"0.70323396",
"0.6732792",
"0.67178863",
"0.6560544",
"0.6409373",
"0.6403011",
"0.6392923",
"0.63879514",
"0.63788706",
"0.6357766",
"0.6295152",
"0.6250366",
"0.6207558",
"0.6176634",
"0.6168933",
"0.6111468",
"0.6110106",
"0.6106015",
"0.6066673",
"0.60666347",
"0.6065239",
"0.60606706",
"0.6047404",
"0.6047404",
"0.6042318",
"0.6016575",
"0.6009021",
"0.60075647",
"0.60020477",
"0.59883124",
"0.5981699",
"0.5979151",
"0.5974761",
"0.5965988",
"0.596489",
"0.5962855",
"0.5952457",
"0.5948619",
"0.5944334",
"0.59404343",
"0.5927827",
"0.59200615",
"0.5920024",
"0.591649",
"0.59099394",
"0.59093076",
"0.5903563",
"0.5894777",
"0.58891004",
"0.5876738",
"0.5876662",
"0.5869157",
"0.5863306",
"0.5858103",
"0.58542734",
"0.5853093",
"0.58514893",
"0.5848496",
"0.58456147",
"0.58426553",
"0.5833398",
"0.5833313",
"0.5831095",
"0.58293295",
"0.58265096",
"0.58201563",
"0.5817908",
"0.581646",
"0.58139443",
"0.58124846",
"0.5805128",
"0.58021426",
"0.5799191",
"0.5796391",
"0.5791907",
"0.57914954",
"0.57902586",
"0.5785096",
"0.5785096",
"0.5783449",
"0.5780474",
"0.57765007",
"0.57757694",
"0.5774665",
"0.5774163",
"0.57728803",
"0.5772467",
"0.5771472",
"0.577102",
"0.57709694",
"0.57577515",
"0.57505405",
"0.5747216",
"0.57461417",
"0.57421845",
"0.5738901",
"0.5736433",
"0.5726602",
"0.5723232"
] | 0.72417325 | 1 |
end of determine dealers best total Method to sum players to the best total(to account for aces) This method returns sum of player's best hand | def determine_players_best_total(current_player)
# @player1_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']
# @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']
# @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']
sum_of_players_hand = 0
number_of_aces_in_hand = 0
if current_player == 1 then
@player1_hand.each {|x| #begin loop adding players hand
card_value = @deckhash.fetch(x)
if card_value == 1 then #adjust aces to a value of 11
card_value = 11
number_of_aces_in_hand = number_of_aces_in_hand + 1
end #end of ace adjustment
sum_of_players_hand = sum_of_players_hand + card_value
} #end of loop adding players hand
if sum_of_players_hand > 21 then #must set one or more aces back to one
loop do
if number_of_aces_in_hand == 0 then break end
sum_of_players_hand = sum_of_players_hand - 10
if sum_of_players_hand < 22 then break end
number_of_aces_in_hand = number_of_aces_in_hand - 1
end #end of loop do
end #end of sum_of_players_hand > 21
end #end if current player = 1
if current_player == 2 then
@player2_hand.each {|x| #begin loop adding players hand
card_value = @deckhash.fetch(x)
if card_value == 1 then #adjust aces to a value of 11
card_value = 11
number_of_aces_in_hand = number_of_aces_in_hand + 1
end #end of ace adjustment
sum_of_players_hand = sum_of_players_hand + card_value
} #end of loop adding players hand
if sum_of_players_hand > 21 then #must set one or more aces back to one
loop do
if number_of_aces_in_hand == 0 then break end
sum_of_players_hand = sum_of_players_hand - 10
$stdout.write("sum of players hand #{sum_of_players_hand} :")
if sum_of_players_hand < 22 then break end
number_of_aces_in_hand = number_of_aces_in_hand - 1
end #end of loop do
end #end of sum_of_players_hand > 21
end #end if current player = 2
if current_player == 3 then
@player3_hand.each {|x| #begin loop adding players hand
card_value = @deckhash.fetch(x)
if card_value == 1 then #adjust aces to a value of 11
card_value = 11
number_of_aces_in_hand = number_of_aces_in_hand + 1
end #end of ace adjustment
sum_of_players_hand = sum_of_players_hand + card_value
} #end of loop adding players hand
if sum_of_players_hand > 21 then #must set one or more aces back to one
loop do
if number_of_aces_in_hand == 0 then break end
sum_of_players_hand = sum_of_players_hand - 10
# $stdout.write("sum of players hand #{sum_of_players_hand} :")
if sum_of_players_hand < 22 then break end
number_of_aces_in_hand = number_of_aces_in_hand - 1
end #end of loop do
end #end of sum_of_players_hand > 21
end #end if current player = 3
if current_player == 4 then
@player4_hand.each {|x| #begin loop adding players hand
card_value = @deckhash.fetch(x)
if card_value == 1 then #adjust aces to a value of 11
card_value = 11
number_of_aces_in_hand = number_of_aces_in_hand + 1
end #end of ace adjustment
sum_of_players_hand = sum_of_players_hand + card_value
} #end of loop adding players hand
if sum_of_players_hand > 21 then #must set one or more aces back to one
loop do
if number_of_aces_in_hand == 0 then break end
sum_of_players_hand = sum_of_players_hand - 10
# $stdout.write("sum of players hand #{sum_of_players_hand} :")
if sum_of_players_hand < 22 then break end
number_of_aces_in_hand = number_of_aces_in_hand - 1
end #end of loop do
end #end of sum_of_players_hand > 21
end #end if current player = 4
# ### This method returns sum of player's best hand
return sum_of_players_hand
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end",
"def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end",
"def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def dealer_score\n dealer_hand.inject(0){|sum,n| sum + n.value }\n end",
"def total_score\n\t\tall_scores = picks.collect { |pick|\n\t\t\tpicks_golfers = TournamentGolfer.where(golfer_id: pick.golfer_id, tournament_id: pick.pool.tournament_id).pluck(:total)[0]\n\t\t} - [nil] - [\"CUT\"]\n\t\tif all_scores.count < 5\n\t\t\treturn \"DQ\"\n\t\telse \n\t\t\tall_scores = all_scores.map {|score| score.to_i}\n\t\t\tall_scores = all_scores.sort\n\t\t\treturn all_scores[0..(pool.number_golfers_for_scoring-1)].sum\n\t\tend\n\tend",
"def add_players_lowest_hand(current_player)\n sum_of_players_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 1\n if current_player == 2 then\n @player2_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 2\n if current_player == 3 then\n @player3_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 3\n if current_player == 4 then\n @player4_hand.each {|x|\n card_value = @deckhash.fetch(x)\n sum_of_players_hand = sum_of_players_hand + card_value\n # $stdout.write(\"Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \\n\")\n }\n end #end if current player = 4\n# ### This method returns sum of player's hand\n return sum_of_players_hand\n end",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def sum_player_hand(player_hand)\n player_hand.reduce(:+)\n end",
"def get_player_total(player_hand)\n\tplayer_total = 0 \t\t# Total value of player's hand\n\n\tfor i in 0..player_hand.length - 1\n\t\tplayer_total += $cards[player_hand[i]]\n\tend\n\treturn player_total\nend",
"def getDealTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $dealerCards.length\n\t\tx = $dealerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend",
"def total\n sum = 0\n hand.each do |card|\n sum += card.find_face_value\n end\n sum = correct_for_aces(sum)\n end",
"def hand_total(hand) \n\n #A flag to see if the hand contains an ace\n have_ace = ! ( session[hand].select{|card| card['rank'] == \"ace\"}.empty? ) \n\n total = 0 \n\n #Look up the point value of each card in the hand\n session[hand].each do |card|\n total += RANK_TO_POINTS[ card['rank']]\n end\n \n #Convert from hard (ace=1) to a soft (ace=11) \n #score if hand contains an ace\n #and it won't cause the hand to bust\n if (total <= 11 && have_ace) then total += 10 end \n\n return total \n\n end",
"def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end",
"def player1_score\n player_hand.inject(0){|sum,n| sum + n.value }\n end",
"def total_score\n total = 0\n @cards.each do |card|\n total += card.value\n end\n\n sorted_cards = @cards.sort\n\n straights = get_straight(sorted_cards).reverse\n straights.each do |straight|\n total += 40\n sorted_cards.slice!(straight[0]..straight[1])\n end\n\n three_cards = get_number_of_a_kind(sorted_cards, 3)\n three_cards.each do |three|\n total += 20\n sorted_cards.slice!(three[0]..three[1])\n end\n\n pairs = get_number_of_a_kind(sorted_cards, 2)\n pairs.each do |pair|\n total += 10\n sorted_cards.slice!(pair[0]..pair[1])\n end\n\n total\n end",
"def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end",
"def compute_sum_for player\r\n if player == nil || player[:cards] == nil || player[:cards].length == 0\r\n return 0\r\n end\r\n \r\n #Compute initial points\r\n sum = 0\r\n i = 0\r\n \r\n while i < player[:cards].length\r\n card = player[:cards][i]\r\n sum = sum + (card[:face] > 10 ? 10 : ((card[:face] == 1)? 11 : card[:face]))\r\n\ti = i + 1\r\n end\r\n \r\n #Fix the sum if possible, when the points is larger than 21\r\n j = player[:cards].length - 1\r\n while sum > 21 && j >= 0\r\n\tcard = player[:cards][j]\r\n\tif card[:face] == 1 #There is an Ace\r\n\t sum = sum - 11 + 1\r\n\tend\r\n\tj = j - 1\r\n end\r\n\t\r\n sum\r\nend",
"def best_total_score\n options = {\n :select => 'sum(players.score) as field',\n :order => 'field DESC'\n }\n\n render_users params[:name], options\n end",
"def get_dealer_total(dealer_hand,dealer_turn)\n\tdealer_total = 0\t# Total value of dealer's visible cards\n\n\tif !dealer_turn\n\t\tdealer_total = $cards[dealer_hand[0]]\n\telse\n\t\tfor i in 0 .. dealer_hand.length - 1\n\t\t\tdealer_total += $cards[dealer_hand[i]]\n\t\tend\n\tend\n\treturn dealer_total\nend",
"def current_total_amount\n\n if calculate_total(session[:player_cards]).to_i == BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:player_cards]).to_i > BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:dealer_cards]).to_i > BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i == BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:player_cards]).to_i > calculate_total(session[:dealer_cards]).to_i\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i > calculate_total(session[:player_cards]).to_i\n session[:player_pot] -= session[:player_bet].to_i \n else\n session[:player_pot]\n end # ends if statement\n end",
"def calcScore(hand)\n return hand.inject(0) { |sum, n| sum + n.points }\nend",
"def show_hands\n player_final_value = player_hand.reduce(:+)\n dealer_final_value = dealer_hand.reduce(:+)\n puts \"Player has a total of #{player_final_value}. Dealer has a total of #{dealer_final_value}\"\n if player_final_value > dealer_final_value\n puts \"You win, congrats on beating a program built by a novice.\"\n else\n puts \"I have bested you.\"\n end\n end",
"def results\n\t\t# reset totals\n\t\t@dealer_total = 0\n\t\t@player_total = 0\n\t\t# display results\n\t\tputs \"\\nDEALER:\\n-------\"\n\t\tif @player_done.nil?\n\t\t\tputs \"/// hidden card ///\"\n\t\t\tcard = @dealer_hand[1]\n\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t@dealer_total += card.value\n\t\telse\n\t\t\t@dealer_hand.each do |card|\n\t\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t\t@dealer_total += card.value\n\t\t\tend\n\t\tend\n\t\tputs \"---> TOTAL (#{@dealer_total})\"\n\t\tputs \"\\nPLAYER:\\n-------\"\n\t\t@player_hand.each do |card|\n\t\t\tputs \"#{card.face} of #{card.suit} (#{card.value})\"\n\t\t\t@player_total += card.value\n\t\tend\n\t\tputs \"---> TOTAL (#{@player_total})\"\n\t\tprint \"\\nYou have #{@player_total}. \"\n\t\t# determine how to proceed based on totals\n\t\tif @player_total == 21\n\t\t\tputs \"BLACKJACK!! You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif @player_total > 21\n\t\t\tputs \"BUST!! You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total == 21\n\t\t\tputs \"Dealer has BLACKJACK. You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total > 21\n\t\t\tputs \"Dealer BUSTS. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif (@dealer_total < @player_total && @player_total <= 21) && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif (@dealer_total > @player_total && @player_total <= 21) && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You lost.\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.dealer_wins += 1\n\t\telsif @dealer_total == 21 && @player_total == 21\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telsif @dealer_total == @player_total && !(@player_done.nil?)\n\t\t\tputs \"Dealer has #{@dealer_total}. You win!\"\n\t\t\tputs \"*******************************************\"\n\t\t\tself.player_wins += 1\n\t\telse\n\t\t\tself.hit_or_stand?\n\t\tend\n\t\tputs \"Score:\"\n\t\tputs \"Player: #{player_wins} --- Dealer: #{dealer_wins}\"\n\t\t# prompt to start new game or end\n\t\tself.continue?\n\tend",
"def total\n calculate_hand_totals\n if @hand.empty?\n puts \"Your hand is empty.\"\n return\n end\n\n puts \"Your hand is #{@hand.to_s}\" \n\n if !in_good_standing?\n puts \"*** YOU LOSE! ***\"\n end\n\n puts \"You have #{@hand_totals.count} possible total(s) with #{@hand_totals.count - 1} Aces:\"\n @hand_totals.each do | total, ace_distrobution |\n if total > 21\n puts \"BUSTED!- #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21 && @hand.count == 2\n puts \"BLACKJACK - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21\n puts \"WINNING HAND - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n else\n puts \"#{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n end\n end\n end",
"def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end",
"def overall_KDR\n overall_deaths = 0\n overall_kills = 0\n @player_champs_list.each do |champ|\n overall_deaths += champ.total_deaths\n overall_kills += champ.total_kills\n end\n overall_deaths > 0 ? (overall_kills.to_f / overall_deaths).round(2) : overall_kills.to_f\n end",
"def pays_players\n self.players.inject(0) {|sum, player| sum += player.pay}\n end",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def get_alternative_total_score()\n # TODO The method get_total_score() above does not seem correct. Replace with this method.\n total_score = 0\n\n self.scores.each { |score| total_score = total_score + score.score }\n\n total_score\n end",
"def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end",
"def getPlayTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $playerCards.length\n\t\tx = $playerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def amt_per_driver(red)\nsum_array = []\nnames_array = []\n red.each do |key,value|\n sum = 0\n value.each do |hash|\n sum += hash.fetch(:\"cost\")\n end\n puts \"Driver #{key} has earned $#{sum}.\"\n sum_array << sum\n names_array << key\n end\nr = sum_array.max\nwinner = names_array[sum_array.find_index(r)]\nreturn winner\nend",
"def calculate_overall_winner\n points_per_player = {}\n @matches.each do | match |\n !points_per_player[match.winner].nil? ? (points_per_player[match.winner] += 1) : (points_per_player[match.winner] = 1)\n end\n max_points = points_per_player.values.max\n points_per_player.key(max_points)\n end",
"def get_hand_sum(curr_hand) \n curr_hand.inject(0) { |sum, card| sum + card }\n end",
"def strength\n players.map{|p| p.strength}.reduce{|sum,n| sum + n}\n end",
"def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end",
"def sum_bets() \n\t\t@sum = 0\n\t\t#loop through players array\n\t\tfor i in 0...@num_players\n\t\t\t@sum += @players[i].bet\n\t\tend\n\t\treturn @sum\n\tend",
"def total_earnings\n # pull all trips from driver\n driver_trips = self.trips\n # driver.trips\n # iterate and determine total for each trip grab the total cost and do math\n trips_total_cost = 0\n driver_trips.each do |trip|\n if trip.cost != nil\n trips_total_cost += ((trip.cost - (1.65*100))*0.8)\n end\n end\n \n trips_total_cost /= 100\n trips_total_cost.round(2)\n return trips_total_cost\n end",
"def highest_options_sum\n possibilities = possibilites_matrix\n ( highest_total, highest_possibilities ) = highest_possibility_price( possibilities )\n highest_total\n end",
"def most_points_scored\n points_scored = 0 # starting score to compare with players shoe sizes\n game_hash.each do |location, team_data| # iterates through each team\n players_array = team_data[:players] # finds the :players info in team_data and puts the players into players_array\n players_array.each do |player_name, data| # iterates through each player..\n if data[:points] > points_scored # if their points scored is greater than 0 (we set this earlier in the top of method)\n points_scored = data[:shoe] # take that players score and make it the new points_scored value\n end # this repeats (iterates) through all players until you don't have any more.. meaning the end result is\n end # the player with the highest score\n end\n return points_scored\nend",
"def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend",
"def score\n p_score = player_hand.collect{|x| x.value}.inject(:+)\n c_score = computer_hand.collect{|x| x.value}.inject(:+)\n puts \"You have #{player_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{p_score}\"\n puts \"The computer has #{computer_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{c_score}\"\n puts \" \"\n end",
"def efp\n top_players.inject(0) { |sum, player| player.efp + sum }\n end",
"def counting_recommended_bet(player)\n count = @shoe.count\n if count <= 1\n bet = player.min_bet\n elsif count <= 10\n bet = player.min_bet + player.betting_unit * count\n else\n bet = player.min_bet + player.betting_unit * 10 + (player.betting_unit * (count/3))\n end\n \"#{player.name}, your recommended bet is $#{bet}. \"\n end",
"def calculate_total(cards_of_player, cards_of_dealer)\n total_points=[]\n total_points[0] = calculate_points(cards_of_player)\n total_points[1] = calculate_points(cards_of_dealer)\n total_points\nend",
"def calculate_total_card_rating(wrestler)\n\t\t\n\t\toc_roll_probability = wrestler.points[:oc_probability]\n\t\tpoints_per_round = calculate_card_points_per_round(wrestler.points)\n\t\tdq_probability_per_round = calculate_dq_probability_per_round(wrestler.points)\n\t\tpa_probability_per_round = calculate_pa_probability_per_round(wrestler.points)\n\t\tsub_probability_per_round = calculate_sub_probability_per_round(wrestler.points)\n\t\txx_probability_per_round = calculate_xx_probability_per_round(wrestler.points)\n\t\t\n\t\t# Double P/A per round and divide XX per round for total card value\n\t\t# to increase relative value of pin attempts.\n\t\ttotal_card_points = (points_per_round / 2) + \n\t\t\t(oc_roll_probability * 10) +\n\t\t\t(dq_probability_per_round * 5) + \n\t\t\t(pa_probability_per_round * 20) +\n\t\t\t(sub_probability_per_round * 10) + \n\t\t\t(xx_probability_per_round * 5)\n\n\t\tsingles_priority = wrestler.points[:prioritys]\n\t\tsubmission_loss_probabilty = wrestler.points[:sub_prob]\n\n\t\ttotal_card_rating = total_card_points + 10 + \n\t\t\tsingles_priority - (submission_loss_probabilty * 10)\n\n\n\t\t@statistics[:total_card_rating] = total_card_rating\n\t\t@statistics[:total_card_points] = total_card_points\n\t\t@statistics[:total_card_points_per_round] = points_per_round\n\t\t@statistics[:dq_probability_per_round] = dq_probability_per_round\n\t\t@statistics[:pa_probability_per_round] = pa_probability_per_round\n\t\t@statistics[:sub_probability_per_round] = sub_probability_per_round\n\t\t@statistics[:xx_probability_per_round] = xx_probability_per_round\n\n\t\treturn total_card_rating\n\tend",
"def calculatetotal(cards) # calculating the total of the two cards dealt, first to player then to dealer\n array = cards.map {|card| card[0]} # using the map method to lay out all the cards which are like so [[\"A\", \"S\"], [\"5\", \"C\"]]\n # We then only take the first element of the array and initialize that to the total\n total = 0 # total at the outset is zero\n array.each do |value|\n if value == \"A\" # in the event you get an ace card. \"A\" is as is unlike the bottom ones below\n total += 11 # total should now increase to 11\n elsif value.to_i == 0 # this is to cover for getting J, K, Q cards which defaults value to integer is zero\n total += 10\n else\n total += value.to_i\n end\nend # finished the array\n\n# Correcting Aces in case there are more than one. It should convert aces to 1 instead of 11 if total is more than 21\narray.select {|card| card.include?(\"A\")}.count.times do\n total -= 10 if total > 21\nend\ntotal # don't forget to include total here before exiting. IMPORTANT!!\nend",
"def best_hand\n @active_players.map do |player|\n # Creates an array storing all possible 5 card combinations.\n @all_combos = (player.hole_cards + @community_cards).combination(5).to_a\n @best_hand = PokerHand.new\n @current_hand = nil\n\n # Loops through every hand combination, comparing the current hand to the best hand. If the current hand is better than the best hand, it becomes the best hand, otherwise it is deleted.\n @all_combos.map do |hand|\n next unless @all_combos.length > 1\n\n @current_hand = PokerHand.new(hand)\n if @current_hand > @best_hand\n @best_hand = @current_hand\n else\n @all_combos.delete(hand)\n end\n end\n\n # After finding the best hand it stores it for the player and outputs it.\n player.strongest_hand = @best_hand\n puts \"#{player.player_name} has #{player.strongest_hand}\"\n sleep(1)\n end\nend",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if @stand\n return tot2\n else\n return [ tot, tot2 ]\n end\n else\n return tot\n end\n end",
"def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend",
"def distribute_money_internal_2(dealer_total, player , hand_index)\n i = hand_index\n dt = dealer_total\n hv = player.get_value(i)\n bet = player.get_bet(i)\n pn = player.player_number\n\n # instead of modifiying amount directly, should use a function call to increment player amount by payoff factor\n if (hv == 21 and (dt > 21 or dt < 21) )\n #player.amount += (bet * 2.5)\n player.modify_account(bet,2.5)\n puts \"Player #{pn} H#{i} #{hv} Blackjack - Dealer #{dt} , Amount= #{player.amount}\"\n elsif (hv < 21 and dt > 21) or (dt <= 21 and hv <= 21 and hv > dt)\n #player.amount += (bet * 2)\n player.modify_account(bet,2)\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n elsif (dt > 21 and hv > 21) or ((hv == 21) and dt == 21 ) or (hv == dealer_total and dt <= 21 and hv <= 21)\n #player.amount += (bet * 1)\n player.modify_account(bet,1)\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n else\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n end\n\n end",
"def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend",
"def highest_total_score\n @game_manager.highest_total_score\n end",
"def calculate_primiera(hand1, hand2)\r\n res = [0,0]\r\n #p hand1\r\n #p hand2\r\n # first get the max card on each suit\r\n max_pt = []\r\n [hand1, hand2].each do |curr_hand|\r\n # reset max\r\n max_pt << {:D => 0, :B => 0, :C => 0, :S => 0 }\r\n curr_hand.each do |lbl|\r\n points = @deck_information.get_card_points(lbl)\r\n suit = @deck_information.get_card_segno(lbl)\r\n if points > max_pt.last[suit]\r\n # max on suit\r\n max_pt.last[suit] = points\r\n end\r\n end\r\n #p max_pt.last\r\n end\r\n # using inject, 0 is the first value of the accumulator sum, tha assume the\r\n # value of the block provided. x assume each value of the max_pt.first\r\n # x becomes a pair like max_pt.first.each{|k,v|}. For example x = [:S, 21]\r\n arr_sum_points = []\r\n max_pt.each do |maxitem|\r\n arr_sum_points << maxitem.inject(0) do |sum, x|\r\n if x[1] > 0 and sum >= 0 \r\n sum + x[1]\r\n else\r\n # this is a particular case, we don't have points on a particular suit\r\n # in this case there is no primiera. Then stay on -1.\r\n sum = -1\r\n end\r\n end\r\n end\r\n #p arr_sum_points\r\n if arr_sum_points[0] > arr_sum_points[1]\r\n #primiera on the first hand\r\n res[0] = 1\r\n res[1] = 0\r\n elsif arr_sum_points[0] == arr_sum_points[1]\r\n # same points, primiera is not assigned\r\n res[0] = 0\r\n res[1] = 0\r\n else\r\n #primiera on the second hand\r\n res[0] = 0\r\n res[1] = 1\r\n end \r\n #p res\r\n return res\r\n end",
"def round()\n\t\t#array of used cards\n\t\t@used = []\n\t\t#loop through players array\n\t\tfor i in 0...@num_players\n\t\t\t#reset player variables\n\t\t\t@players[i].reset()\t\n\t\t\t#populate hand\n\t\t\t@players[i].populate(@used,52,5)\n\t\t\t#get hand rank\n\t\t\t@players[i].get_rank()\n\t\t\t#add hand to array of used cards\n\t\t\t@used += @players[i].hand\n\t\tend\n\t\t#increment round number\n\t\t@roundnum += 1 \n\tend",
"def total_score\n sum = self.games.sum{|game|game.points}\n sum.to_i / self.games.count\n end",
"def score\n total_score = 0\n current_roll = 0\n\n while current_roll < @rolls.size - 1\n roll = @rolls[current_roll]\n next_roll = @rolls[current_roll + 1]\n\n if roll == 10 #strike\n total_score += 10 + @rolls[current_roll + 1] + @rolls[current_roll + 2]\n current_roll += 1\n elsif roll + next_roll == 10 #spare\n total_score += 10 + @rolls[current_roll + 2]\n current_roll += 2\n else #normal players\n total_score += roll + next_roll\n current_roll += 2\n end\n end\n\n return total_score\n end",
"def week_1_total\n total = 0\n rostered_players.each do |rostered_player|\n total += rostered_player.player.week_1_score\n end\n return total\n end",
"def game_score\n previous_hands = self.game_player.hand_players.joins(:hand).where(\n \"hands.position <= ?\", self.hand.position\n )\n gs = 0\n for h in previous_hands\n gs += h.hand_score\n end\n return gs\n end",
"def goals_against()\n\t self.as_regular_contestants.select{|c| c.opponent.score}.collect{|c| c.opponent.score}.inject{|gf, c| gf + c} || 0\n\tend",
"def getMoneySpent(keyboards, drives, budget)\n #\n # Write your code here.\n #\n highest_combination = -1\n keyboards.each do |keyboard|\n drives.each do |drive|\n sum = keyboard + drive\n highest_combination = sum if sum <= budget && sum > highest_combination\n end\n end\n highest_combination;\nend",
"def finish_round!\n raise Exceptions::NoWinner if @players_in_round.nil?\n # The winner is the Player with the highest hand_value.\n @round_winner = @players_in_round.sort_by do |player|\n hand_value(player.hand)\n end.reverse.first\n @round_winner.chips += @pot\n @pot = INITIAL_POT\n end",
"def houseRobber(arr)\n \toldBest = 0\n \tnewBest = 0\n \tsteal = 0\n\n \tfor loot in arr\n \t\tsteal = loot + oldBest\n \t\toldBest = newBest\n \t\tnewBest = [steal,oldBest].max \n \tend\n \n return newBest\nend",
"def deal_and_total(name, hand_array, deck_hash)\n read_hand(name, hand_array, deck_hash)\n new_hand_value = sum_cards(hand_array, deck_hash)\nend",
"def winner\n @players.max_by do |player|\n player.score\n end\n end",
"def most_steals(game)\nmax_steals = 0\nmax_steals_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:steals] == max_steals\n max_steals_player = max_steals_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:steals] > max_steals\n max_steals = player_contents[:steals]\n max_steals_player = player_contents[:player_name]\n end\n end\nend\nmax_steals_player\nend",
"def compute_best_score(team, pilots, pilot_contests)\n combination = []\n total = 0.0\n total_possible = 0\n puts 'compute_score TBD'\nend",
"def lowest_total_score\n total_game_scores = games.map { |game| game.home_goals + game.away_goals}\n total_game_scores.min\n end",
"def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend",
"def money_earned_by_driver(driver)\n sum = 0.0\n\n driver.each do |money|\n earned = money[:cost]\n sum += earned.round(2)\n end\n\n return sum\nend",
"def winner\n @best_hand = {}\n @eg_users.each do |user|\n @usr = user[0]\n @best_hand[@usr] = []\n cards = []\n cards = Array.new(@communal_cards)\n cards << user[1]\n cards << user[2]\n calculate_hand cards\n end\n best_hnd_key = determine_winner\n end",
"def pl_total\n @printer << \"You have #{session[:player].hand_total}\" if !session[:player].blackjack?\n @printer << \"You bust.\" if session[:player].bust?\n if session[:player].blackjack?\n @printer << \"BlackJack!\" \n session[:player].make_lucky\n end\n nil\n end",
"def total\n @frame.inject(0){|rez, item| item ? rez + item[:score] : rez }\n end",
"def total_cost\n [executor_cost, team_lead_cost, account_manager_cost].compact.inject(&:+)\n end",
"def player_round (player_cards, dealer_cards, player_total, player_name, deck)\n # display the first round of cards, only show dealer's top card\n puts \"Welcome, #{player_name}!\"\n puts \"Dealer has: #{dealer_cards[0]} and #{dealer_cards[1]}\"\n puts \"You have: #{player_cards[0]} and #{player_cards[1]}\"\n player_total = total(player_cards, player_total)\n if blackjack(player_total) != true\n puts \"Your total is #{player_total}, would you like to hit or stay? (hit or stay response only allowed)\"\n # add validation for this\n hit_stay = gets.chomp.downcase\n while hit_stay == \"hit\"\n player_cards << deal_cards(1,deck)\n # IMPORTANT: WHY IS EXTRA LAST NECESSARY HERE, EXTRA BLANK ARRAY?\n value_string = player_cards.last.last[1]\n puts \"You've been dealt a #{value_string}.\"\n player_total += get_int_value(value_string, player_total)\n if player_total < 21\n puts \"Your total is now #{player_total}, would you like to hit or stay?\"\n hit_stay = gets.chomp.downcase\n elsif player_total > 21\n hit_stay = \"bust\"\n else\n hit_stay = \"blackjack\"\n end\n end\n end\n player_total\nend",
"def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend",
"def total_cost\n lifter_membership.reduce(0){ |total, pay| \n total + pay.cost}\n end",
"def most_points_scored\nbest_player = \"\"\npoints = 0\ngame_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if stats[:points] > points\n points = stats[:points]\n best_player= name\n end\n end\nend\nbest_player\nend",
"def score\n # make a local array that will disappear when not in this method\n tally = []\n # for each of the cards in the hand, add their score to the tally from points\n @hand.each do |card|\n tally.push(@points[card])\n end\n # return the tally of the scores\n return tally.sum\nend",
"def percent_high_ranking\n number_of_high_cards = self.high_ranking_cards.length.to_f\n number_of_all_cards = self.cards.length.to_f\n\n percentage = number_of_high_cards / number_of_all_cards\n percentage_rounded = (percentage * 100).round(2)\n\n return percentage_rounded\n end",
"def total_score\n @all_games.map do |games|\n games[\"home_goals\"].to_i + games[\"away_goals\"].to_i\n end\n end",
"def scores_update\n # Variable to Hold the Player's Score:\n @players_score = 0\n # Variable to Hold the Dealer's Score:\n @dealers_score = 0\n\n # Player - Different Scenarios for an Ace\n #########################################\n for card in @player.cards\n if card.name == :ace\n # If player's card is an Ace, then increase the player's softhand score by 1.\n @players_softhand += 1\n # If player's card is an Ace and the player's score is greater than 11, then increase the score by 1\n if @players_score >= 11\n @players_score += 1\n\n #Note* Alternatively:\n #@players_score += card.value.last\n else\n # Else increase the score by 11\n @players_score += 11\n #Note* Alternatively:\n #@players_score += card.value.first\n end\n else\n # Else if card isn't an Ace, then increase the value of the score by the cards value.\n @players_score += card.value\n end\n end\n\n # Dealer - Scenario for an Ace\n ##############################\n\n # If player hasn't chosen to stand\n if player_stands == false\n # and If the dealers first card is an Ace\n if @dealer.cards[1].name == :ace\n # then increase the dealer's soft hand score by 1\n @dealers_softhand += 1\n # and increase the dealer's score by 11\n @dealers_score += 11\n else\n # else increase the dealer's score by the value of the card.\n @dealers_score += @dealer.cards[1].value\n end\n\n # Else if Player has chosen to stand, \n else\n # For each of the Dealer's cards\n for card in @dealer.cards\n # If any card is an ace,\n if card.name == :ace\n # Then increase the dealer's softhand score by 1\n @dealers_softhand += 1\n # If player has chosen to stand and if the card is an ace and if the dealer's score is greater than 10,\n if @dealers_score >= 11\n # then increase the dealer's score by one\n @dealers_score += 1\n else\n # else increase the dealer's score by 11.\n @dealers_score += 11\n end\n # Else if the dealer's card is not an Ace, then increase the score by the cards value. \n else\n @dealers_score += card.value\n end\n end\n end\n\n # Dealing with Edge Cases for an Ace Card\n # First 2 Cards are both Aces or one of the first 2 cards is an Ace, but then a resulting value makes the score go over 21\n ######################################\n\n # If player score is greater than 21 and player's softhand is greater than 0, \n if @players_score > 21 && players_softhand > 0\n # then subtract the score by 10 (Difference in value of an Ace.)\n @players_score -= 10\n # and subtract the score of the softhand score by 1.\n @players_softhand -= 1\n end\n\n # If dealer score is greater than 21 and dealer's softhand score is greater than 0, \n if @dealers_score > 21 && dealers_softhand > 0\n # then subtract the dealer's score by 10 (Difference in value of an Ace.)\n @dealers_score -= 10\n # then subtract the dealer's soft hand score by 1.\n @dealers_softhand -= 1\n end\n end",
"def highest_total_score\n total_goals.max\n end",
"def big_shoe_rebounds\n max_shoe = 0 \n max_rebounds = 0 \n game_hash.each do |place, team|\n # team.each do |attribute, data|\n team[:players].each do |player|\n if player[:shoe] > max_shoe\n max_shoe = player[:shoe]\n max_rebounds = player[:rebounds]\n # if attribute == :players\n # data.each do |player|\n #this gives me the player hashes\n # data.max_by{|player| player[:shoe] }\n # data.max_by{|player| player[:shoe] }[:rebounds]\n # player.max_by{|player| player[:shoe] \n # player.max_by{|player| player[:shoe] }[:rebounds]\n end\n end\n end\n return max_rebounds\n end",
"def total_score\n return @plays.reduce(0) { |memo, word| memo + Scrabble::Scoring.score(word) }\n end",
"def total (player=nil, mods=nil)\n player ||= belongs_to_player\n mods ||= modifiers(player)\n base_value + mods\n end",
"def total_score\n rank_items.to_a.sum { |item| item.rank_score * item.weight }\n end",
"def big_shoe_points\n big_shoes_guy = 0\n points = 0\n game_hash.each do | location, attributes|\n attributes[:players].each do |player, stats|\n if stats[:shoe] > big_shoes_guy\n big_shoes_guy = stats[:shoe]\n points = stats[:points]\n end\n end\n end\n points\nend",
"def driver_with_cash(total_earned)\n return total_earned.max_by { |driver_earning| driver_earning[:amount]}\nend",
"def total\n base_query.sum('max_candidates')\n end",
"def total_charged\n return self.trips.sum(&:cost)\n end",
"def detect_result(dealer_hand, player_hand)\n player_total = calculate_total(player_hand)\n dealer_total = calculate_total(dealer_hand)\n\n if player_total > 21\n :player_busted\n elsif dealer_total > 21\n :dealer_busted\n elsif dealer_total < player_total\n :player\n elsif player_total < dealer_total\n :dealer\n else\n :tie\n end\nend",
"def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end",
"def display_final_scores(players)\n\t\tall_scores = []\n\t\tputs \"\\n\\n\"\n\t\tputs \"*\"*20\n\t\tputs \"FINAL SCORES\"\n\t\tplayers.each do |player|\n\t\t\tplayer_score = player.score[:grand_total][:score]\n\t\t\tputs \"\\tPlayer#{player.id}: #{player_score}\"\n\t\t\tall_scores << player_score\n\t\tend\n\t\tmax_score = all_scores.max\n\t\tif all_scores.count(max_score) > 1\n\t\t\tputs \"Its a tie!! Play again to find out clear winner!!\"\n\t\telse\n\t\t\tputs \"Player #{all_scores.index(max_score) + 1} wins!!!! Yay!! Congratulations!!\"\n\t\tend\n\t\t\n\t\tputs \"*\"*20\n\n\tend",
"def card_total(player_or_dealer_array)\n value_array = player_or_dealer_array.map { |v| v[1] }\n card_value_counter = 0\n \n value_array.each do |value|\n if value.is_a? Integer\n card_value_counter += value\n elsif value != 'Ace'\n card_value_counter += 10\n else\n card_value_counter += 11\n end\n end\n \n #decided total based on total number of aces. Will keep adjusting ace value to 1 until the toal is 21 or under\n value_array.select { |v| v == 'Ace'}.count.times do\n card_value_counter -= 10 if card_value_counter > 21\n end\n \n card_value_counter\nend",
"def total_worth\n find_amount = funding_rounds.map{|funding| funding.investment}\n find_amount.inject{|sum, el| sum + el}\n end",
"def hand_score\n score = self.tricks\n if !self.got_set\n score += 10\n end\n return score\n end",
"def net_worth\n result = self.cash_on_hand\n self.holdings.each do |holding|\n share_price = holding.company.share_price\n result += share_price * holding.amount\n end\n @net_worth = result\n end"
] | [
"0.77136475",
"0.742315",
"0.7167293",
"0.7083669",
"0.70728785",
"0.7057982",
"0.6936001",
"0.6885964",
"0.6884353",
"0.6854238",
"0.6812462",
"0.6795545",
"0.6780712",
"0.6778064",
"0.67451924",
"0.66781193",
"0.6651935",
"0.66492975",
"0.6607205",
"0.65959024",
"0.6542137",
"0.6499952",
"0.6499818",
"0.6488213",
"0.6477215",
"0.6476827",
"0.64675653",
"0.64161325",
"0.63962317",
"0.63579214",
"0.6345041",
"0.6344565",
"0.6340013",
"0.6335925",
"0.6293173",
"0.6291008",
"0.6286436",
"0.62696886",
"0.6263861",
"0.6261593",
"0.62451",
"0.62349665",
"0.6206603",
"0.6199094",
"0.61897403",
"0.61528736",
"0.6149831",
"0.6145099",
"0.6139629",
"0.61394185",
"0.6132805",
"0.61288875",
"0.61268014",
"0.61257565",
"0.61118203",
"0.6108686",
"0.6105498",
"0.61046743",
"0.60948145",
"0.6090307",
"0.6088985",
"0.608177",
"0.60754555",
"0.607123",
"0.60629237",
"0.6055519",
"0.6043585",
"0.60216707",
"0.6019969",
"0.6018774",
"0.6006202",
"0.60057974",
"0.6003273",
"0.59931296",
"0.5992373",
"0.5991973",
"0.5985936",
"0.5980991",
"0.59799814",
"0.5977437",
"0.5968331",
"0.5962124",
"0.5957405",
"0.59572005",
"0.5954896",
"0.59518486",
"0.59480834",
"0.5937997",
"0.59369606",
"0.593596",
"0.59293854",
"0.5928486",
"0.59218335",
"0.59215844",
"0.59202",
"0.5917788",
"0.59158486",
"0.5915821",
"0.5914587",
"0.5911939"
] | 0.75809574 | 1 |
end of sum of player's best hand Sum up of all the player's current hand This method returns sum of player's hand | def add_players_lowest_hand(current_player)
sum_of_players_hand = 0
if current_player == 1 then
@player1_hand.each {|x|
card_value = @deckhash.fetch(x)
sum_of_players_hand = sum_of_players_hand + card_value
# $stdout.write("Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \n")
}
end #end if current player = 1
if current_player == 2 then
@player2_hand.each {|x|
card_value = @deckhash.fetch(x)
sum_of_players_hand = sum_of_players_hand + card_value
# $stdout.write("Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \n")
}
end #end if current player = 2
if current_player == 3 then
@player3_hand.each {|x|
card_value = @deckhash.fetch(x)
sum_of_players_hand = sum_of_players_hand + card_value
# $stdout.write("Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \n")
}
end #end if current player = 3
if current_player == 4 then
@player4_hand.each {|x|
card_value = @deckhash.fetch(x)
sum_of_players_hand = sum_of_players_hand + card_value
# $stdout.write("Showing card and value #{x}, #{sum_of_players_hand}, #{card_value} \n")
}
end #end if current player = 4
# ### This method returns sum of player's hand
return sum_of_players_hand
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_player_hand(player_hand)\n player_hand.reduce(:+)\n end",
"def get_hand_sum(curr_hand) \n curr_hand.inject(0) { |sum, card| sum + card }\n end",
"def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def get_player_total(player_hand)\n\tplayer_total = 0 \t\t# Total value of player's hand\n\n\tfor i in 0..player_hand.length - 1\n\t\tplayer_total += $cards[player_hand[i]]\n\tend\n\treturn player_total\nend",
"def hand_total(hand) \n\n #A flag to see if the hand contains an ace\n have_ace = ! ( session[hand].select{|card| card['rank'] == \"ace\"}.empty? ) \n\n total = 0 \n\n #Look up the point value of each card in the hand\n session[hand].each do |card|\n total += RANK_TO_POINTS[ card['rank']]\n end\n \n #Convert from hard (ace=1) to a soft (ace=11) \n #score if hand contains an ace\n #and it won't cause the hand to bust\n if (total <= 11 && have_ace) then total += 10 end \n\n return total \n\n end",
"def hand_value(hand)\n sum = 0\n hand.each do |card|\n sum += card\n end\n sum\n end",
"def hand_value\n @hand_value = @player_hand.hand.flatten.map { |x| Integer(x) rescue nil}.compact.inject(:+)\n end",
"def determine_players_best_total(current_player)\n # @player1_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n sum_of_players_hand = 0\n number_of_aces_in_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n\n sum_of_players_hand = sum_of_players_hand - 10\n\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 1\n\n if current_player == 2 then\n @player2_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 2\n\n if current_player == 3 then\n @player3_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 3\n\n if current_player == 4 then\n @player4_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 4\n # ### This method returns sum of player's best hand\n return sum_of_players_hand\n end",
"def player1_score\n player_hand.inject(0){|sum,n| sum + n.value }\n end",
"def calcScore(hand)\n return hand.inject(0) { |sum, n| sum + n.points }\nend",
"def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end",
"def total\n calculate_hand_totals\n if @hand.empty?\n puts \"Your hand is empty.\"\n return\n end\n\n puts \"Your hand is #{@hand.to_s}\" \n\n if !in_good_standing?\n puts \"*** YOU LOSE! ***\"\n end\n\n puts \"You have #{@hand_totals.count} possible total(s) with #{@hand_totals.count - 1} Aces:\"\n @hand_totals.each do | total, ace_distrobution |\n if total > 21\n puts \"BUSTED!- #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21 && @hand.count == 2\n puts \"BLACKJACK - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21\n puts \"WINNING HAND - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n else\n puts \"#{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n end\n end\n end",
"def total\n sum = 0\n hand.each do |card|\n sum += card.find_face_value\n end\n sum = correct_for_aces(sum)\n end",
"def dealer_hand_total\n dealers_hand.inject(0) {|sum, card| sum + card.value}\n end",
"def get_hand_value\n cards.reduce(0) { |hand_value, card| hand_value += card.value }\n end",
"def determine_dealers_lowest_total\n sum_of_dealers_hand = 0\n @dealer_hand.each {|x|\n card_value = @deckhash.fetch(x)\n if card_value == 1 then card_value = 11\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n }\n # ### This method returns sum of dealer's hand\n return sum_of_dealers_hand\n end",
"def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend",
"def total_hands\n return @@total_hands\n end",
"def finish_round!\n raise Exceptions::NoWinner if @players_in_round.nil?\n # The winner is the Player with the highest hand_value.\n @round_winner = @players_in_round.sort_by do |player|\n hand_value(player.hand)\n end.reverse.first\n @round_winner.chips += @pot\n @pot = INITIAL_POT\n end",
"def hand_score\n score = self.tricks\n if !self.got_set\n score += 10\n end\n return score\n end",
"def game_score\n previous_hands = self.game_player.hand_players.joins(:hand).where(\n \"hands.position <= ?\", self.hand.position\n )\n gs = 0\n for h in previous_hands\n gs += h.hand_score\n end\n return gs\n end",
"def show_hands\n player_final_value = player_hand.reduce(:+)\n dealer_final_value = dealer_hand.reduce(:+)\n puts \"Player has a total of #{player_final_value}. Dealer has a total of #{dealer_final_value}\"\n if player_final_value > dealer_final_value\n puts \"You win, congrats on beating a program built by a novice.\"\n else\n puts \"I have bested you.\"\n end\n end",
"def hand_value(hand)\n return 0 if hand.empty?\n value = 0\n\n # Add up the face values\n hand.each do |card|\n value += FACE_VALUES[card.face]\n end\n\n # Handle any needed Ace changes.\n while value > BUST\n hand.each do |card|\n if card.face == 'A'\n # Subtract the difference between high and low ace (10).\n value -= (FACE_VALUES['A'] - FACE_VALUES['L'])\n end\n end\n break # no aces to change, bail\n end\n\n return value\n end",
"def hand_value\n\t\tadd_card_value(all_sums = [[]])\n\t\tconvert_aces(all_sums)\n\t\tall_sums.map! do |value_set|\n\t\t\tvalue_set.inject :+\n\t\tend\n\t\treturn_sum(all_sums)\n\tend",
"def dealer_score\n dealer_hand.inject(0){|sum,n| sum + n.value }\n end",
"def player_turn\n player_hand.each do |card|\n puts card\n end\n # hand_value = player_hand.reduce(:+)\n hand_value = player_hand.reduce(0){|sum, num| sum + num.value}\n puts \"You have #{hand_value}\"\n\n puts \"Hit or Stay\"\n answer = gets.chomp.downcase\n if answer == \"hit\"\n hit_phase\n # puts hand_value\n end\n # puts hand_value\n end",
"def sum\n\t\t#sets sum at 0\n\t\tsum = 0\t\t\n\n\t\t#adds each card to the sum\n\t\t@hand_contents.each do |card|\n\t\t\tsum += card.number\n\t\tend\n\n\t\t@hand_contents.each do |card|\n\t\t\tif card.number.eql? 1 then\n\t\t\t\tif sum + 10 <= 21 then\n\t\t\t\t\tsum += 10\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t#return the sum\t\t\n\t\treturn sum\n\tend",
"def compute_sum_for player\r\n if player == nil || player[:cards] == nil || player[:cards].length == 0\r\n return 0\r\n end\r\n \r\n #Compute initial points\r\n sum = 0\r\n i = 0\r\n \r\n while i < player[:cards].length\r\n card = player[:cards][i]\r\n sum = sum + (card[:face] > 10 ? 10 : ((card[:face] == 1)? 11 : card[:face]))\r\n\ti = i + 1\r\n end\r\n \r\n #Fix the sum if possible, when the points is larger than 21\r\n j = player[:cards].length - 1\r\n while sum > 21 && j >= 0\r\n\tcard = player[:cards][j]\r\n\tif card[:face] == 1 #There is an Ace\r\n\t sum = sum - 11 + 1\r\n\tend\r\n\tj = j - 1\r\n end\r\n\t\r\n sum\r\nend",
"def total_query\n\t\t@total = 0\n\t\t@cards_held.times do |x|\n\t\t\t@total += hand_query(x,1,0)\n\t\tend\n\t\treturn @total\n\tend",
"def getPlayTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $playerCards.length\n\t\tx = $playerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def best_hand\n @active_players.map do |player|\n # Creates an array storing all possible 5 card combinations.\n @all_combos = (player.hole_cards + @community_cards).combination(5).to_a\n @best_hand = PokerHand.new\n @current_hand = nil\n\n # Loops through every hand combination, comparing the current hand to the best hand. If the current hand is better than the best hand, it becomes the best hand, otherwise it is deleted.\n @all_combos.map do |hand|\n next unless @all_combos.length > 1\n\n @current_hand = PokerHand.new(hand)\n if @current_hand > @best_hand\n @best_hand = @current_hand\n else\n @all_combos.delete(hand)\n end\n end\n\n # After finding the best hand it stores it for the player and outputs it.\n player.strongest_hand = @best_hand\n puts \"#{player.player_name} has #{player.strongest_hand}\"\n sleep(1)\n end\nend",
"def total_on_hand\n if @variant.should_track_inventory?\n stock_items.sum(:count_on_hand)\n else\n Float::INFINITY\n end\n end",
"def poker hands\n raise NoHandError if hands.empty?\n allmax(hands, method(:hand_rank))\nend",
"def deal_and_total(name, hand_array, deck_hash)\n read_hand(name, hand_array, deck_hash)\n new_hand_value = sum_cards(hand_array, deck_hash)\nend",
"def getDealTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $dealerCards.length\n\t\tx = $dealerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend",
"def bot_hand(player_hand)\n hand = @elements.key(most_frequent_move) || super\n @moves[player_hand] += 1\n\n hand\n end",
"def calculate_primiera(hand1, hand2)\r\n res = [0,0]\r\n #p hand1\r\n #p hand2\r\n # first get the max card on each suit\r\n max_pt = []\r\n [hand1, hand2].each do |curr_hand|\r\n # reset max\r\n max_pt << {:D => 0, :B => 0, :C => 0, :S => 0 }\r\n curr_hand.each do |lbl|\r\n points = @deck_information.get_card_points(lbl)\r\n suit = @deck_information.get_card_segno(lbl)\r\n if points > max_pt.last[suit]\r\n # max on suit\r\n max_pt.last[suit] = points\r\n end\r\n end\r\n #p max_pt.last\r\n end\r\n # using inject, 0 is the first value of the accumulator sum, tha assume the\r\n # value of the block provided. x assume each value of the max_pt.first\r\n # x becomes a pair like max_pt.first.each{|k,v|}. For example x = [:S, 21]\r\n arr_sum_points = []\r\n max_pt.each do |maxitem|\r\n arr_sum_points << maxitem.inject(0) do |sum, x|\r\n if x[1] > 0 and sum >= 0 \r\n sum + x[1]\r\n else\r\n # this is a particular case, we don't have points on a particular suit\r\n # in this case there is no primiera. Then stay on -1.\r\n sum = -1\r\n end\r\n end\r\n end\r\n #p arr_sum_points\r\n if arr_sum_points[0] > arr_sum_points[1]\r\n #primiera on the first hand\r\n res[0] = 1\r\n res[1] = 0\r\n elsif arr_sum_points[0] == arr_sum_points[1]\r\n # same points, primiera is not assigned\r\n res[0] = 0\r\n res[1] = 0\r\n else\r\n #primiera on the second hand\r\n res[0] = 0\r\n res[1] = 1\r\n end \r\n #p res\r\n return res\r\n end",
"def winning_hand\n if !(@player.hand.bust)\n if @player.hand.value > @dealer.hand.value\n player_win\n elsif @player.hand.value == @dealer.hand.value\n if @player.hand.blackjack? && [email protected]?\n player_win\n else\n puts \"The hand pushed\"\n @player.push_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You lost the hand\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You busted\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n end",
"def round()\n\t\t#array of used cards\n\t\t@used = []\n\t\t#loop through players array\n\t\tfor i in 0...@num_players\n\t\t\t#reset player variables\n\t\t\t@players[i].reset()\t\n\t\t\t#populate hand\n\t\t\t@players[i].populate(@used,52,5)\n\t\t\t#get hand rank\n\t\t\t@players[i].get_rank()\n\t\t\t#add hand to array of used cards\n\t\t\t@used += @players[i].hand\n\t\tend\n\t\t#increment round number\n\t\t@roundnum += 1 \n\tend",
"def value(hand)\n # Sorting hack to get aces at the very end so we count them last\n hand.sort_by { |c| c.to_i != 0 ? c : c[0] - 81 }.reverse().inject(0) do |total,cur|\n if cur.to_i != 0\n total + cur # 2-10 case\n elsif [\"J\",\"Q\",\"K\"].include? cur\n total + 10 # J,Q, or K\n elsif cur == \"A\"\n if (total+11) > 21\n total + 1 # Count ace as 1\n else\n total+11 # Count ace as 11\n end\n end\n end\n end",
"def score\n # make a local array that will disappear when not in this method\n tally = []\n # for each of the cards in the hand, add their score to the tally from points\n @hand.each do |card|\n tally.push(@points[card])\n end\n # return the tally of the scores\n return tally.sum\nend",
"def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend",
"def highest_non_bust_hand_value\n hands.select {|hand| !hand.bust? }.map {|hand| hand.value }.max\n end",
"def eval_7hand(hand)\n best = 9999\n subhand = []\n\n (0..20).each do |i|\n (0..4).each do |j|\n subhand[j] = hand[ Arrays::PERM7[i][j] ]\n q = eval_5hand(subhand)\n if q < best\n best = q\n else\n return best\n end\n end\n end\n end",
"def calc_odds(hand, result)\n current = hand_value(hand)\n return 1.0 if current == result\n return 0.0 if current >= 17\n\n # Remove hand cards from full shute\n cards = new_shute\n hand.each {|c| cards.delete_at(cards.index(c))}\n\n odds = 0.0\n CARDS.each do |c|\n odds_of_card = odds_of(cards, c)\n if odds_of_card > 0.0\n hand.push c\n odds_of_result = calc_odds(hand, result)\n odds += odds_of_card * odds_of_result\n hand.pop\n end\n end\n\n return odds\nend",
"def calculate_hand_value(hand)\n value = 0\n if hand.values.reduce(:+) <= 21\n value = hand.values.reduce(:+)\n elsif hand.values.reduce(:+) > 21 && hand.keys.any? {|card| card.include?(\"A\") }\n hand.keys.each do |card|\n hand[card] = 1 if card.include?(\"A\")\n value = hand.values.reduce(:+)\n break if value <= 21\n end\n value\n else\n value = hand.values.reduce(:+)\n end\n\nend",
"def evaluateHandWithoutJoker(hand)\n\t\tevaluation = HAND_EVALUATIONS_NOTHING\n\n\t\tgroupedValues = self.cardsGroupedByValue(hand)\n\t\tgroupedSuits = self.cardsGroupedBySuit(hand)\n\t\tlongestRunLength = self.lengthOfLongestRunOfCards(hand)\n\n\t\t# one pair\n\t\tif !groupedValues[2].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_ONE_PAIR\n\t\tend\n\n\t\t# two pair\n\t\tif !groupedValues[2].nil? and groupedValues[2].length == 2\n\t\t\tevaluation = HAND_EVALUATIONS_TWO_PAIR\n\t\tend\n\n\t\t# three of a kind\n\t\tif !groupedValues[3].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_THREE_OF_A_KIND\n\t\tend\n\n\t\t# straight\n\t\tif longestRunLength == 5\n\t\t\tevaluation = HAND_EVALUATIONS_STRAIGHT\n\t\tend\n\n\t\t# flush\n\t\tif !groupedSuits[5].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_FLUSH\n\t\tend\n\n\t\t# full house\n\t\tif !groupedValues[2].nil? and !groupedValues[3].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_FULL_HOUSE\n\t\tend\n\n\t\t# four of a kind\n\t\tif !groupedValues[4].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_FOUR_OF_A_KIND\n\t\tend\n\n\t\t# straight flush\n\t\tif !groupedSuits[5].nil? and longestRunLength == 5\n\t\t\tevaluation = HAND_EVALUATIONS_STRAIGHT_FLUSH\n\t\tend\n\n\t\t# five of a kind\n\t\tif !groupedValues[5].nil?\n\t\t\tevaluation = HAND_EVALUATIONS_FIVE_OF_A_KIND\n\t\tend\n\n\t\t# royal flush\n\t\tif !groupedSuits[5].nil? and longestRunLength == 5\n\t\t\tif groupedValues[1].include? 0 and groupedValues[1].include? 12 # if it has an A and K\n\t\t\t\tevaluation = HAND_EVALUATIONS_ROYAL_FLUSH_NATURAL\n\t\t\tend\n\t\tend\n\n\t\treturn evaluation\n\tend",
"def get_dealer_total(dealer_hand,dealer_turn)\n\tdealer_total = 0\t# Total value of dealer's visible cards\n\n\tif !dealer_turn\n\t\tdealer_total = $cards[dealer_hand[0]]\n\telse\n\t\tfor i in 0 .. dealer_hand.length - 1\n\t\t\tdealer_total += $cards[dealer_hand[i]]\n\t\tend\n\tend\n\treturn dealer_total\nend",
"def total_score\n total = 0\n @cards.each do |card|\n total += card.value\n end\n\n sorted_cards = @cards.sort\n\n straights = get_straight(sorted_cards).reverse\n straights.each do |straight|\n total += 40\n sorted_cards.slice!(straight[0]..straight[1])\n end\n\n three_cards = get_number_of_a_kind(sorted_cards, 3)\n three_cards.each do |three|\n total += 20\n sorted_cards.slice!(three[0]..three[1])\n end\n\n pairs = get_number_of_a_kind(sorted_cards, 2)\n pairs.each do |pair|\n total += 10\n sorted_cards.slice!(pair[0]..pair[1])\n end\n\n total\n end",
"def total_score\n\t\tall_scores = picks.collect { |pick|\n\t\t\tpicks_golfers = TournamentGolfer.where(golfer_id: pick.golfer_id, tournament_id: pick.pool.tournament_id).pluck(:total)[0]\n\t\t} - [nil] - [\"CUT\"]\n\t\tif all_scores.count < 5\n\t\t\treturn \"DQ\"\n\t\telse \n\t\t\tall_scores = all_scores.map {|score| score.to_i}\n\t\t\tall_scores = all_scores.sort\n\t\t\treturn all_scores[0..(pool.number_golfers_for_scoring-1)].sum\n\t\tend\n\tend",
"def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end",
"def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend",
"def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end",
"def flush(hand)\n\t\thand_num = check_num(hand)\n\t\tif !check_consecutive(hand_num) and same_suit(hand)\n\t\t\treturn 5\n\t\tend\n\t\treturn 0\n\tend",
"def check\n curhand = \"hand ##{@cur+1} contains: \"\n containAce = false;\n sum = 0\n i = 0\n while i<@hands[@cur].length\n if 1 == num_to_value(@hands[@cur][i])\n containAce = true\n end\n sum += num_to_value(@hands[@cur][i])\n curhand += num_to_rank(@hands[@cur][i]) + \" \"\n i += 1\n end\n\n puts \"---------------------------------------------------------\"\n puts curhand\n\n if containAce\n if sum < 11\n puts \"hand ##{@cur+1} value: #{sum}/#{sum+10}\"\n @values[@cur] = sum + 10 # store the higher value which benefits the player\n elsif 11 == sum \n if 2 == @hands[@cur].length && 1 == @hands.length # a blackjack!! no split and only contain two cards\n puts \"hand ##{@cur+1} value: BLACKJACK!!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 50 # use 50 to represent a blackjack\n else\n puts \"hand ##{@cur+1} value: 21\"\n @values[@cur] = 21\n @hands_status[@cur] = \"finished\"\n end\n elsif sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum \n end\n else\n if sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum\n end\n end\n\n\n puts \"bets for hand ##{@cur+1}: #{@bets[@cur]}\"\n puts \"---------------------------------------------------------\"\n\n if \"finished\" == @hands_status[@cur] \n puts \"hand ##{@cur+1} finished\"\n puts \"\"\n if @cur < @hands.length - 1\n @cur += 1 \n self.check # this recursion is to output the information about newly splitted hand's initial status\n end\n end\n\n end",
"def current_total_amount\n\n if calculate_total(session[:player_cards]).to_i == BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:player_cards]).to_i > BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:dealer_cards]).to_i > BLACKJACK\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i == BLACKJACK\n session[:player_pot] -= session[:player_bet].to_i\n elsif calculate_total(session[:player_cards]).to_i > calculate_total(session[:dealer_cards]).to_i\n session[:player_pot] += session[:player_bet].to_i \n elsif calculate_total(session[:dealer_cards]).to_i > calculate_total(session[:player_cards]).to_i\n session[:player_pot] -= session[:player_bet].to_i \n else\n session[:player_pot]\n end # ends if statement\n end",
"def score\n dealt.inject(0){|sum,card| sum + card.value}\n end",
"def full_hand player\n if @table.hand.cards.any?\n return @table.hand.cards.first + player.hand.cards.first \n end\n player.hand.cards.first\n end",
"def high_card\n @hand.max_by{|card| card.point}.point.to_i\n end",
"def calculate_hand_total_value(hand_array)\n total_value = 0\n is_there_an_ace = false\n\n hand_array.each do |card|\n if card[:rank] === \"A\"\n is_there_an_ace = true\n end\n\n card_value = card[:value]\n total_value += card_value\n\n end\n\n if is_there_an_ace\n return [total_value, total_value + 10]\n\n else\n return [total_value, 999]\n\n end\n\nend",
"def get_score\n flush = is_flush?\n straight = is_straight?\n pairs = pairs?\n\n return 45 if pairs.size == 1 && pairs[0][1] == 5\n return 44 if flush && straight\n return 31 + pairs[0][0] - 2 if pairs.size == 1 && pairs[0][1] == 4\n return 30 if pairs.size == 2 && (pairs[0][1] + pairs[1][1]) == 5\n return 29 if flush\n return 28 if straight\n return 15 + pairs[0][0] - 2 if pairs.size == 1 && pairs[0][1] == 3\n return 14 if pairs.size == 2\n return 1 + pairs[0][0] - 2 if pairs.size == 1\n -14 + high_card #high card return\n end",
"def score\n p_score = player_hand.collect{|x| x.value}.inject(:+)\n c_score = computer_hand.collect{|x| x.value}.inject(:+)\n puts \"You have #{player_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{p_score}\"\n puts \"The computer has #{computer_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{c_score}\"\n puts \" \"\n end",
"def overall_WLR\n overall_losses = 0\n overall_wins = 0\n @player_champs_list.each do |champ|\n overall_losses += champ.total_losses\n overall_wins += champ.total_wins\n end\n overall_losses > 0 ? (overall_wins.to_f / overall_losses).round(2) : overall_wins.to_f\n end",
"def total_high\n if is_soft\n return total[1]\n end\n return total\n end",
"def compare_hands\n players_hash = Hash.new(0)\n @active_players.each do |player|\n players_hash[player] = player.hand.analyze_hand_value\n end\n\n highest_val = players_hash.values.max\n winners = players_hash.reject { |_, val| val != highest_val }\n\n winners.keys.each do |winner|\n winner.chip_count += @pot.to_f / winners.length.to_f\n end\n winners_str = \"This rounds winner(s) is/are\"\n winners.keys.each do |winner|\n winners_str << \" #{winner.name}\"\n end\n winners_str << \"!!!!\\n\"\n puts winners_str\n end",
"def eval_hand(player, player_hand)\n d = @dealer.hand.count\n p = player_hand.count\n\n if p > 21 || (d > p && d <= 21) # LOSE!\n puts \"You lost $#{player_hand.bet}.\"\n elsif d == p # PUSH!\n player.wallet += player_hand.bet\n puts :Push\n elsif p == 21 && player_hand.size == 2 # BLACKJACK!\n # Blackjack pays out 3/2.\n player.wallet += (player_hand.bet*2.5).to_i\n puts \"You won $#{player_hand.bet*1.5}!\"\n else # WIN!\n player.wallet += (player_hand.bet*2)\n puts \"You won $#{player_hand.bet}!\"\n end\n end",
"def best_hand\n case\n when hand?\n return @cards\n when pair? && !hand?\n get_pairs\n when two_pair? && !hand?\n get_pairs\n when three_of_a_kind? && !full_house? && !hand?\n get_three_of_a_kind\n when straight? && !straight_flush? && !hand?\n get_straight\n when flush? && !straight_flush? && !hand?\n get_flush\n when full_house? && !hand?\n get_full_house\n when four_of_a_kind? && !hand?\n get_four_of_a_kind\n when straight_flush? && !hand?\n get_straight_flush\n else\n get_high_card\n end\n end",
"def full_house(hand)\n\t\tif (pair(hand) > 0 and three_of_a_kind(hand) > 0)\n\t\t\treturn 6\n\t\tend\n\t\treturn 0\n\tend",
"def net_worth\n result = self.cash_on_hand\n self.holdings.each do |holding|\n share_price = holding.company.share_price\n result += share_price * holding.amount\n end\n @net_worth = result\n end",
"def hand_value\n\t\treturn evaluate_hand(@hand)\n\tend",
"def hand_of_poker\n players_in_hand = @players.dup\n @players.each {|player| deal(player, 5)}\n remaining_players = betting_round(players_in_hand)\n unless remaining_players.count == 1\n exchange_cards\n remaining_players = betting_round(remaining_players)\n unless remaining_players.count == 1\n remaining_players = compare_hands(remaining_players)\n end\n end\n winner = remaining_players.first\n puts \"#{winner.name} wins!\"\n print \"\\n\\n\\n\"\n pay_out(winner)\n reset_deck\n end",
"def total\n @frame.inject(0){|rez, item| item ? rez + item[:score] : rez }\n end",
"def winner\n @best_hand = {}\n @eg_users.each do |user|\n @usr = user[0]\n @best_hand[@usr] = []\n cards = []\n cards = Array.new(@communal_cards)\n cards << user[1]\n cards << user[2]\n calculate_hand cards\n end\n best_hnd_key = determine_winner\n end",
"def reduce_HP\n @points -= 10\n end",
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def sum_bets() \n\t\t@sum = 0\n\t\t#loop through players array\n\t\tfor i in 0...@num_players\n\t\t\t@sum += @players[i].bet\n\t\tend\n\t\treturn @sum\n\tend",
"def win_hp\n maxhp * features_sum(:hp_on_win)\n end",
"def possibleHandValues\n \thand_values = Set.new [0] # start with value 0\n \[email protected] do |card| # for each card in the hand\n \t card_values = card.getValue\n \t new_hand_values = Set.new # add its value to all the possible\n \t hand_values.each do |total| # values for each of the previous\n \t \tcard_values.each do |card_value| # cards\n new_hand_values << total+card_value\n end\n end\n # Swap variable names. This makes the loop simpler\n new_hand_values, hand_values = hand_values, new_hand_values\n new_hand_values.clear\n end\n # Get the values that are below 21\n hand_values.delete_if do |value|\n if value > BLACKJACK\n true\n end\n end\n hand_values # Return set of possible values\n end",
"def currentHand #finds current hand during game\n self.hands.last\n end",
"def sum_of_cards(hand)\n card_values = hand.map do |card|\n if card[0] == 1\n card[0] = 11\n elsif card[0] >= 11\n card[0] = 10\n else\n card[0]\n end\n end\n sum = 0\n card_values.each do |card|\n sum += card[0]\n end\n sum\n end",
"def current_hp\n\t\t@current_hp + temp_hp\n\tend",
"def pays_players\n self.players.inject(0) {|sum, player| sum += player.pay}\n end",
"def get_sum_frame()\n sum = 0\n @frames.each do |frame|\n if !frame.score.nil?\n sum += frame.score\n end\n end\n sum\n end",
"def read_hand(name, hand_array, deck_hash)\n hand_val = sum_cards(hand_array, deck_hash)\n puts \"#{name}'s hand is now #{hand_array.join(\", \")} for a total of #{hand_val} points\"\n nil\nend",
"def calculate\n player.combine_cards\n player.deck.each do |card|\n if card.is_a? Victory\n @points += card.points player\n end\n end\n self\n end",
"def strength\n players.map{|p| p.strength}.reduce{|sum,n| sum + n}\n end",
"def winner_take_hand\n from_war = @state == 'war'\n\n #save this for use in the stats display later\n @hand_played.freeze \n\n @winning_player = get_player_by_name @hand_played.try(:first).try(:owner)\n # @hand_played.each{|x| cards_played.push(x)}\n\n unless @winning_player.blank? \n # first calculate the loser's lost cards and metadata\n @cards_on_table.each do |c|\n get_player_by_name( c.try(:owner) ).in_battle\n get_player_by_name( c.try(:owner) ).lose_cards [c]\n end\n\n # winner puts all cards on table at the end of their deck, change ownership\n @winning_player.gain_cards(@cards_on_table)\n @winning_player.won_battle\n\n # reset var to empty array\n @cards_on_table = []\n end\n\n # check if all players can continue\n players.each do |p|\n player_leaves_game(p) if p.try(:cards).try(:count) < 1\n end\n\n display_battle_results\n set_game_state 'play'\n end",
"def total (hand, current_total)\n # cards are nested arrays format like this: [\"H\", \"9\"] and [\"S\", \"9\"]\n # can extract out separate array of values only using .map, ignore suits\n string_values = hand.map { |card| card[1] } \n\n string_values.each do |value|\n current_total += get_int_value(value, current_total)\n end\n current_total\nend",
"def heuristic_score(state)\n pieces = state[:pieces]\n player = state[:player]\n total_value(pieces[player]) - total_value(pieces[opponent(player)])\n end",
"def value_of_hand(hand)\n collection_of_card_values = hand.collect {|index| index[1]}\n card_values = collection_of_card_values.inject{|sum,next_card| sum + next_card }\n if collection_of_card_values.include?(1) && card_values < 12\n card_values += 10\n end\n card_values\nend",
"def calculate_points(cards_in_hands)\n points = 0\n cards_without_ace = cards_in_hands.select {|card| card[1] != 'A'}\n cards_with_ace = cards_in_hands.select {|card| card[1] == 'A'}\n cards_without_ace.each do |card|\n if card[0].to_i !=0\n points += card[0].to_i\n else\n points += 10\n end\n end\n if cards_with_ace.empty?\n return points\n else\n ace_sets = [11, 1].repeated_permutation(cards_with_ace.length).to_a\n ace_sets_sum_arr = []\n ace_sets.each do |arr|\n arr_sum = 0\n arr.each {|v| arr_sum = arr_sum + v}\n ace_sets_sum_arr.push(arr_sum)\n end\n ace_sets_sum_arr.sort!.uniq!\n ace_sets_sum_arr.map! {|num| num + points}\n if ace_sets_sum_arr.include?(21)\n points = 21\n return points\n else\n lt_21_arr = ace_sets_sum_arr.select {|v| v < 21}\n gt_21_arr= ace_sets_sum_arr.select {|v| v > 21}\n if lt_21_arr.empty?\n points = gt_21_arr.first\n return points\n else\n points = lt_21_arr.last\n return points\n end\n end\n end\nend",
"def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end",
"def pl_high?\n session[:player].hand_total > session[:dealer].hand_total\n end",
"def score_hand\n\n end",
"def blind_score\n p_score = player_hand.collect{|x| x.value}.inject(:+)\n c_score = computer_hand.collect{|x| x.value}.inject(:+)\n puts \"You have #{player_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{p_score}\"\n puts \"The computer has #{computer_hand[1].face}#{computer_hand[1].suit} & [#]\"\n puts \" \"\n end",
"def hand_score(hand)\n\tcards= {\"A\"=>4, \"K\"=>3, \"Q\"=>2, \"J\"=>1}\n \tscore = 0\n \thand.each_char { |char| score += cards[char.upcase] }\n \treturn score\nend",
"def deal_hand\n dealt = 0\n while dealt < @hand_size \n for player in @players\n player.cards.push(deal_answer_card)\n end \n dealt = dealt + 1\n end\n return @players\n \n end",
"def score\n handscore = possible_scores.sort.reverse\n handscore.detect { |value| value <= 21 } or handscore.last\n end",
"def highest_options_sum\n possibilities = possibilites_matrix\n ( highest_total, highest_possibilities ) = highest_possibility_price( possibilities )\n highest_total\n end",
"def reward\n -queue.sum.to_f if feasible?\n end"
] | [
"0.7518541",
"0.74518615",
"0.7345666",
"0.7178283",
"0.71606296",
"0.69473803",
"0.6850758",
"0.6776467",
"0.67761457",
"0.67357767",
"0.6707099",
"0.6635455",
"0.6632383",
"0.66071683",
"0.660602",
"0.66054374",
"0.65918857",
"0.6557082",
"0.65395415",
"0.65181434",
"0.6517122",
"0.65087223",
"0.6504261",
"0.64909524",
"0.6488478",
"0.64560544",
"0.64392245",
"0.64308804",
"0.6429569",
"0.6398424",
"0.6395492",
"0.63628334",
"0.6359546",
"0.62840146",
"0.6269437",
"0.6246883",
"0.62342346",
"0.62292653",
"0.6178589",
"0.6173752",
"0.6152135",
"0.61496294",
"0.61318153",
"0.61308974",
"0.6120741",
"0.61161184",
"0.61031663",
"0.6086741",
"0.6082693",
"0.6077655",
"0.6075935",
"0.6074839",
"0.6068164",
"0.6066955",
"0.6037473",
"0.602731",
"0.6017566",
"0.60104436",
"0.60074633",
"0.59827596",
"0.5981513",
"0.59665877",
"0.59660226",
"0.5965304",
"0.594157",
"0.59414643",
"0.59368056",
"0.5928086",
"0.59273374",
"0.5917086",
"0.59139746",
"0.59027106",
"0.5888629",
"0.58858645",
"0.5868534",
"0.58685327",
"0.58622277",
"0.5850704",
"0.5845228",
"0.5842426",
"0.5841163",
"0.58302546",
"0.5822232",
"0.5813682",
"0.58085185",
"0.5802184",
"0.5795097",
"0.57870686",
"0.57835793",
"0.5776844",
"0.57633793",
"0.57574576",
"0.57484794",
"0.5747026",
"0.5742781",
"0.5742412",
"0.5724448",
"0.57239115",
"0.57172185",
"0.5716062"
] | 0.7314292 | 3 |
Row explanation: [ "month_name", ruby_prs, js_prs, pythong_prs ] Output: [ [ "january", 1, 2, 3 ], ... [ "dicember", 6, 0, 2 ], ] | def monthly_language_activity
@data.fetch("activity")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def month_array\r\n\t\t[[\"January\", \"1\"],[\"February\", \"2\"], \r\n\t\t[\"March\", \"3\"],[\"April\",4],\r\n\t\t[\"May\",5],[\"June\",6],\r\n\t\t[\"July\",7],[\"August\",8],\r\n\t\t[\"September\",9],[\"October\",10],\r\n\t\t[\"November\",11],[\"December\",12]]\r\n\tend",
"def month_names; end",
"def monthly_language_activity\n memoized_language_breakdowns = all_languages_monthly_activity\n\n MONTHS.map do |month|\n res = [Date::MONTHNAMES[month]]\n memoized_language_breakdowns.each do |lang, breakdown|\n value = breakdown.detect { |b| b.fetch(\"month\") == month }\n prs = value ? value.fetch(\"prs\") : 0\n res << prs\n end\n res\n end\n end",
"def translated_month_names; end",
"def take_row(month_line, months)\n months.map { |month| month[month_line] }.join(EMPTY_DAY_SPACES)\n end",
"def month_by_month_table(event)\n headers = ['Title']\n month_column_headers = months_list.map { |m| m.strftime(MONTH_KEY) }\n headers.concat(month_column_headers)\n table = [headers]\n\n each do |item|\n monthly_stats = months_list.map { |m| item.get_stat(event, m.strftime(MONTH_KEY)) }\n table << [item.document.title].concat(monthly_stats)\n end\n\n total_stats = months_list.map { |m| total_for(event, m.strftime(MONTH_KEY)) }\n table << ['Totals:'].concat(total_stats)\n\n table\n end",
"def rsmonth(month)\n case month\n when 1\n return 'januar'\n when 2\n return 'februar'\n when 3\n return 'mart'\n when 4\n return 'april'\n when 5\n return 'maj'\n when 6\n return 'jun'\n when 7\n return 'jul'\n when 8\n return 'avgust'\n when 9\n return 'septembar'\n when 10\n return 'oktobar'\n when 11\n return 'novembar'\n when 12\n return 'decembar'\n end\nend",
"def format_month_body(m)\n d = ((first_day(m) + 5) % 7) + 1\n if d == 7\n d = 0\n end\n padding = Array.new(d, nil)\n updated_list = (padding + get_number_of_month(m)).each_slice(7).to_a\n updated_list.each do |a|\n if a.length < 7\n (7 - a.length).times do\n a << nil\n end\n end\n end\n (6 - updated_list.length).times do\n updated_list << Array.new(7, nil)\n end\n updated_list\n end",
"def month() end",
"def month_by_month_csv\n CSV.generate do |csv|\n report_details.each { |a| csv.add_row(a) }\n csv.add_row [] # Blank row\n csv.add_row ['VIEWS']\n month_by_month_table(Statistic::VIEW).each { |a| csv.add_row(a) }\n csv.add_row [] # Blank row\n csv.add_row ['DOWNLOADS']\n month_by_month_table(Statistic::DOWNLOAD).each { |a| csv.add_row(a) }\n end\n end",
"def months_as_array\n (1..12).map {|m| [Date::MONTHNAMES[m]]}\n end",
"def format_month_body\n d = ((first_day + 5) % 7) + 1\n if d == 7\n d = 0\n end\n padding = Array.new(d, nil)\n updated_list = (padding + get_number_of_month).each_slice(7).to_a\n updated_list.each do |a|\n if a.length < 7\n (7 - a.length).times {a << nil}\n end\n end\n (6 - updated_list.length).times {updated_list << Array.new(7, nil)}\n updated_list\n end",
"def month; end",
"def month; end",
"def month=(_arg0); end",
"def make_year_stats(months)\n rows = months.map{|month|\n items = Item.all(:conditions => {\n :date => month_range(month),\n :type => [\"Expense\", \"Income\"]\n }).group_by(&:category)\n\n make_row(month, items)\n }\n\n return rows.push make_sum_row(rows)\n end",
"def parse_header(row)\r\n @first_month = 0 # January.\r\n row.each do |col|\r\n next unless col.nil?\r\n index = Date::MONTHNAMES.index(col.strip)\r\n unless index.nil?\r\n @first_month = index\r\n break\r\n end\r\n end\r\n @header_parsed = true\r\n end",
"def month_result_by_week(day)\n output = []\n data = month_result_string(day)\n # front pad with null days\n ((day.beginning_of_month.wday + 6) % 7).times do\n output << { result: nil, mday: nil }\n end\n # get the data\n data.each_char.with_index do |r, i|\n output << { result: r, mday: i + 1 }\n end\n # end pad\n (- output.count % 7).times do\n output << { result: nil, mday: nil }\n end\n output\n end",
"def to_category_month_hash\n {\n month: row_hash[\"Month\"],\n category_group_and_category: row_hash[\"Category Group/Category\"],\n category_group: row_hash[\"Category Group\"],\n category: row_hash[\"Category\"],\n budgeted: row_hash[\"Budgeted\"],\n activity: row_hash[\"Activity\"],\n available: row_hash[\"Available\"]\n }\n end",
"def create_date_value\n \n 1.upto(months.length) do |month|\n 1.upto(month) do |day|\n arr << [\"2015#{day}#{month}\", day_of_week]\n end\n end\nend",
"def month_week_result_array(day)\n first_week_length = (7 - (day.wday + 6) % 7)\n data = month_result_string(day)\n [\n data[0..first_week_length - 1],\n data[first_week_length..7 + first_week_length - 1],\n data[first_week_length + 7..14 + first_week_length - 1],\n data[first_week_length + 14..21 + first_week_length - 1],\n data[first_week_length + 21..28 + first_week_length - 1],\n data[first_week_length + 28..35 + first_week_length - 1]\n ].compact\n end",
"def test_yearly_by_month_loop\n parse(\n 'FREQ=YEARLY;INTERVAL=1;UNTIL=20120203T225959Z;BYMONTH=2;BYSETPOS=1;BYDAY=SU,MO,TU,WE,TH,FR,SA',\n '2012-01-01 15:45:00',\n [\n '2012-02-01 15:45:00'\n ],\n '2012-01-29 23:00:00'\n )\n end",
"def month_name(number); end",
"def make_month_stats(month)\n rows = Account.all(:order => \"position\").map{|account|\n items = Item.all(:conditions => {\n :account_id => account.id,\n :date => month_range(month), \n :type => [\"Expense\", \"Income\"]\n }).group_by(&:category)\n\n make_row(account.name, items)\n }\n\n return rows.push make_sum_row(rows)\n end",
"def normalise_month(row_index)\r\n month_index = row_index + @first_month\r\n month_index -= 12 if month_index >= 12\r\n month_index\r\n end",
"def month\r\n return @hm\r\n end",
"def month\n return self.to_a[IDX_MONTH]\n end",
"def summary_array\n row = []\n column = [DueText.minutes, till_or_since, calc_mins_till.round(2), DueText.minutes_suffix]\n row << column\n column = [DueText.hours, till_or_since, calc_hours_till.round(2), DueText.hours_suffix]\n row << column\n column = [DueText.days, till_or_since, calc_days_till.round(2), DueText.days_suffix]\n row << column\n column = [DueText.weeks, till_or_since, calc_weeks_till.round(2), DueText.weeks_suffix]\n row << column\n column = [DueText.months, till_or_since, calc_months_till.round(2), DueText.months_suffix]\n row << column\n column = [DueText.years, till_or_since, calc_years_till.round(2), DueText.years_suffix]\n row << column\n end",
"def each_june( n=1); each_monthnum(self.Jun,n); end",
"def parse_month(time)\n [file_for_month(time.strftime(\"%-m\"))]\n end",
"def month_labels\n dates.collect { |date| date.to_date.day == 1 ? date.to_date.strftime('%B') : '' }\n end",
"def roman_month(date)\n date[1]\n end",
"def month_entries(pages, year, month)\n #puts \", year = #{year}, month = #{month}\"\n # page.full_name => yyyy/mm/dd\n entries = []\n pages.each do |page|\n if page_is_of_month?(page, year, month)\n entries << page \n end\n end\n entries\n end",
"def heb_month_name\r\n if HebrewDate.leap?(@hy) and @hm >= 12 # leap year and from adar\r\n return HEB_MONTH_NAMES[@hm + 1]\r\n else\r\n return HEB_MONTH_NAMES[@hm]\r\n end\r\n end",
"def month_depot\n \"#{depot.name} \"+\"#{issue_date.strftime(\"%b\")} \"+\"#{issue_date.year}\"\n end",
"def each_july( n=1); each_monthnum(self.Jul,n); end",
"def weeks\n rows = []\n rows << name_of_month.center(20) + \" \"\n rows << \"Su Mo Tu We Th Fr Sa\" + \" \"\n days = format_dates\n (0..7).each {|num|\n fields = days[num * 7, 7]\n rows << fields.join(\" \") + \" \" if fields\n }\n if rows.last.length < 22\n rows.last << \" \" * (22 - rows.last.length)\n end\n until rows.length == 8\n rows << \" \" * 22\n end\n rows\n end",
"def to_ary\n [year, month]\n end",
"def months\n self.to_i * 2_592_000\n end",
"def generate_month_definition_strings(rules_by_month, parsed_custom_methods)\n month_strings = []\n\n rules_by_month.each do |month, rules|\n month_string = \" #{month.to_s} => [\"\n rule_strings = []\n rules.each do |rule|\n string = '{'\n if rule[:mday]\n string << \":mday => #{rule[:mday]}, \"\n end\n\n if rule[:function]\n string << \":function => \\\"#{rule[:function].to_s}\\\", \"\n\n # We need to add in the arguments so we can know what to send in when calling the custom proc during holiday lookups.\n # NOTE: the allowed arguments are enforced in the custom methods parser.\n string << \":function_arguments => #{get_function_arguments(rule[:function], parsed_custom_methods)}, \"\n\n if rule[:function_modifier]\n string << \":function_modifier => #{rule[:function_modifier].to_s}, \"\n end\n end\n\n # This is the 'else'. It is possible for mday AND function\n # to be set but this is the fallback. This whole area\n # needs to be reworked!\n if string == '{'\n string << \":wday => #{rule[:wday]}, :week => #{rule[:week]}, \"\n end\n\n if rule[:year_ranges] && rule[:year_ranges].is_a?(Hash)\n selector = rule[:year_ranges].keys.first\n value = rule[:year_ranges][selector]\n\n string << \":year_ranges => { :#{selector} => #{value} },\"\n end\n\n if rule[:observed]\n string << \":observed => \\\"#{rule[:observed].to_s}\\\", \"\n string << \":observed_arguments => #{get_function_arguments(rule[:observed], parsed_custom_methods)}, \"\n end\n\n if rule[:type]\n string << \":type => :#{rule[:type]}, \"\n end\n\n # shouldn't allow the same region twice\n string << \":name => \\\"#{rule[:name]}\\\", :regions => [:\" + rule[:regions].uniq.join(', :') + \"]}\"\n rule_strings << string\n end\n month_string << rule_strings.join(\",\\n \") + \"]\"\n month_strings << month_string\n end\n\n return month_strings\n end",
"def months_list\n\t (Date.today-1.year..Date.today).map{|d| [d.strftime(\"%b-%Y\"), d.strftime(\"%m-%Y\")]}.uniq.reverse\n\tend",
"def month\n end",
"def print_month\n print \"#{@month.capitalize} #{@year}\".center(20) + \" \"\n puts \"\\n\"\n print \"Su Mo Tu We Th Fr Sa\" + \" \"\n puts \"\\n\"\n format_month_body.each do |line|\n converted_line = line.map do |day|\n day.to_s.rjust(2)\n end\n puts converted_line.join(\" \") + \" \"\n end\n end",
"def each_september(n=1); each_monthnum(self.Sep,n); end",
"def monthly\n end",
"def print_year_body(mon, itr)\n index = mon\n @row.times do\n converted_line = format_month_body(@@months[index])[itr].map do |day|\n day.to_s.rjust(2)\n end\n index += 1\n print converted_line.join(\" \") + \" \"\n end\n end",
"def month\n @month ||= date_calc.merch_to_julian(merch_month)\n end",
"def build_vertical_array(year, month)\n # pull in arrays of days and dates\n dates = self.build_date_array(Time.now.year, Time.now.month)\n days = self.build_day_array(Time.now.year, Time.now.month)\n\n # zip the two arrays so we have the following single array to work with\n # [['Mo', '01'], ['Tu', '02']]\n vertical = days.zip(dates)\n\n return vertical\n end",
"def by_month(year, month)\n request = @client.call(:recupera_tc_mes, message: {\n Ano: year,\n Mes: month\n })\n\n response = request.body[:recupera_tc_mes_response][:recupera_tc_mes_result][:detalle_tc][:tc]\n puts response.to_json\n response\n end",
"def print_year_header(mon)\n index = mon\n @row.times do\n print \"#{@@months[index].to_s.capitalize.center(20)} \"\n index += 1\n end\n puts \"\\n\"\n end",
"def payments_report(period_data = 'last_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, 'Tithe', 'Pledge', 'Partner', 'Donation', 'Offertory', 'Payment']]\n range.each do |d| \n r = d.beginning_of_day..(daily_report ? d.end_of_day : d.end_of_month.end_of_day)\n data << [d.strftime(daily_report ? '%d' : '%Y-%m'), \n res.where(payment_at: r, goal: 'tithe').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'pledge').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'partner').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'donation').sum(:amount).to_f,\n res.where(payment_at: r, goal: 'offertory').sum(:amount).to_f,\n res.where(payment_at: r, goal: nil).sum(:amount).to_f\n ]\n end\n data\n end",
"def each_march( n=1); each_monthnum(self.Mar,n); end",
"def assign_products(row, input, pubYear)\n products = []\n base = ''\n\n if( pubYear < 2020 )\n base = 'bar_pre2020_collection'\n else\n base = \"bar_#{pubYear}_annual\"\n end\n products.push base\n\n case input['Series']\n when 'BAR British Series'\n products.push base+='_brit'\n when 'BAR International Series'\n products.push base+='_int'\n end\n\n i = 1\n products.each { |p|\n row[\"Fulcrum Product #{i}\"] = p\n i += 1\n }\n\nend",
"def month_name\r\n return MONTH_NAMES[@hm]\r\n end",
"def month(date)\n [MONTHS[date.month - 1], year(date)].join(', ')\n end",
"def each_january( n=1); each_monthnum(self.Jan,n); end",
"def months; self * MONTH; end",
"def render_months(months)\n months.map { |month| month_renderer.render(month) }\n end",
"def weeks_layout\n begin_space = []\n i = 1\n until i == zeller\n begin_space << \" \"\n i += 1\n end\n \n all_days_array = days_in_month\n all_days_array.collect! do |date|\n if date < 10 && date != 1\n \" \" + date.to_s\n else\n \" \" + date.to_s\n end\n end\n days_and_spaces_array = begin_space\n days_and_spaces_array += all_days_array\n\n weeks = []\n weeks << [month_year_header]\n weeks << [\"Su Mo Tu We Th Fr Sa\"]\n j = 0\n while j < 6 #6 weeks max\n seven_days = days_and_spaces_array.shift(7) #plucks the first 7 string elements from the array\n seven_days = seven_days.join\n seven_days.slice!(0) unless j == 0 #slicing off the first space of each line\n weeks << [seven_days]\n # calendar << \"\\n\" #line break at the end of each line\n j += 1 #up to 6 weeks max\n end\n weeks\n end",
"def table (b,rain_fall_type,year,ji,compare)\n if rain_fall_type == \"All\"\n hash_data = ji.map do |el|\n {title:el, field:el, sorter:\"string\", editor:true}\n end\n else\n if compare == \"None\"\n hash_data = [\n {title:\"Year\", field:\"Year\", sorter:\"string\", editor:true},\n {title:rain_fall_type, field:rain_fall_type, sorter:\"string\", editor:true},\n {title:\"Districts\", field:\"Districts\", sorter:\"string\", editor:true}\n ]\n else\n hash_data = [\n # {title:compare, field:compare, sorter:\"string\", editor:true},\n {title:\"Year\", field:\"Year\", sorter:\"string\", editor:true},\n {title:rain_fall_type, field:rain_fall_type, sorter:\"string\", editor:true},\n {title:\"Districts\", field:\"Districts\", sorter:\"string\", editor:true}\n ]\n end\n end\n data = {column: hash_data,data: b}\n return data\n end",
"def to_year\n month_obj = []\n month_obj << \"#{month_name}\".center(DEFAULT_MONTH_WIDTH)\n month_obj << \"Su Mo Tu We Th Fr Sa\"\n month_obj.concat(format_body)\n end",
"def monthly_sales(report_date = Time.now)\n date = DateTime.parse report_date.to_s\n prior_months = TimeCalculator.prior_year_period(date, {:format => '%b %Y'})\n [].tap do |results|\n prior_months.each { |mon|\n short_mon = DateTime.parse(mon).strftime('%b')\n total_sales = sold_images.sum { |image| image.sale.total_image_sales(mon) }\n results << { :month => short_mon, :sales => total_sales }\n }\n end\n end",
"def data\n d = Date.new(0, 1, 1)-1\n months = params[:months].to_i\n respond_to do |format|\n format.json { render json: JournalEntry.build_stairs(months).to_json }\n #format.csv {render csv: 'foo'}\n format.text { render :text => JournalEntry.all.map { |j| \"#{(j.entry_date - d).to_i} #{j.fitness ? j.fitness : \"NaN\"} #{j.purity ? j.purity : \"NaN\"} #{j.chrissy ? j.chrissy : \"NaN\"}\" }.join(\";\") }\n end\n\n end",
"def month_groups(sd,ed)\n\t (sd..ed).map{|d| [Date::MONTHNAMES[d.month], d.year]}.uniq\n\tend",
"def build_date_array(year, month)\n date_array = Array.new\n # cycle through days in month creating one key in the array for each day\n for d in (1..self.days_in_month(year, month))\n if d.to_i < 10 then\n # if date is 1-9 make sure it is 01-09\n d = \"0#{d}\"\n end\n date_array[d.to_i] = d\n end\n # remove 0 key for 1 to 1 mapping in array\n date_array.shift\n return date_array\n end",
"def months\n @years * 12\n end",
"def month\n return @month\n end",
"def growth_months(growth)\n \"#{months[growth[:months_in]]} - #{months[growth[:months_in]+growth[:chunk].length-1]}\"\n end",
"def table(b, rain_fall_type, _year, ji, compare)\n dataset = rain_fall_type.tr('_', ' ')\n dataset_compare = compare.tr('_', ' ')\n hash_data = if rain_fall_type == 'All'\n ji.map do |el|\n if el.to_s == 'Year'\n { title: 'Year', field: el, headerFilter: true }\n else\n { title: el.to_s.tr('_', ' '), field: el }\n end\n end\n else\n\n hash_data = if compare == 'None'\n [\n { title: 'Year', field: 'Year', headerFilter: true },\n { title: dataset, field: rain_fall_type }\n\n ]\n else\n [{ title: 'Year', field: 'Year', headerFilter: true },\n { title: dataset, field: rain_fall_type },\n { title: dataset_compare, field: compare }]\n end\n end\n\n data = { column: hash_data, data: b }\n data\n end",
"def displayTransactionsMonth(month)\n displayTransactionsBlankRow\n row do\n @pastMonthDeployed = true\n column(getRuleString(@transWidth_1))\n column(getRuleString(@transWidth_2))\n column(getRuleString(@transWidth_3))\n column(\" [ #{month.upcase} ] #{getRuleString(@transWidth_4 - (month.length + 6))}\")\n column(getRuleString(@transWidth_5))\n column(getRuleString(@transWidth_6))\n column(getRuleString(@transWidth_7))\n end\n displayTransactionsBlankRow\n end",
"def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[1])\n end",
"def month_result_string(day)\n start = day.beginning_of_month.yday - 1\n finish = day.end_of_month.yday - 1\n result_string(day.year).slice(start..finish)\n end",
"def create_monthly_data\n number = @slide_number.to_i + 1\n monthly_data = Nokogiri::HTML(\n open(\n \"#{ENV['API_DOMAIN_2']}#{ENV['API_DOMAIN_2_MONTHLY']}\"\n )\n ).css(\"div.shareable-section-wrapper\").last\n\n data = {\n sign: @sign_name.to_s,\n duration: \"monthly\",\n horoscope_text: monthly_data.css(\"div[#{number}]\").text.split(' ')[1..-1].join(' ')\n } if monthly_data\n Horoscope.create(data) if monthly_data and data\n end",
"def month_names\n @month_names ||= begin\n month_names = @options[:use_month_names] || translated_month_names\n month_names = [nil, *month_names] if month_names.size < 13\n month_names\n end\n end",
"def to_months; @val end",
"def format_for_export(row, formats)\n formatted_row = []\n row.zip(formats).each do |val, format|\n formatted = val\n if format == :boolean\n formatted = val ? 'Yes' : ''\n elsif format == :fiscal_year\n formatted = val.blank? ? '' : format_as_fiscal_year(val.to_i)\n end\n formatted_row << formatted\n end\n formatted_row\n end",
"def calc_beer_months(x)\n\t\t@top_beer_styles=[\"Porter\", \"Stout\", \"Brown Ale\", \"Pale Ale\", \"Red/Amber Ale\", \"Belgian Ale\", \"Wheat Ale\", \"Other Ale\", \"Pilsner\", \"Other Lager\", \"Other\"]\n\n\t\t#creates a 12 x 11 array of 0s\n\t\t@beer_months = Array.new(12) { Array.new(11, 0)}\n\n\t\t#for each of the arrays in month_counts corresponding to each month\n\t\t@month_counts.each do |x|\n\t\t\t#for each checkin in that month\n\t x.each do |that_months_beer|\n\t \t#for each style in the beer styles array\n\t @top_beer_styles.each do |one_beer_style|\n\t \t#if the beer style of the checkin equals the beer style in the array, increment the value of number of beers for that style for that month\n\t if (that_months_beer == one_beer_style) \n\t @beer_months[@month_counts.index(x)][@top_beer_styles.index(one_beer_style)]+=1\n\t end\t \n\t end\n\t end\n\t\tend\n\n#Last minute fix to get the data in the proper format for D3. Each element is converted into an object where each x is the column index (relates to each style) and each y is the number of checkins for that beer style per month ie {x: 0, y: 23} and this array can then be fed into the D3 stacked bar chart. This could likely be handled better from an object-oriented standpoint.\n\t\t@beer_months_object = []\n\t\t@beer_months.each do |m|\n\t\t\tthis_month = []\n\t\t\t(0...m.length).each do |s_idx|\n\t\t\t\tthis_month << {x: s_idx, y: m[s_idx]}\n\t\t\tend\n\t\t\t@beer_months_object << this_month\n\t\tend\n\tend",
"def scan_for_month_names(token, options = T.unsafe(nil)); end",
"def test__individual_month__printing\n\t\tm = Month.new(1, 1, true)\n\t\texpected_output = \n\"Su Mo Tu We Th Fr Sa\n 1 2 3 4 5 6 7\n 8 9 10 11 12 13 14\n15 16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30 31\n\n\"\n\t\tassert_equal(expected_output, m.construct_month_for_printing)\n\tend",
"def monthly_timesheet\n \n end",
"def calories_month(db, member_id)\n total_calories= []\n this_month = Time.now.strftime(\"%m\") \n calories_date= db.execute(\"SELECT * FROM calories WHERE member_id='#{member_id}' AND month='#{this_month}' \")\n calories_date.each do |cals|\n total_calories << cals['amt_burned']\n end \n total_calories.inject(:+)\nend",
"def publish_month_and_year\n [publish_on.month, publish_on.year]\n end",
"def month_of_year(*months)\n merge(month: months)\n end",
"def adjust_month(m)\n months = [\"january\", \"february\", \"march\", \"april\", \"may\", \"june\", \"july\", \"august\", \"september\", \"october\", \"november\", \"december\"]\n if m.is_a? Integer\n months[m-1]\n else\n m\n end\n end",
"def month_week_pattern\n week_pattern.map.with_index { |val,idx| Array.new(val,idx+1) }.flatten\n end",
"def setMonthNames(months)\n (1...[months.size, @month_name.size].min).each do |x|\n @month_name[x] = months[x]\n end\n end",
"def month\n @month ||= Date::ABBR_MONTHNAMES.index(@md[4])\n end",
"def each_april( n=1); each_monthnum(self.Apr,n); end",
"def price_of_month\n { :\"#{Date::MONTHNAMES[Date.strptime(yearmonth, '%Y%m').mon]}\" => price(yearmonth) }\n end",
"def oz_archived_months(sep = ', ')\r\n year, string = 0, ''\r\n months = {}\r\n years = []\r\n\r\n Post.archived_months.map do |month|\r\n date = Time.parse(month)\r\n if date.year > year\r\n year = date.year\r\n months[year] = []\r\n years << year\r\n end\r\n months[year] << month_link(date.strftime('%B').downcase, month)\r\n end\r\n\r\n years.map { |y| \"#{y}: \" << months[year].join(sep) }.join('<br/>')\r\n end",
"def display_months(this_year)\n # Calculate what the last month is\n last_month = this_year.last.month\n # Return an ordered array of the past months of the fiscal year\n return last_month >= 7 ?\n last_month.downto(7).to_a :\n last_month.downto(1).to_a + 12.downto(7).to_a\n end",
"def locales_from_xlsx_sheet_row row\n locales = []\n row.each_with_index do |cell, i|\n if i > 0\n locales.push(cell.downcase)\n end\n end\n locales\n end",
"def display_month_with_year\n puts (name_of_month + \" #{@year}\").center(20) +\" \"\n puts weeks_with_year\n end",
"def get_months(place,yearselect)\r\n months = []\r\n puts \"Please select the month of #{yearselect} for #{place} you wish to view:\"\r\n filename = \"rainfall_collection.csv\"\r\n CSV.foreach(filename, headers: true) do |row| # read line by line\r\n if place == row[0] # row[0] is the place from each row\r\n if yearselect == row[1] # row[1] is the year of the collected rainfalls\r\n months << row[2] # row[1] is the year of the collected rainfalls\r\n end\r\n end\r\n end\r\n months.uniq.each_with_index {|mth, index| print \"#{index+1}\".rjust(5) +\". \" + \"#{mth}\\n\" }\r\n puts \"\"\r\n puts \"X\".rjust(5) + \". To exit\"\r\n puts \"Please select from above:\"\r\n chosen = $stdin.gets.chomp\r\n if chosen.upcase == 'X'\r\n month = nil\r\n elsif chosen.to_i > months.uniq.count\r\n puts \"Not a valid choice.\"\r\n gets\r\n month = nil\r\n else\r\n month = months[chosen.to_i-1] # the year chosen\r\n end\r\n # CSV month details into an array\r\n place_yr_mth = nil\r\n CSV.foreach(filename, headers: true) do |row| # read line by line\r\n # match on row[0] for place, row[1] for year, row[2] for month\r\n if place == row[0] && yearselect == row[1] && month == row[2]\r\n place_yr_mth = row # dump the whole row into an array\r\n end\r\n end\r\n return place_yr_mth\r\nend",
"def oz_archived_months(sep = ', ')\n year, string = 0, ''\n months = {}\n years = []\n\n Post.archived_months.map do |month| \n date = Time.parse(month)\n if date.year > year\n year = date.year\n months[year] = []\n years << year\n end\n months[year] << month_link(date.strftime('%B').downcase, month) \n end\n\n years.map { |y| \"#{y}: \" << months[year].join(sep) }.join('<br/>')\n end",
"def build_day_array(year, month)\n day_array = Array.new\n # cycle through number of days in the month and build an array with one entry per day\n for d in (1..self.days_in_month(year, month))\n day_array[d] = Line_Calendar::ABBR_DAYNAMES[self.day_in_month(year, month, d)] # populates array with abbreviated daynames\n end\n # remove the 0 entry and move everything up one\n day_array.shift\n return day_array\n end",
"def refine_month(m)\n mon = check_num_str(m)\n adjust_month(mon)\n end",
"def associated_months\n result = [] # expect no months if no dates\n years = associated_years\n \n\t start_date = event_start\n\t start_date = entry_deadline if is_opportunity?\n\t \t \n start_month_year = Time.parse(\"01/#{start_date}.month/#{start_date}.year\") if !start_date.blank?\n finish_month_year = Time.parse(\"01/#{event_finish}.month/#{event_finish}.year\") if !event_finish.blank?\n \n #this is the case when we only have a start month\n if !start_month_year.blank? and finish_month_year.blank?\n result << start_date.month\n #this is the tricky one...\n elsif !start_month_year.blank? and !finish_month_year.blank?\n delta_year = event_finish.year - start_date.year # year\n \n #if the range spans an entire year we have all the months\n if (delta_year) > 1\n result = [1,2,3,4,5,6,7,8,9,10,11,12]\n #this is the case of months being in the same year\n elsif delta_year == 0\n puts start_month_year.month\n puts finish_month_year.month\n for m in start_month_year.month..finish_month_year.month\n result << m\n end\n \n #this is the annoying one, going over new year\n elsif delta_year == 1\n #add months to year end\n for month in start_month_year.month..12\n result << month\n end\n \n #add months from start of year\n for month in 1.. finish_month_year.month\n result << month\n end \n end\n result\n end\n \n \n \n \n result\n end",
"def monthly\n keys = redis.keys(\"#{prefix_monthly}:*\")\n keys.zip(redis.mget(keys)).inject({}) { |t,p| t.merge(p.first.sub(\"#{prefix_monthly}:\", '') => p.last.to_i) }\n end",
"def format_dates\n days = (1..@number_of_days_in_month).to_a\n days.map! do |d|\n d < 10 ? \" \" + d.to_s : d.to_s\n end\n # adds blank elements to the beginning of the days array to offset the\n # first day of the month\n @first_day_of_month.times do\n blankday = \" \"\n days.unshift(blankday)\n end\n days\n end",
"def date_array(hash)\n array = []\n hash.each do |h|\n temp =[]\n h.each do |key,value|\n if key == \"month\"\n temp << value\n end\n if key == \"day\"\n temp << value\n end\n if key == \"year\"\n temp << value\n end\n end\n array << temp\n end\n return array\n end"
] | [
"0.6679028",
"0.63668233",
"0.6273568",
"0.6183829",
"0.6107074",
"0.606694",
"0.59649074",
"0.59382457",
"0.5894731",
"0.58943886",
"0.5887359",
"0.58782953",
"0.5857224",
"0.5857224",
"0.58405876",
"0.5829198",
"0.5786427",
"0.57749456",
"0.5740887",
"0.56753874",
"0.5670048",
"0.5664781",
"0.5663464",
"0.5651465",
"0.5638398",
"0.55971795",
"0.5588825",
"0.5567693",
"0.5532439",
"0.5503008",
"0.55013686",
"0.55004984",
"0.5492806",
"0.54697484",
"0.54467624",
"0.54311866",
"0.54307735",
"0.5430235",
"0.5424053",
"0.54216796",
"0.5416485",
"0.54130775",
"0.539345",
"0.53918284",
"0.5391763",
"0.53810674",
"0.5369688",
"0.53655964",
"0.53576654",
"0.5354897",
"0.5348223",
"0.53462553",
"0.5345721",
"0.5343468",
"0.5341213",
"0.53387785",
"0.5328751",
"0.5320902",
"0.53116894",
"0.5296731",
"0.52923495",
"0.529001",
"0.5289659",
"0.52884406",
"0.52858",
"0.528106",
"0.52796996",
"0.52794933",
"0.52775025",
"0.52724165",
"0.5261133",
"0.52498615",
"0.5245046",
"0.5238703",
"0.52382153",
"0.52217525",
"0.5212486",
"0.52119964",
"0.5210703",
"0.5209603",
"0.52071834",
"0.5205673",
"0.52053934",
"0.5202795",
"0.52013236",
"0.51929903",
"0.5192008",
"0.51863474",
"0.5177946",
"0.515972",
"0.5158444",
"0.51482767",
"0.5147494",
"0.5144566",
"0.5141877",
"0.51409954",
"0.5136918",
"0.5136119",
"0.5130844",
"0.5126768",
"0.5126509"
] | 0.0 | -1 |
Fetch all documents at this scope. | def all(extra_parameters = {})
klass.all(params(extra_parameters))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(*vars)\n result = Query.get self, *vars\n result.get_docs\n end",
"def all\n @document = Document.all\n end",
"def all(params={})\n scoped_attributes = self.class.scopes.inject({}){|r,k| r.merge(k.to_s => send(k))}\n scoped_attributes.merge!(params)\n body = connection.send(collection_method, scoped_attributes).body\n\n collection = self.load(body[collection_root])\n collection.merge_attributes(Cistern::Hash.slice(body, \"count\", \"next_page\", \"previous_page\"))\n collection\n end",
"def all\n include_docs!\n docs\n end",
"def all\n documents\n end",
"def fetchAllDocuments(collection)\n return collection.find({})\n end",
"def all(&block)\n args = include_docs.query\n \n end",
"def all(options={})\n @collection = query(options)\n self\n end",
"def all opts = {}\n self.generated_design_doc ||= default_design_doc\n unless design_doc_fresh\n refresh_design_doc\n end\n view_name = \"#{design_doc_slug}/all\"\n raw = opts.delete(:raw)\n fetch_view_with_docs(view_name, opts, raw)\n end",
"def all(client, opts = {})\n request = Request.new(client, :get, RESOURCE_COLLECTION, params: opts)\n Cursor.new(self, request, init_with: [client])\n end",
"def all_docs(*opts)\n q = \"#{database}/_all_docs\"\n q << build_query_string(opts.first,\"all_docs\") if opts && opts.any? && opts.first.is_a?(Hash)\n\n @conn.query({url_path: q, method: :get})\n end",
"def all; @docs.values end",
"def documents(params={})\n server.get(\"#{name}/_all_docs\", params)\n end",
"def all\n response = run\n\n while continue?(response)\n @options[:exclusive_start_key] = response.last_evaluated_key\n response = run(response)\n end\n\n @collection.deserialize(response.entities)\n end",
"def all(offset = 0, limit = 0)\n @client.get(\"/#{@model}s\", {offset: offset, limit: limit})\n end",
"def fetch\n @_fetch ||= begin\n path = @parent.build_request_path(@query_attrs)\n @parent.request(@query_attrs.merge(:_method => :get, :_path => path)) do |parsed_data, response|\n @parent.new_collection(parsed_data)\n end\n end\n end",
"def all\n @documents = Document.order(\"id DESC\").all\n end",
"def all\n repository.all(self)\n end",
"def fetch_all\n fetch_many0(nil, Array)\n end",
"def all(options = {})\n #assert_kind_of 'options', options, Hash\n query = { :name => nil }.merge!(options).merge!(:id => nil)\n result = mqlread([ query ], :cursor => !options[:limit]) \n Basuco::Collection.new(result.map { |r| Basuco::Resource.new(r) })\n end",
"def all\n raise ArgumentError, \"No type specified for query\" if @type.nil?\n\n @store.load_from_url(uri_builder.resources_uri(@type, to_query))\n end",
"def all\n load[:results]\n end",
"def promise_all\n _class_fetch_states[:all] = 'i'\n _promise_get(\"#{resource_base_uri}.json?timestamp=#{`Date.now() + Math.random()`}\").then do |response|\n collection = _convert_array_to_collection(response.json[self.to_s.underscore.pluralize])\n _class_fetch_states[:all] = 'f'\n _notify_class_observers\n warn_message = \"#{self.to_s}.all has been called. This may potentially load a lot of data and cause memory and performance problems.\"\n `console.warn(warn_message)`\n collection\n end.fail do |response|\n error_message = \"#{self.to_s}.all failed to fetch records!\"\n `console.error(error_message)`\n response\n end\n end",
"def findAndFetchDocuments(collection, query)\n return collection.find(query)\n end",
"def all\n results_from(response)\n end",
"def scan_all(*vars, &block)\n Query.elastics.scan_search(:get, self, *vars) do |result|\n block.call result.get_docs\n end\n end",
"def retrieve_all_entities\n response = self.execute(\"RetrieveAllEntities\", {\n EntityFilters: \"Entity\",\n RetrieveAsIfPublished: true\n },\n Metadata::RetrieveAllEntitiesResponse)\n end",
"def fetch_all\n klass_name = Starwars.const_get(name.split('::').last).const_get('RESOURCE_NAME')\n object = Starwars.const_get(\"#{klass_name.capitalize}\").new(url: \"#{Starwars::Base::BASE_URL}/#{klass_name}/\")\n Starwars::Request.new(resource: object, uri: object.url, params: {}).perform_request\n end",
"def index\n\n @documentable = find_resource\n @documents = @documentable.documents\n\n end",
"def all(coll)\n @db[coll].find\n end",
"def fetch_all!\n fetch_all(true)\n end",
"def all\n @collection ||= Collection.new model_name\n end",
"def all\n api_get(path)\n end",
"def all\n _register_class_observer\n if _class_fetch_states.has_key?(:all) && 'fi'.include?(_class_fetch_states[:all]) # if f_etched or i_n progress of fetching\n collection = HyperRecord::Collection.new\n _record_cache.each_value { |record| collection.push(record) }\n return collection\n end\n promise_all\n HyperRecord::Collection.new\n end",
"def list\n\t\tdocs = proxy_database.view(\"#{shared_data_context.name}/all\")[\"rows\"]\n\t\treturn docs\n \tend",
"def all\n @adapter.all(collection)\n end",
"def all(per_page = 100)\n @search.per_page(per_page).fetch\n end",
"def all\n response = request(:get_all)\n handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) }\n\n if handles.size == 1\n # Fetch data for single entity\n find(handles.first)\n elsif handles.size > 1\n # Fetch all data for all the entities\n entity_data = get_data_array(handles)\n\n # Build Entity objects and add them to the proxy\n entity_data.each do |data|\n entity = build(data)\n entity.persisted = true\n end\n end\n\n self\n end",
"def all(*args)\n find(:all, *args)\n end",
"def all(*args)\n find(:all, *args)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def all\n PaginatedResource.new(self)\n end",
"def fetch_all(options = {}, &block)\n use_callback = block_given?\n url = self.new.sync_url(options[:method] || :get, options)\n\n fetch_all_with_url url, options do |records, status_code, response|\n records.each(&:save) if options[:save]\n block.call(records, status_code, response) if use_callback\n end if !url.blank?\n end",
"def find_all\n response = fetch()\n new(response)\n end",
"def index\n @scopes = Scope.all.page(params[:page]).per(20)\n end",
"def all(params = {})\n query = params.map { |key, value| \"#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}\" }.join(\"&\")\n query = \"?\" + query unless query.empty?\n code, data = @session.get(collection_path + '.json' + query)\n data.collect { |data|\n key = @resource.name.to_s.split('::').last.downcase\n @resource.new(data[key].merge(:session => @session, :prefix => @prefix))\n }\n end",
"def get_all_fences\n @coll.find.to_a\n end",
"def get_all\n get_countries_if_necessary\n get_subjects_if_necessary\n get_qualifications_if_necessary\n end",
"def fetch_all\n self.to_a\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def all\r\n copy_and_return(@records)\r\n end",
"def documents\n @mapped_documents ||= Basecamp3::Document.all(bucket.id, id)\n end",
"def get_document_all_using_get(opts = {})\n data, _status_code, _headers = get_document_all_using_get_with_http_info(opts)\n data\n end",
"def all_docs(table)\n connection.all_docs(path(table))\n end",
"def all\n self.class.all\n end",
"def all\n results = query '*::*::*::*'\n (results.each {|r| yield r}) if block_given?\n results\n end",
"def find_all(options = {})\n construct_scope(options).to_a\n end",
"def documents\n response = API.instance.send_request('docs.getList', { :session_key => @attributes[:session_key] })\n documents = Array.new\n response.elements['/rsp/resultset'].elements.each do |doc|\n documents << Document.new(:xml => doc, :owner => self)\n end\n return documents\n end",
"def all\n @cache ||= Request.get('/data')\n\n end",
"def collection\n if @collection.empty? && @loaded == false\n @collection = forward( :\"#{@key}_fetch!\" ) || @collection || []\n @loaded = true\n end\n\n @collection\n end",
"def load_collection\n model_class.all(find_options)\n end",
"def list(scope = list_query)\n model.all(scope)\n end",
"def all(options={})\r\n find(:all, options)\r\n end",
"def all(*args)\n find(:all, *args)\n end",
"def all\n Ribs.with_handle(self.database) do |h|\n h.all(self.metadata.persistent_class.entity_name)\n end\n end",
"def all(query = nil)\n if query.nil? || (query.kind_of?(Hash) && query.empty?)\n # TODO: after adding Enumerable methods to Model, try to return self here\n new_collection(self.query)\n else\n new_collection(scoped_query(query))\n end\n end",
"def index\n @client_docs = ClientDoc.all\n end",
"def index\n @documents = current_user.documents.all\n end",
"def index\n authorize Document\n\n @documents = apply_scopes(Document).valid.all\n\n if current_user.client?\n @documents = @documents.by_belongings([current_user.id])\n end\n\n respond_with do |format|\n format.html\n format.json { render json: DocumentsDatatable.new(view_context, @documents) }\n format.js\n end\n\n end",
"def all(options={})\r\n find(:all,options)\r\n end",
"def all\n folder.data_objects.all(parameters).collect do |data_object|\n model.new(data_object)\n end\n end",
"def all\n ::ActiveRecord::Base.connection_pool.with_connection do\n execute(:all).to_a\n end\n end",
"def browse(options={})\n response = API.instance.send_request('docs.browse', options.merge(:category_id => self.scribd_id))\n documents = []\n response.elements['/rsp/result_set'].elements.each do |doc|\n documents << Document.new(:xml => doc)\n end\n return documents\n end",
"def all\n load_clients\n load_preferences\n end",
"def each\n @cursor = nil\n session = client.send(:get_session, @options)\n server = cluster.next_primary(nil, session)\n result = send_initial_query(server, session, context: Operation::Context.new(client: client, session: session))\n result = send_fetch_query(server, session) unless inline?\n @cursor = Cursor.new(view, result, server, session: session)\n if block_given?\n @cursor.each do |doc|\n yield doc\n end\n else\n @cursor.to_enum\n end\n end",
"def results\n fetch unless @results\n @results\n end",
"def index_documents\n @params = {}\n @action = 'index_documents'\n \n send_auth_request\n end",
"def all(params = {})\n Iterable.request(conf, base_path, params).get\n end",
"def all(*args, &block)\n find(:all, *args, &block)\n end",
"def clients!\n @clients = search_clients clients_doc!\n end",
"def resolve\n scope.all\n end",
"def get_all(account = nil)\n account ||= user_api.account\n @all_definitions[account] ||= RagentApi::CollectionDefinitionMapping.get_all(account)\n end",
"def docs #returns string array of all documents in collection\n raise \"Must be implemented.\"\n return array_of_documents\n end",
"def index\n @cdocuments = Cdocument.all\n end",
"def all\n if current_scope\n current_scope.clone\n else\n default_scoped\n end\n end",
"def index\n @observations = scope.all\n end",
"def all\n ContactDatabase.get_all\n end"
] | [
"0.7350431",
"0.70373404",
"0.68038696",
"0.672279",
"0.6682842",
"0.6653729",
"0.6647518",
"0.66374654",
"0.65687865",
"0.65375215",
"0.6487783",
"0.6405739",
"0.6319488",
"0.63042766",
"0.62618166",
"0.62565845",
"0.6241662",
"0.62393904",
"0.6234384",
"0.62326854",
"0.6207765",
"0.6188888",
"0.61603695",
"0.61477447",
"0.61443883",
"0.6139101",
"0.61244917",
"0.61214054",
"0.6099903",
"0.60961986",
"0.6076825",
"0.6067352",
"0.60464835",
"0.6039205",
"0.6025935",
"0.5983324",
"0.59672475",
"0.59447396",
"0.5906141",
"0.5906141",
"0.5883493",
"0.5883493",
"0.5883493",
"0.5883493",
"0.5883493",
"0.5883493",
"0.5883493",
"0.5883493",
"0.5883493",
"0.5883493",
"0.5877236",
"0.5867936",
"0.58585143",
"0.5857255",
"0.5856679",
"0.5832794",
"0.5832712",
"0.5804308",
"0.5804308",
"0.5804308",
"0.5804308",
"0.5804308",
"0.5804308",
"0.5804308",
"0.57928634",
"0.579198",
"0.57722646",
"0.57650405",
"0.5751295",
"0.5747035",
"0.57366484",
"0.57332003",
"0.57255095",
"0.5722944",
"0.5721856",
"0.571733",
"0.57005405",
"0.56894547",
"0.5680981",
"0.5673016",
"0.56595135",
"0.56566",
"0.56512326",
"0.5640041",
"0.5636769",
"0.5632326",
"0.56294954",
"0.56125665",
"0.56070685",
"0.56043303",
"0.55943674",
"0.5593623",
"0.559086",
"0.55874044",
"0.55803496",
"0.55716884",
"0.55679643",
"0.5561976",
"0.5560211",
"0.55588436",
"0.55575675"
] | 0.0 | -1 |
Fetch the first document at this scope. | def first(extra_parameters = {})
klass.first(params(extra_parameters))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first\n find.limit(1).next_document\n end",
"def first\n response = query(:per_page => 1, :page => 1).get!\n response[:results].first\n end",
"def first(*args)\n query = scoped_query(args.last.respond_to?(:merge) ? args.pop : {})\n\n if args.any?\n new_collection(query).first(*args)\n else\n query.repository.read(query.update(:limit => 1)).first\n end\n end",
"def first(*vars)\n result = Query.get params(:size => 1), *vars\n docs = result.get_docs\n docs.is_a?(Array) ? docs.first : docs\n end",
"def first!\n first or raise RecordNotFound\n end",
"def first(query={})\n document = Driver.client[coll_name].find(query).first\n self.new(document) if document\n end",
"def first(&block)\n args = limit(1).include_docs.query\n\n end",
"def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def first!\n first || raise_record_not_found_exception!\n end",
"def first\n return nil unless first_page_uri\n perform_request(first_page_uri)\n end",
"def first\n\n wi(fetch_all({}).first)\n end",
"def first\n self.all.first\n end",
"def first\n self.all.first\n end",
"def first\n result ? all.first : limit(1).all.first\n end",
"def one\n attributes = klass.collection.find_one(selector, process_options)\n attributes ? Mongoid::Factory.from_db(klass, attributes) : nil\n end",
"def find_first(options = {})\n construct_scope(options).first\n end",
"def find_one(options = {})\n @find_one ||=\n if primary_key_set?\n without_collection_params { super() }\n else\n klass.new_collection_from_result(limit(1).fetch(options)).first\n end\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def first\n results.first\n end",
"def first; self.objects.first end",
"def first\n @adapter.first(collection)\n end",
"def find_one(opts={})\n unless @site\n document = super\n return nil if document.nil?\n @constructor.load(document)\n else\n query = clone.amend(opts)\n \n # construct the criteria hash, and remove the keys allowed by a cacheable lookup\n criteria_hash = query.criteria.to_hash\n id = criteria_hash[:_id]\n keys = criteria_hash.keys\n keys -= [:_id, :_site_id, :model]\n \n # queries are cacheable if they are looking for a single ID\n cacheable = !id.nil? && id.is_a?(BSON::ObjectId) && keys.empty?\n \n # lookup the record in the cache\n if cacheable\n record = @site.cached_records[id]\n return record unless record.nil?\n end\n \n # lookup failed, so perform a query\n record = query.collection.find_one(criteria_hash, query.options.to_hash)\n if record\n record = @constructor.load(@site, record)\n @site.cached_records[id] = record if cacheable\n end\n \n record\n end\n end",
"def first\n graph.first_object(subject: first_subject, predicate: RDF.first)\n end",
"def fetch_first(&block)\n Volt.logger.warn('.fetch_first is deprecated in favor of .first')\n first\n end",
"def document\n documents.first\n end",
"def first_object(query, kwargs = {})\n objs = objects(query, kwargs)\n return objs.length > 0 ? objs[0] : nil\n end",
"def find(id)\n repository.find(id).documents.first\n end",
"def first(options={})\r\n find(:first, options)\r\n end",
"def find_one(query={}, opts={})\n return nil unless doc = self.collection.find_one(query, opts)\n self.new(doc, false)\n end",
"def first(*args)\n find(:first, *args)\n end",
"def first(*args)\n last_arg = args.last\n\n limit = args.first if args.first.kind_of?(Integer)\n with_query = last_arg.respond_to?(:merge) && !last_arg.blank?\n\n query = with_query ? last_arg : {}\n query = scoped_query(query.merge(:limit => limit || 1))\n\n if !with_query && (loaded? || lazy_possible?(head, limit || 1))\n if limit\n new_collection(query, super(limit))\n else\n super()\n end\n else\n if limit\n all(query)\n else\n relate_resource(query.repository.read_one(query))\n end\n end\n end",
"def find_single(scope, options)\n context = options[:context] || {}\n reload_fields_definition(false)\n fields = options[:fields] || options[:only] || fast_fields(options)\n fields += options[:include] if options[:include]\n \n if scope\n is_collection, records = read_scope(context, fields, scope)\n else\n is_collection, records = read_domain(context, fields, options)\n end\n active_resources = []\n records.each { |record| active_resources << new(record, [], true)}\n if is_collection\n active_resources\n else\n active_resources[0]\n end\n end",
"def find_first(name)\n object = build(name)\n object.retrieve\n end",
"def first_or_initialize(attrs = {})\n fetch.first || build(attrs)\n end",
"def first\n perform_request(first_page_uri) if first_page_uri\n end",
"def first(opts={})\n sq = Tripod::SparqlQuery.new(self.as_query(opts))\n first_sparql = sq.as_first_query_str\n self.resource_class._resources_from_sparql(first_sparql).first\n end",
"def first!\n fail_not_found_if_nil(first)\n end",
"def first_instance\n params(limit: 1).all.first\n end",
"def first\n document.new? ? document.clone.extend(VersionedDocument) : self[all_preceding_versions.last]\n end",
"def fetch(id)\n search(id: id)[:records].first\n end",
"def first\n all.first\n end",
"def first\n\t\trow = connection.get_first_row <<-SQL\n\t\t\tSELECT #{columns.join \",\"} FROM #{table}\n\t\t\tORDER BY id ASC LIMIT 1;\n\t\tSQL\n\t\tinit_object_from_row(row)\n\tend",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def fetch\n @fetched_record = nil\n return nil if @index >= @records.size\n rec = @records[@index]\n @index += 1\n @fetched_record = rec\n return rec\n end",
"def first(*args)\n find(:first, *args)\n end",
"def first(*args)\n find(:first, *args)\n end",
"def first(spec)\n spec.view_parameters = spec.view_parameters.merge({:limit => 1})\n view(spec).first\n end",
"def results(reply)\n reply.documents.first\n end",
"def get_one(query)\n res = get_all_by_query(query)\n return nil if res.length == 0\n res[0]\n end",
"def first\n resources.first\n end",
"def first_book\n Book.find(:first)\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n # Modify the @next url to set the :limit to 1\n original_next = @next\n @next = @path\n fetch_next!(@options.merge(params: @options.fetch(:params, {}).merge({ limit: 1 })))\n # Restore the @next url to the original\n @next = original_next\n @data.first\n end",
"def first\n return sync { @first }\n end",
"def fetch(dn = self.dn, options = {}) #:nodoc:\n find_one(dn, options)\n end",
"def first\n self.take(1)[0]\n end",
"def find_first(*args)\n id = get_range(:count => 1, *args).first\n id && find_one(id, *args)\n end",
"def one\n if size == 0\n raise \"Could not find any records\"\n elsif size > 1\n raise \"Search returned multiple records when only one was expected\"\n else\n first\n end\n end",
"def read_one\n synchronize {\n read_many.slice!(0)\n }\n end",
"def fetch\n @_fetch ||= begin\n path = @parent.build_request_path(@query_attrs)\n @parent.request(@query_attrs.merge(:_method => :get, :_path => path)) do |parsed_data, response|\n @parent.new_collection(parsed_data)\n end\n end\n end",
"def first\n limit(1).to_a.first\n end",
"def first\r\n\t\[email protected]\r\n\tend",
"def get_first_row(*args)\n @db.get_first_row(*args)\n end",
"def first(conditions = {})\n new(conditions.merge(Connection.get(create_route(:get, conditions)).body['data']))\n end",
"def first\n @cursor_instance.jump( nil )\n return current\n end",
"def find_single(scope, options, instantiate=true)\n prefix_options, query_options = split_options(options[:params])\n path = element_path(scope, prefix_options, query_options)\n record = format.decode(connection.get(path, headers).body)\n if instantiate\n instantiate_record(record, prefix_options)\n else\n record\n end\n end",
"def first\n enumerator(:limit => 1).first \n end",
"def first\n lock {\n first_id = resolve_steps(:first)\n first_id.nil? ? nil : _load(first_id)\n }\n end",
"def first_page\n previous_page? ? updated_collection(from: from, page: { number: 1 }) : self\n end",
"def find_one(spec)\n doc = collection.find(spec.is_a?(Hash) ? spec : {}.merge('_id' => spec)).first\n new(doc) if doc\n end",
"def first() end",
"def find_first(selector={}, options={})\n h = options.dup\n h[:limit] = 1\n cursor = find(selector, h)\n cursor.next_object # don't need to explicitly close b/c of limit\n end",
"def select_first!\n limit(1).select!.first\n end",
"def get_single_doc_via_search(extra_controller_params={})\n solr_params = solr_search_params(extra_controller_params)\n solr_params[:per_page] = 1\n solr_params[:fl] = '*'\n Blacklight.solr.find(solr_params).docs.first\n end",
"def find_single(scope, options)\r\n query = \"/#{@doctype}[@ino:id=#{scope}]\" \r\n \r\n if result = connection.query(query)\r\n connection.getResultDomNode\r\n xml = connection.getResultDomNode\r\n if (result = REXML::XPath.first(xml, \"//a:result\", {\"a\" => \"http://metalab.unc.edu/xql/\"}) rescue false)\r\n new(Hash.from_xml(result.children.first.to_s).values.first)\r\n else\r\n nil\r\n end\r\n else\r\n raise \"Query failed.\"\r\n end\r\n end",
"def find\n super.first\n end",
"def next\n Expression.where('id > ? AND collection_id = ?', self.id, self.collection_id).order('id ASC').limit(1).first\n end",
"def find_core_document\n return unless (core_doc = find_resource)\n return if core_doc.foundational?\n\n core_doc\n end",
"def first!(spec)\n first(spec) || raise(CouchPotato::NotFound)\n end",
"def first\n response = $es.search index: es_type_name, type: es_type_name, body: { size: 1, query: { match_all: { } }, sort: [{created_at: 'asc'}] }\n mpages = instantiate_results(response)\n mpages.last\n end",
"def sample\n self.class.collection.find.first\n end",
"def find(query)\n @coll.find(query).first\n end",
"def first_page\n Page.find(self.first_page_id)\n end",
"def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end",
"def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end",
"def find_one(criteria, options = {})\n criteria = normalize_criteria criteria\n hash = self.collection.find_one(criteria, options)\n self.normalize(hash) if hash\n end",
"def one(*args)\n find(:one, *args)\n end",
"def find_first(conditions = nil, orderings = nil)\n sql = \"SELECT * FROM #{table_name} \"\n add_conditions!(sql, conditions)\n sql << \"ORDER BY #{orderings} \" unless orderings.nil?\n sql << \"LIMIT 1\"\n \n record = connection.select_one(sql, \"#{name} Load First\")\n instantiate(record) unless record.nil?\n end",
"def current_final_legal_document\n final_legal_documents.where.not(published_at: nil).order(published_at: :desc).limit(1).first\n end",
"def first(n=1)\n return values[0] if self.class == BaseRelation && loaded && n == 1\n result = limit(n).load\n result.length == 1 ? result[0] : result\n end",
"def find_single(scope, options)\n fields = options[:fields] || []\n context = options[:context] || {}\n prefix_options, query_options = split_options(options[:params])\n is_collection = true\n if !scope.is_a? Array\n scope = [scope]\n is_collection = false\n end\n records = rpc_execute('read', scope, fields, context)\n active_resources = []\n records.each do |record|\n r = {}\n record.each_pair do |k,v|\n r[k.to_sym] = v\n end\n active_resources << instantiate_record(r, prefix_options)\n end\n unless is_collection\n return active_resources[0]\n end\n return active_resources\n end",
"def first( n=nil )\n\t\tresults = self.branch.search( self.scope, self.filter,\n\t\t\t:selectattrs => self.select,\n\t\t\t:timeout => self.timeout,\n\t\t\t# :sortby => self.order,\n\t\t\t:client_controls => self.get_client_controls,\n\t\t\t:server_controls => self.get_server_controls,\n\t\t\t:limit => n || 1\n\t\t )\n\n\t\tif n\n\t\t\treturn results.first( n )\n\t\telse\n\t\t\treturn results.first\n\t\tend\n\tend",
"def this\n @this ||= dataset.filter(pk_hash).limit(1).naked\n end",
"def single_record!\n if use_eager_all?\n obj = clone(:all_called=>true).all.first\n\n if opts[:eager_graph]\n obj = clone(:all_called=>true).where(obj.qualified_pk_hash).unlimited.all.first\n end\n\n obj\n else\n super\n end\n end",
"def fetch_one(id, extra_controller_params)\n puts \"fetch one search helper\"\n old_solr_doc_params = Deprecation.silence(Blacklight::SearchHelper) do\n solr_doc_params(id)\n end\n\n if default_solr_doc_params(id) != old_solr_doc_params\n Deprecation.warn Blacklight::SearchHelper, \"The #solr_doc_params method is deprecated. Instead, you should provide a custom SolrRepository implementation for the additional behavior you're offering. The current behavior will be removed in Blacklight 6.0\"\n extra_controller_params = extra_controller_params.merge(old_solr_doc_params)\n end\n \n #Override id\n if params[\"DocId\"]\n id = params[\"DocId\"]\n #Rails.logger.debug(\"Found DocID #{params['DocId'].inspect} and id is #{id.inspect}\")\n else \n id ||= params[:id]\n #Rails.logger.debug(\"Using other id\")\n end\n \n\n solr_response = repository.find id, extra_controller_params\n [solr_response, solr_response.documents.first]\n end",
"def first\n self.class.where(id: rid).chronological.first\n end",
"def first\n model[key.call(\"LINDEX\", 0)]\n end"
] | [
"0.75297153",
"0.72958803",
"0.70266074",
"0.70233303",
"0.6916869",
"0.68905544",
"0.68613297",
"0.68105555",
"0.67515945",
"0.66868764",
"0.6680791",
"0.66408634",
"0.66088617",
"0.6588913",
"0.65075207",
"0.64805984",
"0.6478315",
"0.6474067",
"0.64712924",
"0.6463976",
"0.6444681",
"0.64227676",
"0.64019173",
"0.6384971",
"0.6374655",
"0.62810487",
"0.62639743",
"0.6222829",
"0.6208835",
"0.6177166",
"0.6173883",
"0.6150646",
"0.6140642",
"0.61305463",
"0.61150837",
"0.61147237",
"0.6097435",
"0.60702956",
"0.60451704",
"0.6041704",
"0.60405684",
"0.60149527",
"0.60149527",
"0.60149527",
"0.60092884",
"0.59968174",
"0.59968174",
"0.5992944",
"0.5987417",
"0.5963681",
"0.59632313",
"0.59502155",
"0.5932065",
"0.5932065",
"0.5932065",
"0.5932065",
"0.59005386",
"0.58994305",
"0.5885243",
"0.58830833",
"0.5882203",
"0.58798194",
"0.58657795",
"0.585231",
"0.5842",
"0.58415216",
"0.58268535",
"0.5823139",
"0.58214873",
"0.5811184",
"0.58099943",
"0.58019793",
"0.5763445",
"0.5762479",
"0.57464236",
"0.57418406",
"0.5739444",
"0.5734407",
"0.57317",
"0.57262874",
"0.57117146",
"0.56930363",
"0.5685607",
"0.5680575",
"0.5676899",
"0.5667308",
"0.5658015",
"0.565088",
"0.565088",
"0.564163",
"0.56401676",
"0.5638154",
"0.5631228",
"0.56277794",
"0.5621093",
"0.560902",
"0.5605924",
"0.55961597",
"0.5591107",
"0.5563282",
"0.5561032"
] | 0.0 | -1 |
Paginate the documents at this scope. | def paginate(extra_parameters = {})
klass.paginate(params(extra_parameters))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paginate(options={})\n populate_pagination_attributes_from_options(options)\n limit(per_page)\n offset((page - 1) * per_page)\n self\n end",
"def paginate(options={})\n page = [options[:page].to_i, 1].max\n per_page = (options[:per_page] || per_page).to_i\n request[:args].update(start: (page - 1) * per_page, hit: per_page)\n self\n end",
"def paginate\n paginated?? self : page(1)\n end",
"def with_pagination(pagination_params)\n scoped(:offset => pagination_params.start_index - 1, :limit => pagination_params.items_per_page)\n end",
"def paginated(options = {})\n @klass.new(@full_collection, options).paginate\n end",
"def paginate!(*args) # @private :nodoc:\n options = args.extract_options!\n self.items_per_page = options[:per_page] || 50\n self.current_page = args.first || 1\n self.limit_value = items_per_page\n self.offset_value = items_per_page * (current_page - 1)\n end",
"def paginate\n @people = Person.paginate(page: page, per_page: 10) if scope_params.blank?\n end",
"def paginate(options)\n proxy = create_collection_proxy(options)\n proxy.paginate(options)\n end",
"def paginate(options = {})\n raise ArgumentError, \"parameter hash expected (got #{options.inspect})\" unless Hash === options\n\n page = (options[:page] || 1).to_i\n per_page = (options[:per_page] || 30).to_i\n\n @total_entries = count\n @total_pages = (@total_entries / per_page.to_f).ceil\n @current_page = page\n\n query.update(offset: (page - 1) * per_page, limit: per_page)\n\n self\n end",
"def paginate opts = {}\n @paginator = true\n page = (opts[:page] || 1).to_i\n per_page = (opts[:per_page] || 20).to_i\n page = 1 if page < 1\n limit( per_page, ( page - 1 ) * per_page )\n end",
"def paginate(*args)\n @list.paginate(*args)\n end",
"def paginate(opts)\n resource\n end",
"def paginate_collection!\n set_collection get_collection.page(params[:page]).per(self.class.per_page)\n end",
"def paginate(*args)\n options = args.last.is_a?(::Hash) ? args.pop : {}\n page = options.delete(:page) || 1\n items_per_page = options.delete(:per_page) || self.per_page\n finder = (options.delete(:finder) || 'get').to_s\n page_options = {\n \"_pagination\" => 1,\n \"_limit\" => items_per_page,\n \"_page\" => page\n }\n options.merge!(page_options)\n args << options\n collection = send(finder,*args)\n end",
"def paginated_each(options, &block)\n search = options.delete(:search)\n unless search == true\n proxy = create_collection_proxy(options)\n else\n proxy = create_search_collection_proxy(options)\n end\n proxy.paginated_each(options, &block)\n end",
"def paginator\n per_page = @ruhoh.db.config(\"paginator\")[\"per_page\"]\n current_page = master.context[\"page\"]['current_page'].to_i rescue 0\n current_page = current_page.zero? ? 1 : current_page\n offset = (current_page-1)*per_page\n\n page_batch = all[offset, per_page]\n raise \"Page does not exist\" unless page_batch\n page_batch\n end",
"def page(num = 1)\n num = 1 if num < 1\n num = @pages if num > @pages\n\n @page_number = num\n\n # offset n is the n+1 record\n start = (@page_number - 1) * @page_size\n\n @paged_filtered_rset = @filtered_rset.offset(start).limit(@page_size)\n\n self\n end",
"def paginate!(curr_page)\n return if !hard_paginate?\n @page = curr_page.to_i\n raise ArgumentError if @page < 1 || @page > total_pages\n adj_page = @page - 1 > 0 ? @page - 1 : 0 \n @prev_page = adj_page > 0 ? adj_page : nil\n @next_page = page < total_pages ? (@page + 1) : nil\n @data.only!(adj_page * per_page..(@page * per_page - 1))\n end",
"def paginate(options={})\n pg_options, find_options = options.partition{|k,v| [:page, :per_page, :total_entries].include?(k)}\n \n pg_options[:page] ||= 1\n pg_options[:per_page] ||= per_page\n \n WillPaginate::Collection.create(pg_options[:page], pg_options[:per_page], pg_options[:total_entries]) do |pager|\n find_options[:params] = (find_options[:params] || {}).merge(:offset => pager.offset, :limit => pager.per_page) \n \n arr = find(:all, find_options) || []\n if pg_options[:total_entries]\n pager.total_entries = pg_options[:total_entries]\n else \n pager.total_entries = arr.size > pager.per_page ? arr.size : count(find_options[:params])\n end\n \n if arr.size > per_page\n pager.replace arr[pager.offset, pager.per_page]\n else\n pager.replace arr\n end\n end\n end",
"def paginate(collection)\n will_paginate(collection, :inner_window => 2)\n end",
"def paginate method=:all, options={}\r\n if method.is_a? Hash\r\n options = method\r\n method= :all\r\n end\r\n if @scope\r\n model_class.send(:with_scope, @scope) { model_class.paginate method, find_options(options) }\r\n else\r\n model_class.paginate method, find_options(options)\r\n end\r\n end",
"def paginate!\n paginated?? nil : page!(1)\n end",
"def paginate klass, force = true\n dataset = ordered(klass).limit(PAGE_LIMIT + 1).offset((page - 1) * PAGE_LIMIT)\n force ? dataset.all : dataset\n end",
"def execute(paginating = false)\n limit(documents.select { |document| document.matches?(selector) })\n end",
"def paginate(options = {})\n page = options.delete(:page) || raise(ArgumentError, \"paginate requires a :page argument\")\n per_page = options.delete(:per_page)\n raise ArgumentError, \"unknown argument #{options.keys.first.inspect} passed to paginate\" unless options.empty?\n @query.paginate(page, per_page)\n end",
"def paginate opts = { }\n @paginate ||= \n begin\n # self.sql sets self.model_class.\n this_sql = sql\n model_class.\n paginate_by_sql(this_sql, opts)\n end\n end",
"def paginate(resources)\n resources.paginate(\n page: page_params[:page],\n per_page: page_params[:per]\n )\n end",
"def paginate_by(relation, page = 1, count = PER_PAGE)\n relation.page(page).per(count)\n end",
"def paginate_with(name, pagination = nil)\n representer.paginate_with(self, name, pagination)\n end",
"def paginate\n raise NoMethodError.new('paginate')\n end",
"def find_documents!(model, page, items_per_page)\n conditions = params.empty? ? {} : make_conditions(params, model)\n model.all(conditions.merge({\n :skip => items_per_page * (page - 1),\n :limit => items_per_page\n }))\n end",
"def add_pagination(params, scope = self.all)\n if params[:page] || params[:per_page]\n scope = scope.paginate(\n page: params[:page] || 1,\n per_page: params[:per_page] || 20\n )\n end\n return scope\n end",
"def paginate_questions\n paginate(@questions)\n end",
"def paginated(relation,options= {})\n start=options[:start]\n limit=options[:limit]\n default_limit=options[:default_limit]||100\n start = start.is_a?(Integer) ? start : (params[:start] || 0).to_i\n limit = limit.is_a?(Integer) ? limit : (params[:limit] || default_limit).to_i\n relation.offset(start).limit(limit)\n end",
"def paginator; end",
"def apply_pagination(data)\n data = data.paginate(page: params[:page], per_page: params[:limit])\n end",
"def page_collection!\n return unless paginate\n\n page = params[:page].to_i\n page = 1 if page.zero?\n page_size = params[:page_size].to_i\n page_size = DEFAULT_PAGE_SIZE if page_size <= 0\n self.collection = collection.page(page).per(page_size)\n end",
"def paginated_collected(options = {})\n paginated(options)\n end",
"def paginate( options = {} )\n pp = options.delete(:per_page) || per_page\n all = options.delete(:all)\n\n options.delete(:category_id) if options[:category_id].nil?\n\n count = count_for( all, options[:category_id] )\n\n Paginator.new( count, per_page ) do |offset, per_page|\n all( default_options.merge(options).merge( :limit => pp, :offset => offset ) )\n end\n end",
"def paginate(current_page, request = nil)\n changed\n @page_criteria = dbi.paginate(current_page,@per_page,:request => request, :pagination_method => @pagination_method)\n notify_observers(:paginate,self,request)\n @page_criteria\n end",
"def paginated_products\n p = self.products.where(:admin_validation => true)\n unless self.page.blank?\n p.page(self.page)\n end\n end",
"def paginate(what, where, options={})\n default_options = @@default_options.merge({ :page => 1, :limit => @@jobs_per_page })\n options[:limit] = options[:per_page] if options[:per_page]\n opts = default_options.merge(options)\n results = self::Collection.create(opts[:page], opts[:limit]) do |pager|\n opts[:limit] = pager.per_page\n opts[:start] = pager.offset\n result = self.api_search(what, where, opts)\n pager.replace(result) # inject the result array into the paginated collection\n unless pager.total_entries # the pager didn't manage to guess the total count, do it manually\n pager.total_entries = pager.totalresults\n end\n pager.total_entries = 1000 if pager.total_entries > 1000 # limits number of jobs to 1000 (max that Indeed API returns)\n end\n end",
"def do_pagination\n @page_number = 1\n if params[:page] && params[:page].to_i > 0\n @page_number = params[:page].to_i\n end\n @pagination = true\n @pagination_options = { :limit => items_per_page, :offset => (@page_number - 1) * items_per_page }\n @pagination_options = {} if params[:all]\n end",
"def paginate(page = 1, per_page = 25)\n if Object.const_defined?(\"WillPaginate\")\n WillPaginate::Collection.create(page, per_page, count) do |pager|\n pager.replace(self[pager.offset, pager.per_page]).to_a\n end\n elsif Object.const_defined?(\"Kaminari\")\n Kaminari.paginate_array(self).page(page).per(per_page)\n else\n self\n end\n end",
"def page (page = 1)\n\t \tdiff = (page - 1) * 10\n\t \tall.offset(diff).limit(10)\n\t end",
"def paginate_with(kind)\n @pagination ||=\n case kind\n when :paginator then paginator\n when :range then pagination_range\n end\n end",
"def paginate(query)\n paginatable =\n params[:page] || params[:per] || request.format.symbol == :html\n paginatable ? current_model_service.paginate(query, params) : query\n end",
"def set_paginate\n @current_page = get_current_page\n\n # TODO: This is written a few times.\n\n if @timekeeper.count > 0\n @page_results = WillPaginate::Collection.create(@current_page, 10, @timekeeper.count) do |pager|\n @start = (@current_page - 1) * 10\n # @start = (@current_page)*get_timekeeper_page_size\n pager.replace @timekeeper.to_a[@start, 10]\n end\n end\n end",
"def myFreeServices_paginate(curr_page)\n services = self.services # Verificar que servicios presta el tecnico\n peticiones = Request.where( service_id: services.ids ) # Consultar a qué peticiones puede aplicar\n peticiones.paginate(page: curr_page, per_page: 10) # Páginar los resultados\n end",
"def pages\n results_per_page = 10.0 # make this float so when we compute pages, we get right value\n page = params[:id].to_i - 1 # for page 1, minus 1 to get records with 0 offset\n @tweets = Tweet.offset( results_per_page * page ).take( results_per_page ); # get records offset by page id\n @pages = (Tweet.count / results_per_page).ceil\n @page = params[:id].to_i\n end",
"def pagination_from(collection)\n collection.offset_value + 1\n end",
"def paginate\n @max_pages = (@transactions_all.size/TRANSACTIONS_PER_PAGE) + 1\n if(@max_pages == 0)\n @max_pages = 1 # Because @max_pages indexes from 0, if its 0 change it to 1\n end\n\n # Boundary conditions for pages, a user should not be able to paginate under 0 or over the max limit\n if(@page >= @max_pages || @page < 0)\n redirect_to transactions_path\n end\n end",
"def pagination\n Pagination.new( total_items, search_args)\n end",
"def paginate(page: nil, per: nil)\n page = (page.to_i > 0) ? page.to_i : 1\n per = (per.to_i > 0) ? per.to_i : DEFAULT_PER_PAGE\n\n offset = (page - 1) * per\n\n query do\n offset(offset).limit(per)\n end\n end",
"def paginate_at ()\n return 8\n end",
"def paginate_items(items)\n paginated_items = items.paginate(paginate_options)\n next_page_exists = paginated_items.length > @limit || paginated_items.next_page\n add_link_header(offset: (offset + 1)) if next_page_exists\n paginated_items[0..(@limit - 1)] # get paginated_collection of length 'limit'\n end",
"def paginate(arg, options = {})\n if arg.instance_of?(Symbol) or arg.instance_of?(String)\n # Use default paginate function.\n collection_id = arg # arg is, e.g., :specs or \"specs\"\n super(collection_id, options)\n else\n # Paginate by hand.\n items = arg # arg is a list of items, e.g., users\n items_per_page = options[:per_page] || 10\n page = (params[:page] || 1).to_i\n result_pages = Paginator.new(self, items.length, items_per_page, page)\n offset = (page - 1) * items_per_page\n [result_pages, items[offset..(offset + items_per_page - 1)]]\n end\n end",
"def paginate(collection)\n page_size = params.dig(:page, :size)&.to_i\n page_number = params.dig(:page, :number)&.to_i\n return collection unless page_size && page_number\n\n Jaf::Pagination.filter(collection, size: page_size, number: page_number)\n end",
"def paginate_by_filter(opts={})\n paginate(filter_and_sort_options(opts))\n end",
"def paginate(relation, options = {})\n relation.paginate({ page: params[:page] }.merge(options))\n end",
"def pages(options={}, page=0, limit=15, do_iterate=false, with_attachments=false)\n $stderr.puts \"[debug] pages(options=#{options}, page=#{page}, limit=#{limit}, do_iterate=#{do_iterate})\" if @debug\n opts = options.dup\n max_rows = max_numrows(opts)\n $stderr.puts \"[debug] pages() max_rows=#{max_rows}\" if @debug\n \n opts[\"limit\"] = limit\n if options.has_key?(\"group\") and options[\"group\"].to_s == \"true\"\n opts.delete(\"reduce\")\n opts.delete(\"include_docs\")\n else\n opts.delete(\"group\")\n opts[\"reduce\"] = \"false\"\n end\n \n yield_skip_page(limit, max_rows, page) do |i_limit, skip, current_page, max_page|\n opts[\"skip\"] = skip\n opts[\"limit\"] = i_limit\n uri = gen_view_uri(opts)\n $stderr.puts \"[debug] pages() uri=#{uri}\" if @debug\n \n resset = YALTools::YaJsonRows.new(@couch, @dbname)\n json = @couch.get(uri)\n json.has_key?(\"rows\") and yield_rows(json[\"rows\"]) do |doc|\n if with_attachments and doc.has_key?(\"_attachments\")\n resset << get_page_with_attachment(doc) \n else\n resset << doc\n end\n end\n if do_iterate\n yield [resset, skip, current_page, max_page ,max_rows]\n else\n return [resset, skip, current_page, max_page ,max_rows]\n end\n end\n ## return [YALTools::YaJsonRows.new(@couch, @dbname), opts[\"skip\"], 0,0,0]\n end",
"def all(params={})\n scoped_attributes = self.class.scopes.inject({}){|r,k| r.merge(k.to_s => send(k))}\n scoped_attributes.merge!(params)\n body = connection.send(collection_method, scoped_attributes).body\n\n collection = self.load(body[collection_root])\n collection.merge_attributes(Cistern::Hash.slice(body, \"count\", \"next_page\", \"previous_page\"))\n collection\n end",
"def paginate(type, request, ds, opts={})\n return ds.all if opts[:all_results]\n limit = limit_for(type, request)\n %r{\\/(\\d+)\\z} =~ request.env['PATH_INFO']\n offset = (($1||1).to_i - 1) * limit\n objs = ds.limit(limit+1, (offset if offset > 0)).all\n next_page = false\n if objs.length > limit\n next_page = true\n objs.pop\n end\n [next_page, objs]\n end",
"def controller_paginated_json(records, options={})\r\n controller_as_paginated_json(records, options)\r\n end",
"def paginate(*args, &block)\n options = args.pop\n page, per_page, total_entries = wp_parse_options(options)\n\n WillPaginate::Collection.create(page, per_page, total_entries) do |pager|\n query_options = options.except :page, :per_page, :total_entries\n wp_query(query_options, pager, args, &block)\n end\n end",
"def paginate\n @max_pages = (@transactions.size/TRANSACTIONS_PER_PAGE) + 1\n if(@max_pages == 0)\n @max_pages = 1 # Because @max_pages indexes from 0, if its 0 change it to 1\n end\n\n # Boundary conditions for pages, a user should not be able to paginate under 0 or over the max limit\n if(@page >= @max_pages || @page < 0)\n redirect_to admin_transactions_path\n end\n end",
"def paginate(cursor, opts)\n\n opts = Ruote.keys_to_s(opts)\n\n return cursor.count if opts['count']\n\n cursor.sort(\n '_id', opts['descending'] ? Mongo::DESCENDING : Mongo::ASCENDING)\n\n cursor.skip(opts['skip'])\n cursor.limit(opts['limit'])\n\n from_mongo(cursor.to_a)\n end",
"def paginated_scope(relation)\n instance_variable_set(\"@projects\", relation.paginate(:page => params[:page], :per_page => 10))\n end",
"def paginate; false; end",
"def auto_paginate\n ENV['KARATEKIT_AUTO_PAGINATE']\n end",
"def paginate_collection(collection, options = {})\n default_options = {:per_page => 10, :page => 1}\n options = default_options.merge options\n\n pages = Paginator.new self, collection.size, options[:per_page], options[:page]\n first = pages.current.offset\n last = [first + options[:per_page], collection.size].min\n slice = collection[first...last]\n return [pages, slice]\n end",
"def paginate_collection(collection, options = {})\n default_options = {:per_page => 10, :page => 1}\n options = default_options.merge options\n\n pages = Paginator.new self, collection.size, options[:per_page], options[:page]\n first = pages.current.offset\n last = [first + options[:per_page], collection.size].min\n slice = collection[first...last]\n return [pages, slice]\n end",
"def page(num)\n @query[:page] = num\n self\n end",
"def page(num)\n @query[:page] = num\n self\n end",
"def paginate_control collection\n previous_query = '?' + URI.escape(request.params.update('page' => collection.page - 1).map{|*a| a.join('=')}.join('&')).to_s\n previous_url = URI.parse(request.url).merge(previous_query).to_s\n\n next_query = '?' + URI.escape(request.params.update('page' => collection.page + 1).map{|*a| a.join('=')}.join('&')).to_s\n next_url = URI.parse(request.url).merge(next_query).to_s\n\n haml(paginate_control_haml, locals: {collection: collection, previous_url: previous_url, next_url: next_url}, layout: false)\n end",
"def paginate\n @max_pages = (@accounts.size/ACCOUNTS_PER_PAGE) + 1\n if(@max_pages == 0)\n @max_pages = 1 # Because @max_pages indexes from 0, if its 0 change it to 1\n end\n\n # Boundary conditions for pages, a user should not be able to paginate under 0 or over the max limit\n if(@page >= @max_pages || @page < 0)\n redirect_to admin_accounts_path\n end\n end",
"def paginated(collection, options = {})\n respond_with_object_and_type collection, options, :paginated, false\n end",
"def index\n @requests = Request.all.paginate(page: params[:page], per_page: 15)\n end",
"def next_page\n next_page? ? updated_collection(next_page_params.merge(from: from)) : self\n end",
"def paginate(page = 1, per_page = 20, count = nil)\n define_singleton_method(:current_page) { page }\n define_singleton_method(:limit_value) { per_page }\n define_singleton_method(:total_results) { count || 0 }\n define_singleton_method(:total_pages) { ((count || size).to_f / per_page).ceil }\n\n self\n end",
"def apply_paging(query, offset, limit)\n validate_paging(offset, limit)\n query.offset(offset).limit(limit)\n end",
"def index\n @corpus = apply_scopes(Corpu).paginate(:per_page => 3, :page => 1)\n end",
"def ensure_paginated(objs)\n if !objs.respond_to?(:total_entries) && objs.respond_to?(:paginate)\n objs.paginate(:page => 1, :per_page => 1000000)\n else\n objs\n end\n end",
"def per_page(limit)\n @size = limit.to_i\n @current_page ||= 1\n self\n end",
"def pagy_get_items(collection, pagy)\n # this should work with ActiveRecord, Sequel, Mongoid...\n collection.offset(pagy.offset).limit(pagy.items)\n end",
"def paginate(page, per, options = {})\n pagination_builder = PaginationBuilder.new(self, page, per, options)\n pagination_builder.create_page\n end",
"def paginate(collection_id, options={})\r\n if collection_id.is_a? Array\r\n per_page = options[:per_page] || 10 \r\n parameter = options[:parameter] || 'page'\r\n current_page = params[parameter]\r\n paginator = Paginator.new self,collection_id.size,per_page,current_page \r\n return [paginator,collection_id[paginator.current_page.offset..paginator.current_page.offset+per_page-1]] \r\n end\r\n super(collection_id,options)\r\n end",
"def paginator=(_arg0); end",
"def per_page(pp = 20)\n @query[:count] = pp\n return self\n end",
"def index\n respond_with(@pages = Page.all.paginate(:page => params[:page] || 1, :per_page => params[:per_page] || 5))\n end",
"def paginate(paginator, args = {})\n instantiate(paginate_ids(paginator), args)\n end",
"def paginate(collection, page_num, per_page=5)\n num_pages = (collection.count.to_f / per_page).ceil\n page_num = page_num.to_i\n\n # fix wonky client requests\n page_num = 1 if page_num.nil? || page_num <= 0\n page_num = num_pages if page_num > num_pages\n\n collection.slice((page_num - 1) * per_page, per_page)\nend",
"def paginate(num)\n l = sorted_articles\n npages = (l.length - 1) / num\n\n for i in 1..(npages)\n create_old_page \"/page/\", i, npages, num\n end\n end",
"def index\n @filter = DocumentFilter.new(filter_params)\n @documents = @filter.call.page(params[:page])\n end",
"def per_page(num)\n @query[:rpp] = num\n self\n end",
"def paginate(scope, options = {}, &block)\n PaginationRenderer.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :remote => false)\n end",
"def paginate(relation:, page:, per_page:)\n relation.send(Kaminari.config.page_method_name, page).per(per_page)\n end",
"def slice_records!\n @number_of_records ||= @records.length\n\n @records = @records.slice(0, per_page) if @number_of_records > per_page\n end",
"def paginate(collection_id, options = {})\n if !options[:per_page].nil?\n params[:num_per_page] = options[:per_page].to_s\n else\n params[:num_per_page] = '10' if params[:num_per_page].nil?\n end\n\n super(collection_id, options.merge(:per_page => params[:num_per_page].to_i))\n end",
"def page(num)\n limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1))\n end"
] | [
"0.7644259",
"0.74222755",
"0.7249519",
"0.7222618",
"0.7197751",
"0.71957314",
"0.7180792",
"0.71390957",
"0.7047344",
"0.6989861",
"0.69371796",
"0.6811305",
"0.6800669",
"0.6788106",
"0.6700812",
"0.6662037",
"0.6657402",
"0.66351646",
"0.6631685",
"0.6631172",
"0.6620033",
"0.6590726",
"0.65309423",
"0.65246385",
"0.6514797",
"0.650878",
"0.648899",
"0.6486832",
"0.6468494",
"0.64584696",
"0.64536524",
"0.644864",
"0.64428157",
"0.6440814",
"0.6439857",
"0.6432583",
"0.64324343",
"0.6405366",
"0.6390142",
"0.6386429",
"0.63822293",
"0.6374974",
"0.6372027",
"0.63628227",
"0.6348146",
"0.63269836",
"0.6307529",
"0.62788814",
"0.6274951",
"0.62697786",
"0.6262542",
"0.62597454",
"0.62581915",
"0.6253913",
"0.62506795",
"0.62426424",
"0.6225312",
"0.6215277",
"0.6188873",
"0.6187141",
"0.61807203",
"0.6177134",
"0.6174905",
"0.6166325",
"0.61485744",
"0.6147776",
"0.614458",
"0.6142566",
"0.61409384",
"0.61409163",
"0.61391324",
"0.61391324",
"0.6135247",
"0.6135247",
"0.6127646",
"0.6122439",
"0.6102178",
"0.60909206",
"0.6048295",
"0.6044229",
"0.6025114",
"0.6022523",
"0.60210466",
"0.60152525",
"0.6008486",
"0.6001292",
"0.5997584",
"0.59959435",
"0.5991956",
"0.5976494",
"0.596904",
"0.59617716",
"0.5961583",
"0.59598845",
"0.59588194",
"0.59524596",
"0.59466237",
"0.5938644",
"0.59343195",
"0.5926713"
] | 0.70397025 | 9 |
Build an object at this scope. e.g. Post.scope(:name => "James").build.name => "James" | def build(extra_parameters = {})
klass.new(params_without_modifiers(extra_parameters))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_with_scope(name); end",
"def build_entry\n model_scope.new\n end",
"def build_person\n @person ||= people_scope.build\n @person.attributes = person_params\n end",
"def build(params = {})\n association.build(model, params)\n end",
"def push_scope(data)\n @scopes.push(\n data.respond_to?(:get_variable_value) ? data : DefaultScope.new(data))\n end",
"def create_with_scope(name)\n attribute = self.attribute\n lambda {|model, values| model.filter(attribute.to_sym => values)}\n end",
"def build(attrs = {})\n @parent.new(@query_attrs.merge(attrs))\n end",
"def build (name, attrs = {})\n factory_by_name(name).build(attrs)\n end",
"def build (name, attrs = {})\n factory_by_name(name).build(attrs)\n end",
"def target_scope\n AssociationRelation.create(klass, self).merge!(klass.scope_for_association)\n end",
"def newscope(parent, options = {})\n raise _('having multiple named scopes is not supported when scripting')\n end",
"def apply_to_scope(scope)\n scope\n end",
"def initialize(scope, user, params, &block)\n @scope = scope\n @params = params.dup\n @user = user\n\n instance_eval(block) if block_given?\n\n build\n end",
"def scope\n @scope ||= Scope.new(parent)\n end",
"def new_object\n @object = scope.new params[object_name.to_sym]\n set_instance\n end",
"def build(name, options={})\n @builds[name] = build = Build.new(options)\n with_scope(build) { yield }\n end",
"def create_without_scope(name); end",
"def build(environment, options = {})\n options[:options] ||= {}\n options[:options].merge!(@options)\n options.merge!(:name => @name)\n @buildable.build(environment, options)\n end",
"def chain(new_scope = {})\n new_scope = {} if new_scope.nil?\n\n self.class.new(collection_path, collection_name, client).tap do |new_request|\n new_request.scope.merge!(scope)\n new_request.scope.merge!(new_scope)\n end\n end",
"def scoped_by(name, options = {})\n options[:scope] ||= :reference\n if scope_class = self.class.scope_types[options[:scope]]\n @scopes[name] = scope_class.new(@model, name, options)\n end\n end",
"def build(attrs)\n # Implement #build \n end",
"def build\n deferred_defaults\n validate\n Builder.new(self).build\n end",
"def build\n builder_values = builder.build\n self.use_values(builder_values)\n end",
"def build_scope_from_columns\n self.scope\n end",
"def build_resource\n get_resource_ivar || set_resource_ivar(end_of_association_chain.send(method_for_build, *resource_params))\n end",
"def build(params); end",
"def _build(scope, opts, locale, invert)\n return yield if (mods = translation_modules(scope)).empty?\n\n keys, predicates = opts.keys.map(&:to_s), []\n\n used_keys = []\n\n query_map = mods.inject(IDENTITY) do |qm, mod|\n i18n_keys = mod.names & keys - used_keys\n next qm if i18n_keys.empty?\n\n used_keys += i18n_keys\n mod_predicates = i18n_keys.map do |key|\n build_predicate(scope.backend_node(key.to_sym, locale), opts.delete(key))\n end\n invert_predicates!(mod_predicates) if invert\n predicates += mod_predicates\n\n ->(r) { mod.backend_class.apply_scope(qm[r], mod_predicates, locale, invert: invert) }\n end\n\n return yield if query_map == IDENTITY\n\n relation = opts.empty? ? scope : yield(opts)\n query_map[relation.where(predicates.inject(:and))]\n end",
"def scoped_by( *scope )\n scope = scope.length == 1 ? scope.first : scope\n sub_map = @map.get( expand_key( scope ) ) || {}\n Properties.new( sub_map )\n end",
"def new_scope(names)\n values = names.map { |n| self[n] }\n self.class.new(names, values + extras, self)\n end",
"def scope\n @scope ||= {}\n end",
"def scope\n @scope ||= {}\n end",
"def scope\n @scope.dup\n end",
"def build builder\n builder.send tag, @attributes do |builder|\n objects.each do |object|\n object.build builder\n end\n end\n end",
"def build(options)\n item = association.associated_constant.new(options)\n self << item\n item\n end",
"def build(**)\n raise NotImplementedError\n end",
"def build(attributes = {})\n Record.new(self, attributes)\n end",
"def build_collection_scope_base(some_instance)\n some_instance.send(@collection_name).scoped\n end",
"def build(&build)\n @context.instance_exec(&build)\n end",
"def aggregate scope\n # TODO fucking slow\n data = {}\n data[:sha] = self.sha\n data[:short_sha] = self.short_sha\n data[:author_name] = self.author.name\n data[:author_email] = self.author.email\n data[:time] = self.time.xmlschema\n data[:message] = self.message\n data[:stats] = self.stats\n if scope == :single\n data[:project] = {}\n data[:current_branch] = @project.branchname\n data[:project][:path] = @project.path\n data[:project][:name] = @project.name\n data[:project][:remotes] = @project.remotes.map(&:name)\n data[:project][:remote_urls] = @project.remotes.map(&:url)\n data[:project][:remote_branches] = @project.remote_branches\n data[:project][:identifier] = self.project_identifier\n end\n data\n end",
"def build opts = nil, &blk\n builder.build opts, &blk\n end",
"def build(attributes = {})\n @klass.build(attributes)\n end",
"def create_scope\n sprintf \"%s/%s/signer\", @self_key, @client_id\n end",
"def create(scope, options = {}, additional_index_options = {})\n bulk options do |indexer|\n each_record(scope, index_scope: true) do |object|\n indexer.create record_id(object), serialize(object), index_options(object).merge(additional_index_options)\n end\n end\n\n scope\n end",
"def build_attribute(name = nil, ransacker_args = [])\n Attribute.new(@context, name, ransacker_args).tap do |attribute|\n @context.bind(attribute, attribute.name)\n self.attributes << attribute if name.nil? || attribute.valid?\n if predicate && !negative?\n @context.lock_association(attribute.parent)\n end\n end\n end",
"def scope(scope_name)\n Scope.new(@backend, @name, scope_name)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n if params[:organization_name].present?\n self.resource.organization = Organization.new(name: params[:organization_name],\n head_name: params[:head_name],\n city: params[:city],\n state: params[:state],\n country: params[:country],\n pin_code: params[:pin_code])\n\n end\n self.resource\n end",
"def builder\n @builder ||= self[ :definition_context_factory ].new( self )\n end",
"def set_scope(val)\n @scope = val\n build_path_query\n @scope\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def build=(_arg0); end",
"def create\n @scope = Scope.new(scope_params)\n\n respond_to do |format|\n if @scope.save\n format.html { redirect_to @scope, notice: 'Scope was successfully created.' }\n format.json { render :show, status: :created, location: @scope }\n else\n format.html { render :new }\n format.json { render json: @scope.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build(attributes = {})\n model_class.build(attributes, self).tap do |resource|\n mark_dirty(resource)\n end\n end",
"def build(attributes = {})\n attributes.merge! foreign_key_association\n @klass.build(attributes.merge(owner_path))\n end",
"def build(attrs, collection)\n collection.new(attrs)\n end",
"def initialize(name)\n @name = name\n @predicates = {}\n \n @@scopes[@name] = self\n end",
"def build_resource\n get_resource_ivar || begin\n set_resource_ivar class_name.new\n end\n end",
"def build(hash, track_changes = true)\n resource = fields.each_with_object(new) do |field, r|\n value = hash.fetch(field.to_s, hash[field.to_sym])\n r.send(\"#{field}=\", value)\n end\n resource.clear_changes! unless track_changes\n resource\n end",
"def scope( new_scope=nil )\n\t\tif new_scope\n\t\t\tself.log.debug \"cloning %p with new scope: %p\" % [ self, new_scope ]\n\t\t\treturn self.clone( :scope => new_scope.to_sym )\n\t\telse\n\t\t\treturn @options[:scope]\n\t\tend\n\tend",
"def as(scope); end",
"def build\n end",
"def define_scope_method(name)\n singleton_class.class_eval do\n ruby2_keywords(\n define_method(name) do |*args|\n scoping = _declared_scopes[name]\n scope = instance_exec(*args, &scoping[:scope])\n extension = scoping[:extension]\n to_merge = scope || queryable\n criteria = to_merge.empty_and_chainable? ? to_merge : with_default_scope.merge(to_merge)\n criteria.extend(extension)\n criteria\n end\n )\n end\n end",
"def build(operators, scope)\n to_sexp(operators, scope)\n end",
"def rubanok_scope(params = nil, with: nil)\n with_inferred_rubanok_params(with, params) do |rubanok_class, rubanok_params|\n rubanok_class.project(rubanok_params)\n end\n end",
"def build(attrs = {}, &block)\n create_document(:new, attrs, &block)\n end",
"def build(&block)\n instance_eval(&block)\n end",
"def build_search!(options = {}, &block)\n conditions = @reflection.klass.build_search!(options, &block)\n conditions.scope = scope(:find)[:conditions]\n conditions\n end",
"def build_request(format, hash = {})\n context_object = OpenURL::ContextObject.new\n context_object.referent.set_format(format) if format\n \n hash.each_pair do |key, value| \n context_object.referent.set_metadata(key.to_s, value.to_s)\n end\n \n rft = Referent.create_by_context_object(context_object)\n \n req = Request.new\n req.referent = rft\n req.save!\n \n return req\n end",
"def build(attributes = {}, type = nil)\n Factory.execute_build(type || klass, attributes, execute_callbacks: false).tap do |doc|\n append(doc)\n doc.apply_post_processed_defaults\n yield doc if block_given?\n doc.run_pending_callbacks\n doc.run_callbacks(:build) { doc }\n end\n end",
"def build(attrs = {})\n choose_right_class(attrs).new(attrs)\n end",
"def build\r\n end",
"def build\r\n end",
"def create!(name, params = {})\n item = build(name, params)\n item.save!\n item\nend",
"def newscope(parent, options = {})\n parent ||= topscope\n scope = Puppet::Parser::Scope.new(self, **options)\n scope.parent = parent\n scope\n end",
"def build(attributes)\n @relationship.build(attributes) do |record|\n record.access_to = @owner.owner\n end\n end",
"def scope\n finder_or_run(:scope)\n end",
"def scope_query(operand)\n @scope << operand.class\n end",
"def build_conditions!(options = {}, &block)\n conditions = @reflection.klass.build_conditions!(options, &block)\n conditions.scope = scope(:find)[:conditions]\n conditions\n end",
"def merge!(scope)\n @options.merge!(scope.options)\n\n @attributes += scope.attributes\n @associations.merge!(scope.associations)\n\n @attributes.uniq!\n\n self\n end",
"def build\n return Membership.where(basic_resource_group_id: group.id) if group\n\n Membership.where(user_id: user.id)\n end",
"def scoped(scope = {}, &block)\n ActiveRecord::NamedScope::Scope.new(self, scope, &block)\n end",
"def build *args\n Factory.build factory_name, *args\n end",
"def update_scope\n @scope = params[:scope] || params[:q] || {}\n end",
"def chain_with(scope_name)\n self + klass.send(scope_name)\n end",
"def build(attributes)\n Model.new(resource_gateway, attributes)\n end",
"def build(*args)\n @instance = @obj.send(PolyBelongsTo::Pbt::BuildCmd[@obj, @child], *args)\n self\n end",
"def set_scope\n @scope = Scope.find(params[:id])\n end",
"def set_scope\n @scope = Scope.find(params[:id])\n end",
"def build(&block)\n if block\n @build = block\n else\n @build\n end\n end",
"def scope=(v); end",
"def scope=(v); end",
"def build!\n end",
"def build(attributes, parent)\n record = new(parent)\n attributes.each do | key, value |\n field_key = record.class.fields.find { |_, params| params[:api_name].to_s == key.to_s }\n attr = field_key.nil? ? key : field_key.last[:internal_name]\n record.send(\"#{attr}=\", value)\n end\n record\n end",
"def build\n yield self\n self\n end",
"def build_search(options = {}, &block)\n conditions = @reflection.klass.build_search(options, &block)\n conditions.scope = scope(:find)[:conditions]\n conditions\n end",
"def initialize(scope, id, name, type, parent, attributes_before_type_cast)\n @scope, @ID, @Name, @internal_type, @parent, @attributes_before_type_cast = scope, id, name, type, parent, attributes_before_type_cast\n @site = Site === @scope ? @scope : @scope.site\n end",
"def build\r\n raise \"Not implemented\"\r\n end"
] | [
"0.67134726",
"0.66358393",
"0.61561906",
"0.57893085",
"0.5769956",
"0.574379",
"0.5689608",
"0.56583",
"0.56583",
"0.563985",
"0.56386757",
"0.5618825",
"0.56106585",
"0.5582285",
"0.5535852",
"0.55302507",
"0.549636",
"0.5490312",
"0.54728025",
"0.5469826",
"0.5430845",
"0.5427192",
"0.5400709",
"0.53957397",
"0.53861654",
"0.53704095",
"0.53613967",
"0.53403604",
"0.5331066",
"0.53259933",
"0.53259933",
"0.5323302",
"0.53169644",
"0.531416",
"0.5305319",
"0.5302546",
"0.5300125",
"0.5285498",
"0.5278019",
"0.5277781",
"0.52679366",
"0.5266874",
"0.526625",
"0.52630657",
"0.5259304",
"0.5254999",
"0.52402467",
"0.52384543",
"0.52377313",
"0.52377313",
"0.52377313",
"0.52377313",
"0.52377313",
"0.52377313",
"0.5230321",
"0.5221985",
"0.5214734",
"0.51917374",
"0.51862764",
"0.51795065",
"0.51703286",
"0.51663435",
"0.5165644",
"0.51653594",
"0.51605856",
"0.5155228",
"0.51503307",
"0.5145768",
"0.51415986",
"0.51415646",
"0.5135454",
"0.5132982",
"0.5122319",
"0.5109959",
"0.5109246",
"0.5109246",
"0.51066625",
"0.51021075",
"0.50916654",
"0.50912607",
"0.50874996",
"0.50859463",
"0.5081127",
"0.5078737",
"0.5067661",
"0.50653875",
"0.50651485",
"0.50524366",
"0.50422806",
"0.5031237",
"0.5030549",
"0.5030549",
"0.502496",
"0.5024062",
"0.5024062",
"0.5017217",
"0.50155413",
"0.5012792",
"0.5008555",
"0.500566",
"0.50040764"
] | 0.0 | -1 |
Create an object at this scope. e.g. | def create(extra_parameters = {})
klass.create(params_without_modifiers(extra_parameters))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_object\n @object = scope.new params[object_name.to_sym]\n set_instance\n end",
"def new\n BikeObject.new(self, 'Object', @type, @name)\n end",
"def create_object\n definition.sought_type.new\n end",
"def new\n AwesomeObject.new(self)\n end",
"def new\n AwesomeObject.new(self)\n end",
"def create_with_scope(name); end",
"def new\n BaseObject.new(self)\n end",
"def create(name)\n object = new(name)\n @instances.push(object)\n object\n end",
"def construct\n end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new\n \n end",
"def create_instance_core() \r\n @log.debug(\"Create core scopetta\")\r\n return CoreGameScopetta.new\r\n end",
"def construct_new_object(db_object)\n end",
"def initialize object\n\t\tself.object = object\n\tend",
"def create(attribs={})\n obj = new\n obj.send :create, attribs\n obj\n end",
"def create_object\n sut.send(: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 create_objects\n# Create a new \"Mash\" object and assign it to \"awesome\"\n awesome Mash.new\n end",
"def create\n attrs = create_attributes\n @object = klass.new\n object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX\n run_callbacks :save do\n run_callbacks :create do\n klass == Collection ? create_collection(attrs) : work_actor.create(environment(attrs))\n end\n end\n log_created(object)\n end",
"def new(klass, *args)\n unless klass.is_a?(BasicObject)\n PEROBS.log.fatal \"#{klass} is not a BasicObject derivative\"\n end\n\n @lock.synchronize do\n obj = _construct_po(klass, _new_id, *args)\n # Mark the new object as modified so it gets pushed into the database.\n @cache.cache_write(obj)\n # Return a POXReference proxy for the newly created object.\n obj.myself\n end\n end",
"def new\n CanadianObject.new(self)\n end",
"def initialize(obj); end",
"def new()\n #This is a stub, used for indexing\n end",
"def new()\n trace(\"Instance #{index} created\")\n index += 1\n end",
"def create\n super\n push_binding(instance_eval(\"#{name.to_s}\"))\n end",
"def object\n @object ||= build_object\n end",
"def instantiate!; end",
"def myAnotherInstance = new ObjectOrientedProgramming()",
"def new\n @space = Space.new\n end",
"def create_observation_object(args)\n now = Time.zone.now\n observation = new_observation(args)\n observation.created_at = now\n observation.updated_at = now\n observation.user = @user\n observation.name = Name.unknown\n observation.source = \"mo_website\"\n determine_observation_location(observation)\n end",
"def create_object(klass, room = nil, position = nil, args = nil, vars = nil)\n object = nil\n if room.is_a? Container\n room_goid = room.goid\n else\n room_goid = room\n room = $manager.get_object room\n end\n if args\n if args.is_a? Enumerable\n object = klass.new(*args)\n else\n object = klass.new(args)\n end\n else\n object = klass.new(nil, room_goid)\n end\n\n if vars\n vars.each do |k,v|\n object.instance_variable_set(k, v)\n end\n end\n\n add_object(object, position)\n unless room.nil?\n if position == nil\n room.add(object)\n else\n room.add(object, position)\n end\n end\n object\n end",
"def create_person\n Neography::Node.create(\"object_id\" => self.id, \"object_type\" => self.class.to_s)\n end",
"def create(name, attributes)\n attributes = attributes.dup\n\n # Add the objectclasses\n attributes[\"objectClass\"] = objectclasses.collect { |o| o.to_s }\n attributes[\"objectClass\"] << \"top\" unless attributes[\"objectClass\"].include?(\"top\")\n\n attributes[rdn.to_s] = [name]\n\n # Generate any new values we might need.\n generate(attributes)\n\n # And create our resource.\n connect { |conn| conn.add dn(name), attributes }\n end",
"def new\n self\n end",
"def create objid\n DataObj.new @repo, self, objid, true\n end",
"def make_object klass\n obj = $manager.make_object klass\n inventory << obj if self.respond_to? :inventory\n obj\n end",
"def get_new_obj(obj, type='query')\n tmp_obj = self.new\n tmp_obj.send 'object'.to_sym, \"{#{obj['object'].to_s}}\"\n tmp_obj.send 'source_id'.to_sym, get_source_id\n tmp_obj.send 'update_type'.to_sym, type\n tmp_obj\n end",
"def new(*args, &block)\n object = mapper.new_object(*args, &block)\n track(object)\n object\n end",
"def new #:nodoc:\n end",
"def new_scope\n self.class.new(@input, @output, @wrap_at,\n @page_at, @indent_size, @indent_level)\n end",
"def instantiate\n resource.new(data)\n end",
"def new_with_value(value)\n AwesomeObject.new(self, value)\n end",
"def scaffold_new_object(attributes, options)\n object = new\n scaffold_set_attributes(object, scaffold_filter_attributes(:new, attributes || {}))\n object.send(\"#{scaffold_session_value}=\", options[:session][scaffold_session_value]) if scaffold_session_value\n object\n end",
"def new_object(definition, name)\n Object.const_get(name).new(definition)\n rescue\n raise Yarpler::Exceptions::ClassNotInModelException, name\n end",
"def initialize\n create_new_rep\n end",
"def constructor; end",
"def new(*args, &block)\n obj = allocate()\n obj.initialize(*args, &block)\n obj\n end",
"def new\n @element = @@model.new()\n end",
"def otCreate(rconstant, &block)\n otObj = $otObjectService.createObject(rconstant.java_class)\n yield otObj\n otObj\nend",
"def create(object)\n object.instance_variable_set('@__attributes', {})\n object.instance_variable_set('@__references', {})\n object.instance_variable_set('@__collections', {})\n object.instance_variable_set('@__mapping', @mapping)\n object.instance_variable_set('@__factory', self)\n\n object.extend(Identity)\n object.extend(Entity)\n object.extend(Validations)\n end",
"def new_person\r\n @person = Person.new\r\n end",
"def object(key)\n Object.send(:new, self, :key => key)\n end",
"def new\n raise('Sorry, modules cannot be instantiated!') if @is_module\n \n RObject.new self\n end",
"def new\n create_obj(@obj_class.new)\n build_enabled(obj)\n end",
"def new\n new_with_value(nil)\n end",
"def new \n @toy = Toy.new \n end",
"def create_instance\n create_instances(1).first\n end",
"def create!(*args, &block)\n instance = new(*args, &block)\n instance.create!\n instance\n end",
"def new\n n = clone\n n.__send__ :instance_variable_set, \"@dict\", @dict.clone\n n.__send__ :instance_variable_set, \"@stack\", @stack.clone\n n\n end",
"def initialize(object)\n @object = object\n end",
"def new_with_value(value)\n RObject.new self, value\n end",
"def new_otus(attrs)\r\n otus = Otus.new(:attrs => attrs)\r\n self.otus.push(otus)\r\n otus \r\n end",
"def create()\n instance = create_instance()\n set_instance_properties(instance)\n create_instance_children(instance)\n return instance\n end",
"def new\n\t\t# create a new object for the yoyo with no data inside of it,\n\t\t# so that rails can figure out what type of data the yoyo will have\n\t\t@yoyo = Yoyo.new\t# we write `new` here to make the object in memory, but NOT save it into the database\n\t\t\t\t\t\t\t# we're just making an ActiveRecord object for our model,\n\t\t\t\t\t\t\t# NOT saving an object to our database\n\tend",
"def new\n @theory = Theory.new\n end",
"def create(attrs = {})\n val = new(attrs)\n R(val, self.database).save\n val\n end",
"def initialize(name, owner)\n self.id # The database id of the object\n self.name = name # The displayed name of the object\n self.owner = owner || id # The owner of the object or itself.\n self.desc = \"\" # The description of the object\n self.created_on = Time.now\n self.updated_on = created_on.dup\n end",
"def new\n @composition = Composition.new\n end",
"def new_variable(name, type, memory, is_cte = false) #method\n @variables[name] = ObjectVariable.new(name, type, memory, is_cte)\n end",
"def create_without_scope(name); end",
"def create\n name_to_const.new\n end",
"def create_observation_object(args)\n now = Time.now\n observation = Observation.new(args)\n observation.created_at = now\n observation.updated_at = now\n observation.user = @user\n observation.name = Name.unknown\n if Location.is_unknown?(observation.place_name) ||\n (observation.lat && observation.long && observation.place_name.blank?)\n observation.location = Location.unknown\n observation.where = nil\n end\n observation\n end",
"def create data_object_class, opts={}\n data_object = make data_object_class, opts\n data_object.create\n data_object\n end",
"def new\n @environment = Environment.new\n @lists = List.active\n end",
"def camCreate _obj, _args\n \"_obj camCreate _args;\" \n end",
"def create\n # TODO: implement create\n end",
"def initialize(vm, type, lt = nil, outer = nil, instructions = nil)\n hash = nil\n if type.is_a?(String)\n hash = JSON.parse(type)\n elsif type.is_a?(Hash)\n hash = type\n end\n\n if hash\n type = hash[:type]\n lt = hash[:local_table]\n outer = hash[:outer_scope]\n instructions = hash[:instructions]\n end\n\n self.vm = vm\n self.name = \"\\##{type}:#{Random.rand(0xFFFFFFFF).to_s(16)}\"\n self.type = type\n case type\n when :top\n clazz = Class.new(vm, 'Object', self, nil, true)\n vm.constant_table['Object'] = clazz\n self.entity = clazz\n self.constant_full_name = ''\n when :class\n self.entity = vm.define_class('a')\n self.constant_full_name = entity.name\n when :method\n when :block\n else\n raise Errors::TypeError\n end\n self.local_table = lt || {}\n self.outer_scope = outer || nil\n self.clazz = get_current_class\n self.instructions = instructions || []\n end",
"def create(name)\n self.new(name)\n end",
"def create(data={})\n object = self.new(data)\n object.save\n end",
"def create(attrs = {})\n super(attrs)\n end",
"def self_new\n raise \"Not implemented.\"\n end",
"def allocate\n <<-CODE\n _lit = stack_pop();\n stack_push(NEW_OBJECT(Qnil, N2I(_lit)));\n CODE\n end",
"def create!\n end",
"def create\n \n end",
"def create(attrs = {})\n instance = self.new(attrs)\n instance.save\n instance\n end",
"def createVehicle _obj, _args\n \"_obj createVehicle _args;\" \n end",
"def open_new_object\n save_state\n oid = open_object\n close_object\n add_object(oid)\n reopen_object(oid)\n oid\n end",
"def newscope(parent, options = {})\n parent ||= topscope\n scope = Puppet::Parser::Scope.new(self, **options)\n scope.parent = parent\n scope\n end",
"def new\n\t\t@habit = Habit.new\n\tend"
] | [
"0.77991676",
"0.6936549",
"0.6880084",
"0.67573494",
"0.67573494",
"0.6510978",
"0.6478314",
"0.6458054",
"0.643385",
"0.64300156",
"0.64300156",
"0.64300156",
"0.64300156",
"0.64300156",
"0.64300156",
"0.64300156",
"0.64300156",
"0.64300156",
"0.6368954",
"0.6361923",
"0.63259363",
"0.6287904",
"0.6284649",
"0.6277707",
"0.6274154",
"0.6274154",
"0.6274154",
"0.6274154",
"0.6274154",
"0.62533873",
"0.62377",
"0.62020993",
"0.6200998",
"0.6181029",
"0.6176635",
"0.6143979",
"0.6130963",
"0.61083615",
"0.6104328",
"0.6101139",
"0.6092493",
"0.60660094",
"0.6053415",
"0.60496575",
"0.60260344",
"0.601994",
"0.60161906",
"0.60073066",
"0.6004974",
"0.5999381",
"0.59782076",
"0.5977437",
"0.596287",
"0.5942888",
"0.594145",
"0.59389687",
"0.59189326",
"0.5917474",
"0.5909884",
"0.59072304",
"0.5903588",
"0.58870393",
"0.5886756",
"0.5886457",
"0.5885848",
"0.58816946",
"0.5865787",
"0.58545053",
"0.58535564",
"0.58451915",
"0.5844952",
"0.5831848",
"0.58199346",
"0.58198136",
"0.58149016",
"0.581475",
"0.5808749",
"0.5807872",
"0.5796341",
"0.57931346",
"0.5785655",
"0.57836926",
"0.5781809",
"0.5769088",
"0.576862",
"0.5759382",
"0.5746398",
"0.57457376",
"0.573868",
"0.57331336",
"0.57233715",
"0.57223594",
"0.5721393",
"0.5720091",
"0.5709476",
"0.5709072",
"0.57013696",
"0.57012814",
"0.56947184",
"0.56885594",
"0.5677957"
] | 0.0 | -1 |
Override respond_to? so that we can return true when it's another named_scope. | def respond_to?(method_name, include_private = false)
klass.has_named_scope?(method_name) || super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_named_scope?(name)\n scope_proxy.has_named_scope?(name)\n end",
"def respond_to?(name, include_private=false) #:nodoc:\n super || (current && current.respond_to?(name, include_private))\n end",
"def respond_to?(name, include_private = false)\n return true if @extensions.any?{|m| m.method_defined?(name) }\n return true if BasicObject.method_defined?(name)\n @parent && @parent.respond_to?(name)\n end",
"def respond_to?(name)\n super || (klass ? target.respond_to?(name) : @parent.respond_to?(name))\n end",
"def respond_to?(name)\n return true if super(name)\n return true if key?(name)\n return false\n end",
"def respond_to?(name)\n return super unless part(name)\n part(name)\n end",
"def respond_to?(symbol, include_private=false)\n super || (response && response.respond_to?(symbol, include_private))\n end",
"def respond_to?(name)\n super || helpers.respond_to?(name)\n end",
"def respond_to?(name, include_private = false)\n # don't include klass private methods because method_missing won't call them\n super || @klass.respond_to?(name) || entries.respond_to?(name, include_private)\n end",
"def respond_to?(method_name)\n @instance.respond_to?(method_name) || super\n end",
"def scope?\n # context = Ransack::Context.for klass\n # context.respond_to?(:ransackable_scope?) && context.ransackable_scope?(method.to_s, klass)\n false\n end",
"def respond_to?(name_) # :nodoc:\n super || @methods.include?(name_.to_sym)\n end",
"def valid_scope_name?(name)\n if scopes[name] || respond_to?(name, true)\n if Mongoid.scope_overwrite_exception\n raise Errors::ScopeOverwrite.new(self.name,name)\n else\n if Mongoid.logger\n Mongoid.logger.warn(\n \"Creating scope :#{name}. \" +\n \"Overwriting existing method #{self.name}.#{name}.\"\n )\n end\n end\n end\n end",
"def respond_to?(sym)\n return true if super\n @headers.has_key?(sym)\n end",
"def respond_to?(*a, &b)\n super || parent.respond_to?(*a, &b)\n end",
"def has_scope?( scope )\n scope_names.include?( scope )\n end",
"def respond_to?(*args) # :nodoc:\n sym = args.first\n first.respond_to?(sym) || super(sym)\n end",
"def respond_to?(name)\n return true if dotruby.respond_to?(name)\n return true if super(name)\n return true if key?(name)\n return false\n end",
"def respond_to_missing?(*args)\n method_name = args.first\n delegates_controller_method?(method_name) || super\n end",
"def respond_to?(method)\n return true if name?(method.to_sym)\n super\n end",
"def respond_to?(*)\n true\n end",
"def __respond_to__(name) # :nodoc:\n name = name.to_s\n return false if name =~ FORBIDDEN_NAMES_RX\n\n if name =~ /=$/\n !@stable\n elsif @members.key?(name)\n true\n else\n (alias_to = @aliases[name]) && respond_to?(alias_to)\n end\n end",
"def respond_to?(method, include_private = false)\n super || @_view.respond_to?(method, include_private)\n end",
"def valid_scope?\n scope.to_s == self.class.scope.to_s\n end",
"def respond_to?(symbol, include_private=false) end",
"def in_scope?(name)\n ret = true if @callable.arguments_type.variable_index(name)\n ret = @callable.frame_type.variable_index(name) unless ret\n ret\n end",
"def scoped?\n !!scope\n end",
"def respond_to?(method_name, include_private = false)\n true\n end",
"def respond_to_missing?(method_name, include_private = false)\n controller.respond_to?(method_name) || super\n end",
"def named_scope_method\n # Can't use respond_to because both AR 2 and 3\n # respond to both +scope+ and +named_scope+.\n ActiveRecord::VERSION::MAJOR == 2 ? :named_scope : :scope\n end",
"def respond_to?(method_name, include_private=false)\n return true if key?(method_name) || method_name.to_s.slice(/[=?!_]\\Z/)\n super\n end",
"def applies_type?(scope, type); end",
"def respond_to?(method_name, include_private = false)\n [\"tenants\"].include? (method_name.to_s) || super\n end",
"def respond_to?(method)\n child_class_for(self, method, params) || super\n end",
"def respond_to?(sym)\n case\n when @attributes.keys.include?(sym)\n true\n when @collection.respond_to?(sym)\n true\n else\n super\n end\n end",
"def respond_to?(m)\n m || super\n end",
"def applies?(scope, path, type); end",
"def has_scope?(scope)\n access_token && access_token.scopes.include?(scope)\n end",
"def respond_to?(symbol, include_priv=false)\n super || matching_rules.respond_to?(symbol, include_priv)\n end",
"def uses_defn?(scope)\n if scope.iter? or scope.module?\n true\n elsif scope.class? and %w(Object BasicObject).include?(scope.name)\n true\n else\n false\n end\n end",
"def respond_to? sym\n return true if @data.key? sym.to_s\n \n #If the method is not supported we performt the default respond_to? behavior.\n super sym\n end",
"def respond_to?(m)\n inner.respond_to?(m)\n end",
"def respond_to_missing?(name, include_private = false)\n ( \\\n ( \\\n (@response.is_a? Hash) \\\n && \\\n ( \\\n @response.key?(name) \\\n || \\\n @response.key?(\"#{name}_reference\".to_sym) \\\n ) \\\n ) \\\n || \\\n @response.respond_to?(name, include_private) \\\n )\n end",
"def respond_to?(symbol, include_private = false)\n (@pjson[s = symbol.to_s] != nil) || (s[-1, 1] == '=' && @pjson[s[0..-2]] != nil) || super(symbol, include_private)\n end",
"def respond_to?(method_name)\n super || rpc_methods.include?(method_name.to_sym)\n end",
"def respond_to?(*args)\n proxy_respond_to?(*args) || target.respond_to?(*args)\n end",
"def is_sphinx_scope?(scope_name)\n klass.sphinx_scopes.include?(scope_name.to_sym)\n end",
"def respond_to?(*args)\n proxy_respond_to?(*args) || collection.respond_to?(*args)\n end",
"def respond_to?(method_name, include_all = false)\n if self.has_key?(method_name.to_s)\n true\n else\n super\n end\n end",
"def respond_to?(symbol, include_private = false)\n return COLLECTION_RESPONSE_ATTRIBUTES.include?(symbol)\n end",
"def respond_to?(symbol, include_private=false)\n @interfaces.has_key?(symbol) ||\n @delegate.respond_to?(symbol, include_private)\n end",
"def respond_to?(method_sym, include_private = false)\n super(method_sym, include_private) || data.respond_to?(method_sym, include_private)\n end",
"def respond_to?(method, include_private = false)\n super || app.respond_to?(method, include_private)\n end",
"def respond_to? name, priv = false\n key = TRANSLATOR.cocoaify name.to_s.chomp(EQUALS)\n @ref.attributes.include?(key) ||\n @ref.parameterized_attributes.include?(key) ||\n super\n end",
"def bound_name?(name)\n type = @names[name.to_sym]\n if type.nil?\n @parent&.bound_name?(name)\n else\n type\n end\n end",
"def respond_to?(m, *args)\n set_name = Kernel.__set\n\n names = @@__name_sets[set_name]\n if names\n f = names[m]\n if f\n return true\n end\n end\n\n super(m, *args)\n end",
"def respond_to_missing?(name, include_private = false)\n @params.key?(name) ||\n active_params.any? { |param| param.respond_to_missing?(name) } ||\n super\n end",
"def respond_to? meth, include_private=false\n if(matches? meth)\n return true\n else\n super\n end\n end",
"def respond_to?(sym)\n java = @java_object.getClass.getMethods.any? {|m| m.getName == sym.to_s} || super.respond_to?(sym)\n end",
"def respond_to?(method, include_private = false)\n super || object.respond_to?(method, include_private)\n end",
"def respond_to?(sym)\n @repo.respond_to?(sym) || super\n end",
"def respond_to?(method_name, include_private = false)\n dynamic_tag_context_attribute?(method_name.to_s.chomp(\"=\")) || tag_list_attribute?(method_name.to_s.chomp(\"=\")) || super\n end",
"def respond_to?(method_name)\n key?(method_name) ? true : super\n end",
"def respond_to?(method_name, _include_all = false)\n if attrs.key?(method_name.to_s)\n true\n else\n super(method_name)\n end\n end",
"def respond_to?(symbol, include_private = false)\n super || the_choice.respond_to?(symbol, include_private)\n end",
"def respond_to?( name )\n string_name = name.to_s\n return true if string_name =~ /^replace_\\w+/\n super\n end",
"def respond_to?(method, include_private = false)\n super || Barista.respond_to?(method, include_private)\n end",
"def respond_to?(method_name, include_all = false) # rubocop:disable Style/OptionalBooleanParameter\n respond_to_missing?(method_name, include_all)\n end",
"def respond_to?(sym, include_priv = false)\n # ensure that we're not going to throw and rescue from NoMethodError in method_missing which is slow\n return false if sym.to_sym == :to_str\n super\n end",
"def has_method?(name)\n Object.instance_method(:respond_to?).bind(self).call(name)\n end",
"def respond_to?(mname)\n return true if is_real_method?(mname)\n mname = mname.to_s\n return true if mname =~ /=$/\n @pObject.hasAttr(mname)\n end",
"def respond_to?( sym, include_priv=false )\n\t\treturn super if caller(1).first =~ %r{/r?spec/} &&\n\t\t\tcaller(1).first !~ /respond_to/ # RSpec workaround\n\t\treturn true if super\n\t\tplainsym, _ = attribute_from_method( sym )\n\t\treturn self.find_attribute_type( plainsym ) ? true : false\n\tend",
"def respond_to?(*args)\n case args[0]\n when :to_uri\n @subject.respond_to?(:to_uri)\n when :to_node\n @subject.node?\n else\n super(*args)\n end\n end",
"def scoped?\n scoping_object.present?\n end",
"def defined?(name)\n @symbols.has_key?(to_name(name)) or\n (Scope === @parent and @parent.defined?(name))\n end",
"def respond_to?(method_sym, include_private = false)\n (method_sym == :is_poxreference?) ||\n _referenced_object.respond_to?(method_sym, include_private)\n end",
"def respond_to_missing?(name, include_private=false)\n cur.respond_to?(name)\n end",
"def respond_to?(method)\n return super unless part(method)\n part(method)\n end",
"def respond_to?(*args)\n proxy_respond_to?(*args) || (load_target && @target.respond_to?(*args))\n end",
"def respond_to?(method, *args)\n return true if self.links && self.links.respond_to?(method)\n return true if self.attributes && self.attributes.respond_to?(method)\n return true if self.objects && self.objects.respond_to?(method)\n super\n end",
"def respond_to_missing?(name, include_priv = false)\n schema = self.class.schema\n return true if schema[name.to_s]\n return true if schema[name.to_s[0..-2]] && name.to_s[-1] == \"=\"\n super\n end",
"def respond_to?(method, include_private = false)\n super || model.respond_to?(method) || relationships.has_key?(method)\n end",
"def respond_to?(method_name, include_private = false)\n [\"users\"].include? (method_name.to_s) || super\n end",
"def acceptable?(scopes)\n accessible? && includes_scope?(*scopes)\n end",
"def respond_to?(symbol, priv = false)\r\n return true if super\r\n return true if has(symbol)\r\n return @proto.respond_to?(symbol, priv) if @proto\r\n # Basically, this can respond to anything since it will interpret it as a\r\n # property getter or setter if not already a property. This is probably\r\n # wrong, but it currently works for me.\r\n true\r\n end",
"def respond_to?(method_name, include_all = false)\n respond_to_missing?(method_name, include_all)\n end",
"def respond_to_missing?(name, include_private = false)\n known_action?(name) ||\n known_resource?(name) ||\n known_exception?(name) ||\n super\n end",
"def respond_to?(name)\n return false if name == :to_ary\n return false if name == :to_str\n super\n end",
"def respond_to?( sym, priv=false )\n\t\t\tkey = sym.to_s.sub( /(=|\\?)$/, '' ).to_sym\n\t\t\treturn true if self.member?( key )\n\t\t\tsuper\n\t\tend",
"def respond_to?(method)\n field = method.to_s\n field.chomp!('=')\n\n return true if @name_to_type.key?(field)\n super\n end",
"def public?\n scope.public_method_defined?(name)\n end",
"def owner_class_ancestor_has_method?(scope, method); end",
"def respond_to?(method, include_private = false)\n (actions(current_api).include? method) ? true : super\n end",
"def respond_to_missing?(name, include_private)\n __getobj__.respond_to?(name, include_private)\n end",
"def named?\n !anonymous?\n end",
"def respond_to?(sym, include_private_methods = false)\n if sym =~ /\\?$/\n return true if self.attribute?($`)\n elsif sym =~ /=$/\n return true if self.class.public_attribute_names.include?($`)\n else\n return true if self.attribute?(sym.to_sym)\n end\n super\n end",
"def respond_to?(method, include_private=false)\n self.configuration.respond_to?(method, include_private) || super\n end",
"def respond_to?(method_name, include_all = false)\n respond_to_missing?(method_name, include_all)\n end",
"def respond_to?(meth)\n\t\ttrue\n\tend",
"def respond_to?( sym )\n super || @state == :open && @dispatcher.respond_to?( sym )\n end"
] | [
"0.7062525",
"0.67563516",
"0.67437124",
"0.6613717",
"0.6609312",
"0.6579753",
"0.6521163",
"0.6433764",
"0.6337225",
"0.63301414",
"0.6260782",
"0.6258281",
"0.62270206",
"0.62126464",
"0.6212093",
"0.618832",
"0.61655074",
"0.61206186",
"0.6084983",
"0.6071883",
"0.6070187",
"0.60224056",
"0.60143256",
"0.5982721",
"0.5973339",
"0.5971359",
"0.59704816",
"0.5963895",
"0.59502536",
"0.5949675",
"0.59444004",
"0.59414244",
"0.59112",
"0.58742243",
"0.58419293",
"0.583794",
"0.5836862",
"0.58134985",
"0.57979393",
"0.5797803",
"0.5791363",
"0.5787077",
"0.5785847",
"0.5769994",
"0.5767648",
"0.57608336",
"0.5744611",
"0.57417053",
"0.5737988",
"0.57222384",
"0.5709864",
"0.5704009",
"0.5687876",
"0.5682283",
"0.56779265",
"0.5670691",
"0.56693184",
"0.5657901",
"0.56411844",
"0.5625122",
"0.56230146",
"0.56215733",
"0.5618118",
"0.56153667",
"0.56145453",
"0.5612369",
"0.5603392",
"0.5595129",
"0.5587507",
"0.5586484",
"0.55848867",
"0.5582126",
"0.5580757",
"0.55798817",
"0.5573502",
"0.55631024",
"0.5562728",
"0.5551246",
"0.5545125",
"0.55446476",
"0.55445474",
"0.55412644",
"0.55399144",
"0.55342364",
"0.55339646",
"0.55244005",
"0.55238026",
"0.5500281",
"0.54937875",
"0.5481135",
"0.5477107",
"0.54616797",
"0.5458817",
"0.54568",
"0.5451751",
"0.54340804",
"0.5430217",
"0.5428345",
"0.5418828",
"0.5412602"
] | 0.7358306 | 0 |
Use method_missing to respond to other named scopes on klass. | def method_missing(method_name, *args, &block)
respond_to?(method_name) ? chain_with(method_name) : super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(name, *args, &block)\n @klass.send(name, *args, &block)\n end",
"def method_missing(method, *args)\r\n self.class.method_missing(method, *args)\r\n end",
"def method_missing(method_name, *args) self end",
"def method_missing(method_name, *args) self end",
"def method_missing(method_name, *args); end",
"def method_missing(method_name, *args); end",
"def method_missing(method, *arguments, &block); end",
"def method_missing(method, *args, &block); end",
"def method_missing(name, *args, &block); end",
"def method_missing(name, *args, &block); end",
"def method_missing(name, *args, &block); end",
"def method_missing(name, *args, &block); end",
"def method_missing(method, *args, &blk); end",
"def method_missing(name, *args); end",
"def method_missing(name, *args); end",
"def method_missing(*args, &block); end",
"def method_missing(meth, *args, &block); end",
"def method_missing(meth, *args, &block); end",
"def method_missing(meth, *args, &block); end",
"def method_missing(meth, *args); end",
"def method_missing(meth, *args, &block)\n\n end",
"def method_missing(:name, *args)\nend",
"def method_missing(*rest) end",
"def method_missing(method, *args)\n send(method, *args)\n end",
"def method_missing(id, *attr, &block); end",
"def method_missing(method, *args)\n @klass[method] = *args\n end",
"def method_missing(symbol, args)\n\[email protected](symbol, args)\nend",
"def method_missing(method, *args) #:nodoc:\n self[method]\n end",
"def method_missing(sym, *args, &block)\n return @klass_hash[sym.to_s]\n end",
"def method_missing(method)\n\t\t self[method]\n\t\tend",
"def method_missing(name, *args, &block)\n if @klass.respond_to?(name)\n @klass.send(:with_scope, self) do\n @klass.send(name, *args, &block)\n end\n else\n return entries.send(name, *args)\n end\n end",
"def method_missing symbol, *args\n if @klass.collection_methods[symbol]\n instance_exec *args, &@klass.collection_methods[symbol]\n else\n super\n end\n end",
"def method_missing(selector, *args, &block); end",
"def method_missing(name, *args, &blk)\n self\n end",
"def method_missing(mth, *args, &block); end",
"def method_missing(method, *args)\n self.person.send(method, *args) if self.person\n end",
"def method_missing(method, *args)\n self[method]\n end",
"def method_missing(method, *args)\n @klass[method] = args.first\n end",
"def method_missing(*args)\n send(*args)\n end",
"def method_missing(sym, *args)\n lookup(sym.to_sym)\n end",
"def method_missing(code, *args, &blk); end",
"def method_missing(code, *args, &blk); end",
"def method_missing(m, *args, &block)\n end",
"def method_missing(name, *args)\n cur.send(name, *args)\n end",
"def define_missing_methods(klass, hash)\n methods = find_methods(hash)\n klass.include(Module.new do\n instance_exec do\n methods.each do |method|\n define_method method do\n if (object = instance_variable_get('@object'))\n object.public_send(method)\n end\n end\n end\n end\n end)\n end",
"def method_missing(*a)\n end",
"def method_missing(name, *args, &block)\n if scopes.include?(name)\n scopes[name].call(self, *args)\n elsif klass\n target.send(name, *args, &block)\n else\n @parent.fuse(@conditions); @parent.send(name, *args, &block)\n end\n end",
"def method_missing(sym, *args, &block)\n @subject.send sym, *args, &block\n end",
"def method_missing(method, *args, &block)\n generate_unsafe_delegation(method)\n send(method, *args, &block)\n end",
"def method_missing name, *args\n bind do |v|\n begin\n v.send name, *args\n rescue NoMethodError\n v.instance_variable_get :\"@#{name}\"\n end\n end\n end",
"def method_missing(*args)\n model.send(*args)\n end",
"def method_missing(method_name, *args, &block)\n instance.send(method_name, *args, &block)\n end",
"def method_missing(sym, *args)\n record.__send__(sym, *args)\n end",
"def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing\n $method_missing = [name, *args]\n (class << self; self end).add_method(nil, name) #(class << self; self end).superclass.add_method(nil, name)\n __send__(name, *args, &block)\n end",
"def method_missing_with_has_scope(method, *args, &block)\n if named_scopes\n named_scopes.keys.each do |name|\n inner = method.to_s.sub(\"_#{name}\",'')\n if inner =~ /^find(_all)_by/ || respond_to?(inner)\n module_eval \"def self.#{method}(*args, &block); with_#{name} { #{inner}(*args, &block) }; end\"\n return send(method, *args, &block)\n end\n end\n end\n method_missing_without_has_scope(method, *args, &block)\n end",
"def method_missing(*args)\n result = nil\n orig = args.shift\n class_sym = self.class.name.to_sym\n m = orig.to_s[0,5] == '_DAV_' ? orig : \"_DAV_#{orig}\" # If hell is doing the same thing over and over and expecting a different result this is a hell preventer\n raise NoMethodError.new(\"Undefined method: #{orig} for class #{self}.\") unless respond_to?(m)\n @runner.call(class_sym, :before, orig)\n result = send m, *args\n @runner.call(class_sym, :after, orig)\n result\n end",
"def method_missing( attribute, *args )\n\t\treturn self.base.send( attribute, *args )\n\tend",
"def method_missing(method_sym, *arguments, &block)\n if self[\"#{method_sym.to_s}\"] != nil\n self[\"#{method_sym.to_s}\"]\n else\n super\n end\n end",
"def method_missing(name, *args)\n @subject.send(name, *args)\n end",
"def method_missing(name, *args)\n @subject.send(name, *args)\n end",
"def method_missing name, *args\n bind { |v| v.send name, *args }\n end",
"def method_missing(name, *arguments)\n str_name = name.to_s\n\n if str_name =~ /\\w+\\?/ && Types::NAMES.include?(str_name.chop)\n klass_name = str_name.sub(/\\?/, '').capitalize\n self.class.class_name == klass_name\n else\n raise NoMethodError, \"undefined method: #{name}\"\n end\n end",
"def method_missing(name, *args, &block)\n return super unless base.respond_to? name# and forward? name\n base.send(name, *args, &block)\n end",
"def method_missing(name, *args, &block)\n target.send(name, *args, &block)\n end",
"def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissing\n (class << self; self end).add_method(nil, name)\n __send__(name, *args, &block)\n end",
"def method_missing(symbol_)\n self[symbol_] || super\n end",
"def method_missing(meth, *args)\n reviewer.send(meth, *args)\n end",
"def method_missing(name, *args, &block)\n @target.send(name, *args, &block)\n end",
"def method_missing(method, params={})\n call(method, params)\n end",
"def method_missing(sym, *args)\n # Extend this object only when needed and immediately redefine\n # #method_missing so that the new version is used on all future calls.\n extensions.each {|e| extend(e) } if @extensions\n redefine_method_missing!\n __send__(sym, *args)\n end",
"def method_missing(symbol, *_args, &_block)\n self[symbol.to_s]\n end",
"def method_missing(symbol, *args)\n #$stdout.puts(\"method_missing: #{symbol}\")\n self.ext_aliases.aliases[symbol.to_s]\n end",
"def method_missing(method_name, *args, &block)\n if @object.respond_to? method_name.to_sym\n @object.__send__(method_name, *args, &block)\n else\n super\n end\n end",
"def method_missing(symbol, *args)\n @curl.send(symbol, *args)\n end",
"def method_missing(meth, *args, &block)\n @object.send(meth, *args, &block)\n end",
"def method_missing(method, *args, &block)\n object.public_send(method, *args, &block)\n end",
"def method_missing method_sym, *args\n if el.respond_to?(method_sym)\n el.send(method_sym, *args)\n else\n raise NoMethodError, \"No such method #{method_sym} for #{self.class}\"\n end\n end",
"def method_missing(m, *args, &b)\n klass = @vocabulary.const_get(m) rescue nil # Catch missing lower-case names (wrong constant) and use super\n if invalid_object_type klass\n super\n else\n define_class_accessor m, klass\n send(m, *args, &b)\n end\n end",
"def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end",
"def method_missing(method_name, *args, &block)\r\n if model\r\n scopes = ActiveRecord::Base.scopes.merge(model.scopes).keys\r\n\r\n if scopes.include? method_name\r\n return Restful::Resource::Scope.new self, method_name, model, args,\r\n block\r\n elsif method_name.to_s =~ /^(?:find(?:_all)?|first|last)_by_/\r\n finder method_name\r\n return send method_name, *args, &block\r\n end\r\n end\r\n\r\n super\r\n end",
"def method_missing(meth, *args) = parameters.has_key?(meth) ? parameters[meth] : meth",
"def method_missing(meth, *args)\n if respond_to_missing?(meth)\n person.send(meth)\n else\n super(meth, *args)\n end\n end",
"def respond_to?(method_name, include_private = false)\n klass.has_named_scope?(method_name) || super\n end",
"def method_missing(sym, *args)\n if args.empty? && !block_given? && respond_to?(sym.to_s)\n self[sym.to_s]\n else\n super\n end\n end",
"def method_missing(method_name, *method_args)\n get(method_name) || super.method_missing(method_name, *method_args)\n end",
"def method_missing(sym, *args, &block)\n if self.internal_object.key?(sym.to_s)\n return self.internal_object[sym.to_s]\n end\n\n super\n end",
"def method_missing(name, *args)\n if wrapped_object.respond_to? name\n wrapped_object.send name, *args\n else\n super\n end\n end",
"def method_missing(name, *args, &blk)\n provider.send(name, *args)\n end",
"def method_missing(method, *args)\n api_obj.send(method, *args)\n end",
"def method_missing(m, *args, &block)\n target = self.__getobj__\n unless target.respond_to?(m)\n super(m, *args, &block)\n else\n target.__send__(m, *args, &block)\n end\n end",
"def method_missing(name, *args)\n\t\t\tcall name, *args\n\t\tend",
"def method_missing(method, *args)\n if method =~ /^find_all_by/\n @scope.send(method, *args).map do |element|\n element.restrict(@context, options_with_escape)\n end\n elsif method =~ /^find_by/\n @scope.send(method, *args).restrict(@context, options_with_escape)\n elsif @scope.heimdallr_scopes && @scope.heimdallr_scopes.include?(method)\n Proxy::Collection.new(@context, @scope.send(method, *args), options_with_escape)\n elsif @scope.respond_to? method\n raise InsecureOperationError,\n \"Potentially insecure method #{method} was called\"\n else\n super\n end\n end",
"def method_missing(name, *args, &block)\n target.send(name, *args, &block)\n end",
"def method_missing(method_sym, *args, &block)\n return nil\n end",
"def method_missing(name, *args, &block)\n self[name.to_s]\n end",
"def method_missing(meth, *args, &block)\n @_resource.send(:method_missing, meth, *args, &block)\n end",
"def method_missing(method_name, *args, &block)\n base.respond_to?(method_name) ? base.send(method_name, *args, &block) : super\n end",
"def method_missing(_method, *_args, &_block)\n @owner.send(_method, *_args, &_block)\n end",
"def method_missing(method, *args, &block)\n if name?(method.to_sym)\n find(method.to_sym)\n else\n super\n end\n end",
"def method_missing(method_name, *args)\n\t\tif DELEGATED_METHODS.include?(method_name)\n\t\t\[email protected](method_name, *args)\n\t\telse\n\t\t\tsuper\n\t\tend\n\tend"
] | [
"0.70185107",
"0.6781858",
"0.6773153",
"0.6773153",
"0.67460823",
"0.67460823",
"0.67295384",
"0.6712492",
"0.66845554",
"0.66845554",
"0.66845554",
"0.66845554",
"0.6621574",
"0.66075516",
"0.66075516",
"0.65530634",
"0.6552229",
"0.6552229",
"0.6552229",
"0.65402293",
"0.64165044",
"0.6401726",
"0.64009356",
"0.6358099",
"0.63516045",
"0.63453805",
"0.63165385",
"0.63048613",
"0.6294646",
"0.62805223",
"0.6279578",
"0.6239817",
"0.6219016",
"0.61903954",
"0.616669",
"0.6159725",
"0.6152193",
"0.61338955",
"0.6132197",
"0.61317307",
"0.60934323",
"0.60934323",
"0.6079756",
"0.60689473",
"0.6045112",
"0.60193783",
"0.6015186",
"0.5989532",
"0.59184873",
"0.59089303",
"0.59025854",
"0.58933127",
"0.5884602",
"0.58776826",
"0.5870681",
"0.58701",
"0.58606607",
"0.5858505",
"0.5855025",
"0.5855025",
"0.58500624",
"0.58454823",
"0.5831149",
"0.58307",
"0.58272463",
"0.58231384",
"0.58136266",
"0.58013165",
"0.57916534",
"0.57800686",
"0.57785755",
"0.5770029",
"0.5765307",
"0.57592654",
"0.5752044",
"0.57477915",
"0.5733387",
"0.5727803",
"0.5725361",
"0.57092196",
"0.57046807",
"0.5699351",
"0.5697632",
"0.56947553",
"0.5693979",
"0.56922716",
"0.56792355",
"0.56701195",
"0.5669131",
"0.56620455",
"0.56564474",
"0.56485033",
"0.5647131",
"0.56432223",
"0.5634338",
"0.5630555",
"0.5624494",
"0.5624224",
"0.5624093",
"0.5617832"
] | 0.5628653 | 96 |
Chain with another one of klass's named_scopes. | def chain_with(scope_name)
self + klass.send(scope_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scopes *names\n self.scope_names ||= []\n\n names.each do |scope|\n self.scope_names << scope\n\n # hand chaining duties off to the ResourceProxy instance\n define_singleton_method scope do\n resource_proxy.append_scope(scope)\n end\n\n # ResourceProxy instance also needs to respond to scopes\n resource_proxy_class.send(:define_method, scope) do\n append_scope(scope)\n end\n end\n\n # self.scope_names.freeze\n end",
"def inherit_scope(other)\n @scope = other.scope\n end",
"def chain(new_scope = {})\n new_scope = {} if new_scope.nil?\n\n self.class.new(collection_path, collection_name, client).tap do |new_request|\n new_request.scope.merge!(scope)\n new_request.scope.merge!(new_scope)\n end\n end",
"def use_scopes(*klasses, &block)\n self.scope_context += klasses.flatten\n yield\n self.scope_context -= klasses.flatten\n nil # should not be chained\n end",
"def merge(new_scopes); end",
"def apply_scopes(*)\n relation = super\n relation = relation.accessible_by(current_ability) if scope_accessible?\n relation\n end",
"def new_scope(names)\n values = names.map { |n| self[n] }\n self.class.new(names, values + extras, self)\n end",
"def scope_chain\n scope ? [[scope]] : [[]]\n end",
"def +(other_scope)\n self.class.new(klass, parameters.merge(other_scope.parameters))\n end",
"def newscope(parent, options = {})\n raise _('having multiple named scopes is not supported when scripting')\n end",
"def apply_to_scope(scope)\n scope\n end",
"def namespace_scopes\n super\n end",
"def as(scope); end",
"def politely_add_named_scope(*args)\n if self.respond_to? args.first\n Rails.logger.warn \"Can't add named_scope #{args.first} to #{self.name}. It would overwrite an existing method.\"\n @failed_to_add_scopes << args.first unless @failed_to_add_scopes.include?(args.first)\n else\n @scopes_added_by_common_scopes ||= []\n @scopes_added_by_common_scopes << args.first unless @scopes_added_by_common_scopes.include?(args.first)\n impolitely_add_named_scope *args\n end\n end",
"def carry_scope(acts=nil,scope=nil)\n scope||= get_scope\n return if scope.nil?\n acts.each_with_index do |act,index|\n if act.start_with?('new')\n acts[index]=\"#{act}?scope=#{scope}\"\n end\n end \n end",
"def scope_for(finder, options = {})\n return finder unless options.keys.include? @named_scope\n value = options.delete(@named_scope)\n finder.send(@named_scope, value)\n end",
"def apply_on(another_scope)\n array = *self.arguments\n if Product.respond_to?(self.name.intern)\n relation2 = if (array.blank? || array.size < 2)\n Product.send(self.name.intern, array.try(:first))\n else\n Product.send(self.name.intern, *array)\n end\n else\n relation2 = Product.search({self.name.intern => array}).relation\n end\n unless another_scope.class == ActiveRecord::Relation\n another_scope = another_scope.send(:relation)\n end\n another_scope.merge(relation2)\n end",
"def dampen_scope(scope)\n define_method(:dampening_scope) do\n scope\n end\n end",
"def named_scope(name, parameters)\n scope_proxy.add_named(name, parameters)\n end",
"def expand(scopes)\n scopes = Array(scopes.to_a)\n registered_scopes = scopes.filter { |sc| @mapping.key?(sc) }\n result = registered_scopes + registered_scopes.reduce([]) { |memo, sc|\n memo + Array(@mapping.fetch(sc))\n }.uniq\n\n Scopes.wrap(result)\n end",
"def merge!( otherstate )\n\t\[email protected]( @scopes.pop + otherstate.scope )\n\t\t# self.attributes.merge!( otherstate.attributes )\n\t\tself.options.merge!( otherstate.options )\n\t\treturn self\n\tend",
"def expand_scopes(scopes)\n scopes.map do |scope|\n [scope, descendents(scope)]\n end.flatten.uniq.sort\n end",
"def extra_scopes()\n @scopes_added_by_common_scopes\n end",
"def scope(*args); end",
"def inherited(subclass)\n super\n subclass.scopes = scopes.dup\n end",
"def scope() binding end",
"def scoped_by(name, options = {})\n options[:scope] ||= :reference\n if scope_class = self.class.scope_types[options[:scope]]\n @scopes[name] = scope_class.new(@model, name, options)\n end\n end",
"def add_scopes(params, base = self)\n # scopes are stored as strings but we want to allow\n params = params.with_indifferent_access\n base = self.add_static_scopes(params, base)\n return self.add_dynamic_scopes(params, base)\n end",
"def create_with_scope(name); end",
"def with_scope(scope)\n (@@scopes ||= []) << scope\n yield ensure @@scopes.pop\n end",
"def with_scope(scope)\n (@@scopes ||= []) << scope\n yield ensure @@scopes.pop\n end",
"def has_scopes(*scopes)\n self.scope_class_methods = self.scope_class_methods +\n Array.wrap(scopes).map(&:to_sym)\n end",
"def scope(parameters)\n scope_proxy.ad_hoc(parameters)\n end",
"def define_scope_method(name)\n singleton_class.class_eval do\n ruby2_keywords(\n define_method(name) do |*args|\n scoping = _declared_scopes[name]\n scope = instance_exec(*args, &scoping[:scope])\n extension = scoping[:extension]\n to_merge = scope || queryable\n criteria = to_merge.empty_and_chainable? ? to_merge : with_default_scope.merge(to_merge)\n criteria.extend(extension)\n criteria\n end\n )\n end\n end",
"def scopes; end",
"def target_scope\n AssociationRelation.create(klass, self).merge!(klass.scope_for_association)\n end",
"def apply_standard_scope\n each_sort do |attribute, direction|\n @scope = resource.adapter.order(@scope, attribute, direction)\n end\n @scope\n end",
"def last_chain_scope(scope, *args)\n # 5.0 table, reflection, owner, association_klass\n # 5.1 table, reflection, owner\n # 5.2 reflection, owner\n\n reflection = args.size.eql?(2) ? args[0] : args[1]\n return super unless reflection.connected_through_array?\n\n table = args[0] if args.size > 2\n keys = args.size.eql?(4) ? reflection.join_keys(args[3]) : reflection.join_keys\n owner = args.size.eql?(2) ? args[1] : args[2]\n\n value = transform_value(owner[keys.foreign_key])\n constraint, binds = build_id_constraint(reflection, keys, value, table, true)\n\n if Torque::PostgreSQL::AR521\n scope.where!(constraint)\n else\n klass = ::ActiveRecord::Relation::WhereClause\n scope.where_clause += klass.new([constraint], binds)\n scope\n end\n end",
"def run_scope(scope, machine, klass, states); end",
"def scope() yield end",
"def next_chain_scope(scope, *args)\n # 5.0 table, reflection, association_klass, foreign_table, next_reflection\n # 5.1 table, reflection, foreign_table, next_reflection\n # 5.2 reflection, next_reflection\n\n reflection = args.size.eql?(2) ? args[0] : args[1]\n return super unless reflection.connected_through_array?\n\n table = args[0] if args.size > 2\n next_reflection = args[-1]\n\n foreign_table = args[-2] if args.size.eql?(5)\n foreign_table ||= next_reflection.aliased_table\n\n keys = args.size.eql?(5) ? reflection.join_keys(args[2]) : reflection.join_keys\n\n value = foreign_table[keys.foreign_key]\n constraint, *_ = build_id_constraint(reflection, keys, value, table)\n\n scope.joins!(join(foreign_table, constraint))\n end",
"def scope\n @scope.dup\n end",
"def map_scopes!(&ruby_block)\n @scopes.map! do |scope|\n scope = ruby_block.call(scope)\n scope.parent = self unless scope.parent\n scope\n end\n end",
"def apply_scopes(target, scopie: default_scopie, hash: params)\n Scopie.apply_scopes(target, hash, method: hash[:action], scopie: scopie)\n end",
"def apply_scope(target, type:, name: :default, scope_options: nil)\n raise ActionPolicy::UnknownScopeType.new(self.class, type) unless\n self.class.scoping_handlers.key?(type)\n\n raise ActionPolicy::UnknownNamedScope.new(self.class, type, name) unless\n self.class.scoping_handlers[type].key?(name)\n\n mid = :\"__scoping__#{type}__#{name}\"\n scope_options ? send(mid, target, **scope_options) : send(mid, target)\n end",
"def apply_custom_scope\n each_sort do |attribute, direction|\n @scope = custom_scope\n .call(@scope, attribute, direction, resource.context)\n end\n @scope\n end",
"def method_missing(name, *args)\n if scopes[name].nil?\n super\n else\n execute_scope(name, *args)\n end\n end",
"def mixins(*scopes); end",
"def set_search_scope(opts)\n opts = check_params(opts,[:search_scopes])\n super(opts)\n end",
"def scope(name = nil)\n raise 'Must specify name if no children have been defined yet' unless name || last_child\n name ||= last_child.name\n @outgoing_scopes[name]\n end",
"def execute_scope(name, *args)\n procedure = scopes[name]\n instance_exec(*args, &procedure)\n self\n end",
"def resolved_scope(scope)\n scoper_object(scope).resolve\n end",
"def replace_names!(former,nname)\n # Stop here if the name is redeclared.\n return if self.each_inner.find {|inner| inner.name == former }\n # Recurse on the sub scopes and behaviors.\n replace_names_subs!(former,nname)\n end",
"def method_missing(name, *args, &block)\n if scopes.include?(name)\n scopes[name].call(self, *args)\n elsif klass\n target.send(name, *args, &block)\n else\n @parent.fuse(@conditions); @parent.send(name, *args, &block)\n end\n end",
"def initialize(name)\n @name = name\n @predicates = {}\n \n @@scopes[@name] = self\n end",
"def get_named_scope_info(klass)\n klass.respond_to?(:scopes) ? klass.scopes.keys.map(&:to_s) : []\n end",
"def named_scope_method\n # Can't use respond_to because both AR 2 and 3\n # respond to both +scope+ and +named_scope+.\n ActiveRecord::VERSION::MAJOR == 2 ? :named_scope : :scope\n end",
"def search_scope\n super\n end",
"def nested_set_scope(options = {})\n add_scope_conditions_to_options(options)\n\n self.class.base_class.default_scoped.nested_set_scope options\n end",
"def nested_set_scope\n raise \"called nested_set_scope\"\n options = {:order => quoted_left_column_name}\n scopes = Array(acts_as_nested_set_options[:scope])\n options[:conditions] = scopes.inject({}) do |conditions,attr|\n conditions.merge attr => self[attr]\n end unless scopes.empty?\n self.class.base_class.scoped options\n end",
"def with_scope(criteria)\n scope_stack = self.scope_stack\n scope_stack << criteria\n begin\n yield criteria\n ensure\n scope_stack.pop\n end\n end",
"def create_with_scope(name)\n attribute = self.attribute\n lambda {|model, values| model.filter(attribute.to_sym => values)}\n end",
"def with_scope(scope)\n current_scope = @current_scope\n @current_scope = scope\n result = yield\n @current_scope = current_scope\n result\n end",
"def scoped_by( *scope )\n scope = scope.length == 1 ? scope.first : scope\n sub_map = @map.get( expand_key( scope ) ) || {}\n Properties.new( sub_map )\n end",
"def merge!(scope)\n @options.merge!(scope.options)\n\n @attributes += scope.attributes\n @associations.merge!(scope.associations)\n\n @attributes.uniq!\n\n self\n end",
"def scope(scope, &block)\n @scopes[scope] ||= []\n @scopes[scope] << block\n end",
"def policy_scope(scope, policy_scope_class: nil)\n api_scope = self.class.inherited_pundit_api_scope || []\n\n super(api_scope + [scope], policy_scope_class: policy_scope_class)\n end",
"def subscope\n self.clone\n end",
"def with_scope(method_scoping = {}, action = :merge, &block)\n method_scoping = method_scoping.method_scoping if method_scoping.respond_to?(:method_scoping)\n\n # Dup first and second level of hash (method and params).\n method_scoping = method_scoping.inject({}) do |hash, (method, params)|\n hash[method] = (params == true) ? params : params.dup\n hash\n end\n\n method_scoping.assert_valid_keys([ :find, :create ])\n\n if f = method_scoping[:find]\n f.assert_valid_keys(VALID_FIND_OPTIONS)\n set_readonly_option! f\n end\n\n self.scoped_methods << merge_scopings(current_scoped_methods, method_scoping, action)\n begin\n yield\n ensure\n self.scoped_methods.pop\n end\n end",
"def scope_query(operand)\n @scope << operand.class\n end",
"def set_scope_class\n klass = self.class::Scope\n klass.send(:include, ScopeMethods)\n @scope_class = klass.new(@scope, @search_attributes)\n end",
"def scopes\n read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {})\n end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def enable_named_scope(patch = true)\n return if defined? ActiveRecord::NamedScope\n require 'will_paginate/named_scope'\n require 'will_paginate/named_scope_patch' if patch\n\n ActiveRecord::Base.class_eval do\n include WillPaginate::NamedScope\n end\n end",
"def scope_with_resource_definition_addition(name, opts = {}, &block)\n # if it's a proc, we figure out its parameters\n params = if opts.is_a?(Proc)\n self.get_scope_parameters(opts)\n # otherwise we just use a blank hash\n else\n {}\n end\n\n # update scope definition\n self.stored_scope_definition = self.stored_scope_definition.merge(\n name.to_sym => params\n )\n\n # call the original scope definition method\n self.scope_without_resource_definition_addition(\n name,\n opts,\n &block\n )\n end",
"def scope_by(&block)\n raise 'Cannot define scope after scope has been called.' if @scope\n\n @scope_block = block\n end",
"def resolve(scope)\n scope\n end",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def method_missing_with_has_scope(method, *args, &block)\n if named_scopes\n named_scopes.keys.each do |name|\n inner = method.to_s.sub(\"_#{name}\",'')\n if inner =~ /^find(_all)_by/ || respond_to?(inner)\n module_eval \"def self.#{method}(*args, &block); with_#{name} { #{inner}(*args, &block) }; end\"\n return send(method, *args, &block)\n end\n end\n end\n method_missing_without_has_scope(method, *args, &block)\n end",
"def add_dynamic_scopes(params, base)\n self.dynamic_scopes.each_pair do |name, args|\n # make sure we have all required arguments\n next unless self.check_required_scope_args(args, params[name])\n\n # the args we will apply\n caller_args = []\n\n # iterate through our args and add them to an array to send to our\n # scope\n args.keys.each do |subkey|\n # we only apply things that are present or explicitly false\n if val = self.get_scope_arg_value(subkey, params[name][subkey])\n caller_args << val\n end\n end\n # call our scope with the supplied args\n base = base.send(name, *caller_args)\n end\n return base\n end",
"def scoped(scope = {}, &block)\n ActiveRecord::NamedScope::Scope.new(self, scope, &block)\n end",
"def reduce_scope_by_authorization(scope)\n return scope unless must_match_user_roles?\n scope.scoped_by_user_roles allowed_roles, match_roles_on\n end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def build_collection_scope_base(some_instance)\n some_instance.send(@collection_name).scoped\n end",
"def protected_scope(*args)\n self.scope_without_resource_definition_addition(*args)\n end",
"def with_scope(method_scoping = {}, action = :merge, &block)\n method_scoping = method_scoping.method_scoping if method_scoping.respond_to?(:method_scoping)\n\n # Dup first and second level of hash (method and params).\n method_scoping = method_scoping.inject({}) do |hash, (method, params)|\n hash[method] = (params == true) ? params : params.dup\n hash\n end\n\n method_scoping.assert_valid_keys([ :find, :create ])\n\n if f = method_scoping[:find]\n f.assert_valid_keys(VALID_FIND_OPTIONS)\n set_readonly_option! f\n end\n\n # Merge scopings\n if [:merge, :reverse_merge].include?(action) && current_scoped_methods\n method_scoping = current_scoped_methods.inject(method_scoping) do |hash, (method, params)|\n case hash[method]\n when Hash\n if method == :find\n (hash[method].keys + params.keys).uniq.each do |key|\n merge = hash[method][key] && params[key] # merge if both scopes have the same key\n if key == :conditions && merge\n if params[key].is_a?(Hash) && hash[method][key].is_a?(Hash)\n hash[method][key] = merge_conditions(hash[method][key].deep_merge(params[key]))\n else\n hash[method][key] = merge_conditions(params[key], hash[method][key])\n end\n elsif key == :include && merge\n hash[method][key] = merge_includes(hash[method][key], params[key]).uniq\n elsif key == :joins && merge\n hash[method][key] = merge_joins(params[key], hash[method][key])\n # begin patch \n elsif key == :order && merge\n hash[method][key] = [params[key], hash[method][key]].reverse.join(' , ') \n # end patch \n else\n hash[method][key] = hash[method][key] || params[key]\n end\n end\n else\n if action == :reverse_merge\n hash[method] = hash[method].merge(params)\n else\n hash[method] = params.merge(hash[method])\n end\n end\n else\n hash[method] = params\n end\n hash\n end\n end\n\n self.scoped_methods << method_scoping\n begin\n yield\n ensure\n self.scoped_methods.pop\n end\n end",
"def add_limit_scopes()\n politely_add_named_scope :limit, lambda {|limit| {:limit => limit} }\n politely_add_named_scope :offset, lambda {|offset| {:offset => offset } }\n end",
"def all\n if current_scope\n current_scope.clone\n else\n default_scoped\n end\n end",
"def custom_filters(scope)\n scope\n end"
] | [
"0.62880945",
"0.62569034",
"0.6231957",
"0.61421496",
"0.60990936",
"0.6068418",
"0.606082",
"0.60203743",
"0.5983783",
"0.59340775",
"0.5843913",
"0.5834608",
"0.57688344",
"0.560718",
"0.5588773",
"0.5517115",
"0.55141205",
"0.54924166",
"0.5491937",
"0.54753065",
"0.54543656",
"0.54157585",
"0.5408997",
"0.5403291",
"0.5364415",
"0.5355833",
"0.53536266",
"0.5352096",
"0.5341447",
"0.5277929",
"0.5277929",
"0.52571607",
"0.5252986",
"0.5203639",
"0.51998895",
"0.51872885",
"0.51659983",
"0.5154215",
"0.51291215",
"0.51185113",
"0.51119024",
"0.5103831",
"0.5095285",
"0.50909144",
"0.5088942",
"0.50888336",
"0.5078029",
"0.50682235",
"0.50642085",
"0.50638294",
"0.5063103",
"0.5057333",
"0.50484973",
"0.504583",
"0.5039029",
"0.5036299",
"0.5035371",
"0.50221574",
"0.50176203",
"0.49957466",
"0.49943167",
"0.49823287",
"0.4979777",
"0.4969844",
"0.49512997",
"0.4946828",
"0.49373734",
"0.49292827",
"0.49253705",
"0.49215463",
"0.49187416",
"0.49184766",
"0.4915378",
"0.4915378",
"0.4915378",
"0.4912088",
"0.49098548",
"0.4901904",
"0.48945403",
"0.4894474",
"0.4887397",
"0.48824006",
"0.48799074",
"0.48771948",
"0.48694798",
"0.48694798",
"0.48694798",
"0.48694798",
"0.48694798",
"0.48694798",
"0.48694798",
"0.48694798",
"0.48694798",
"0.48694798",
"0.48639947",
"0.48611972",
"0.48569074",
"0.48445493",
"0.4832632",
"0.48215967"
] | 0.73902106 | 0 |
Create a new Scope that is the combination of self and other, where other takes priority | def +(other_scope)
self.class.new(klass, parameters.merge(other_scope.parameters))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inherit_scope(other)\n @scope = other.scope\n end",
"def scope\n @scope ||= Scope.new(parent)\n end",
"def scope\n @scope.dup\n end",
"def newscope(parent, options = {})\n raise _('having multiple named scopes is not supported when scripting')\n end",
"def apply_scopes(*)\n relation = super\n relation = relation.accessible_by(current_ability) if scope_accessible?\n relation\n end",
"def scope( new_scope=nil )\n\t\tif new_scope\n\t\t\tself.log.debug \"cloning %p with new scope: %p\" % [ self, new_scope ]\n\t\t\treturn self.clone( :scope => new_scope.to_sym )\n\t\telse\n\t\t\treturn @options[:scope]\n\t\tend\n\tend",
"def subscope\n self.clone\n end",
"def newscope(parent, options = {})\n parent ||= topscope\n scope = Puppet::Parser::Scope.new(self, **options)\n scope.parent = parent\n scope\n end",
"def enter(other_type_defn)\n case other_type_defn\n when nil\n # The type wasn't found, who cares\n Scope.new(@query, nil)\n when @type\n # The condition is the same as current, so reuse self\n self\n when GraphQL::UnionType, GraphQL::InterfaceType\n # Make a new scope of the intersection between the previous & next conditions\n new_types = @query.possible_types(other_type_defn) & concrete_types\n Scope.new(@query, new_types)\n when GraphQL::BaseType\n # If this type is valid within the current scope,\n # return a new scope of _exactly_ this type.\n # Otherwise, this type is out-of-scope so the scope is null.\n if concrete_types.include?(other_type_defn)\n Scope.new(@query, other_type_defn)\n else\n Scope.new(@query, nil)\n end\n else\n raise \"Unexpected scope: #{other_type_defn.inspect}\"\n end\n end",
"def create_with_scope(name); end",
"def chain(new_scope = {})\n new_scope = {} if new_scope.nil?\n\n self.class.new(collection_path, collection_name, client).tap do |new_request|\n new_request.scope.merge!(scope)\n new_request.scope.merge!(new_scope)\n end\n end",
"def target_scope\n AssociationRelation.create(klass, self).merge!(klass.scope_for_association)\n end",
"def apply_to_scope(scope)\n scope\n end",
"def scope\n scope!(operator) if @scopes.empty?\n scope!(\"AND\") if @scopes.last.is_a?(NestedScope)\n @scopes.last\n end",
"def chain_with(scope_name)\n self + klass.send(scope_name)\n end",
"def scope!(operator)\n scope = CriteriaScope.new(operator)\n scopes << scope\n self\n end",
"def scope=(_); end",
"def scope(name = nil)\n raise 'Must specify name if no children have been defined yet' unless name || last_child\n name ||= last_child.name\n @outgoing_scopes[name]\n end",
"def become_sibling_of(other, options = {})\n return true if self.sibling_of?(other, options)\n\n scopes = options[:scope] || self.default_sibling_scope\n other_scope_values = options[:other_scope_values] || {}\n\n scopes = Array.wrap(scopes).compact\n\n\n return false if base_document_class != base_document_class(other)\n\n scopes.each do |scope|\n other_scope_value = other_scope_values.fetch(scope) { other.send(scope) }\n\n relation_metadata = self.reflect_on_association(scope)\n if relation_metadata && other_scope_value\n inverse_metadata = other.intelligent_inverse_metadata(scope, other_scope_value)\n if inverse_metadata\n inverse = inverse_metadata.name\n if inverse_metadata.many?\n other_scope_value.send(inverse) << self\n else\n other_scope_value.send(\"#{inverse}=\", self)\n end\n\n next\n end\n end\n self.send(\"#{scope}=\", other_scope_value)\n end\n end",
"def carry_scope(acts=nil,scope=nil)\n scope||= get_scope\n return if scope.nil?\n acts.each_with_index do |act,index|\n if act.start_with?('new')\n acts[index]=\"#{act}?scope=#{scope}\"\n end\n end \n end",
"def new_scope(names)\n values = names.map { |n| self[n] }\n self.class.new(names, values + extras, self)\n end",
"def subscope(namespace)\n namespace = unique_name(namespace)\n namespace = self.namespace + '/' + namespace if self.namespace != ''\n sub_scope = Tensorflow::Scope.new\n sub_scope.graph = graph.clone\n sub_scope.namemap = namemap.clone\n sub_scope.namespace = namespace.clone\n sub_scope\n end",
"def same_scope?(other)\n Array(nil).all? do |attr|\n self.send(attr) == other.send(attr)\n end\n end",
"def scope\n @scope ||= {}\n end",
"def scope\n @scope ||= {}\n end",
"def same_scope?(other)\n same_kind?(other) && tree.columns.scope.all? do |attr|\n record[attr] == other[attr]\n end\n end",
"def dampen_scope(scope)\n define_method(:dampening_scope) do\n scope\n end\n end",
"def get_closest_containing_scope\n self\n end",
"def same_scope?(other)\n Array(acts_as_nested_set_options[:scope]).all? do |attr|\n self.send(attr) == other.send(attr)\n end\n end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def merge(new_scopes); end",
"def scope_chain\n scope ? [[scope]] : [[]]\n end",
"def same_scope?(other)\n Array(acts_as_nested_set_options[:scope]).all? do |attr|\n self.send(attr) == other.send(attr)\n end\n end",
"def scope(scope_name)\n Scope.new(@backend, @name, scope_name)\n end",
"def new_scope\n self.class.new(@input, @output, @wrap_at,\n @page_at, @indent_size, @indent_level)\n end",
"def scope\n finder_or_run(:scope)\n end",
"def nested_set_scope(options = {})\n add_scope_conditions_to_options(options)\n\n self.class.base_class.default_scoped.nested_set_scope options\n end",
"def scope() binding end",
"def apply_standard_scope\n each_sort do |attribute, direction|\n @scope = resource.adapter.order(@scope, attribute, direction)\n end\n @scope\n end",
"def same_scope?(other)\n scope_column_names.empty? || scope_column_names.all? do |attr|\n self[attr] == other[attr]\n end\n end",
"def create_with_scope(name)\n attribute = self.attribute\n lambda {|model, values| model.filter(attribute.to_sym => values)}\n end",
"def merge!( otherstate )\n\t\[email protected]( @scopes.pop + otherstate.scope )\n\t\t# self.attributes.merge!( otherstate.attributes )\n\t\tself.options.merge!( otherstate.options )\n\t\treturn self\n\tend",
"def scoped_by(name, options = {})\n options[:scope] ||= :reference\n if scope_class = self.class.scope_types[options[:scope]]\n @scopes[name] = scope_class.new(@model, name, options)\n end\n end",
"def protected_scope(*args)\n self.scope_without_resource_definition_addition(*args)\n end",
"def base_scope\n ApplicationRecord.none\n end",
"def merge!(scope)\n @options.merge!(scope.options)\n\n @attributes += scope.attributes\n @associations.merge!(scope.associations)\n\n @attributes.uniq!\n\n self\n end",
"def update_scope\n filter = (id == record.id) | (parent_id == from.parent_id) | (parent_id == to.parent_id)\n node.scope.where(filter.to_sql)\n end",
"def scope_association\n parent? ? scope_parent_association : scope_model\n end",
"def apply_on(another_scope)\n array = *self.arguments\n if Product.respond_to?(self.name.intern)\n relation2 = if (array.blank? || array.size < 2)\n Product.send(self.name.intern, array.try(:first))\n else\n Product.send(self.name.intern, *array)\n end\n else\n relation2 = Product.search({self.name.intern => array}).relation\n end\n unless another_scope.class == ActiveRecord::Relation\n another_scope = another_scope.send(:relation)\n end\n another_scope.merge(relation2)\n end",
"def create_scope\n sprintf \"%s/%s/signer\", @self_key, @client_id\n end",
"def it_scope\n @it_scope ||= Example::Scope.new(self)\n end",
"def current_scope\n @scope\n end",
"def extra_scopes()\n @scopes_added_by_common_scopes\n end",
"def scope\n @scope\n end",
"def scope\n @scope\n end",
"def scope_by(&block)\n raise 'Cannot define scope after scope has been called.' if @scope\n\n @scope_block = block\n end",
"def ancestors_through(other, scope = {})\n ancestors_and_self_through(other, scope) - [self]\n end",
"def scoped\n self.default_scopable = true\n apply_default_scope\n end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def create_without_scope(name); end",
"def scope_query(operand)\n @scope << operand.class\n end",
"def scope= new_scope\n case new_scope\n when Array\n new_scope.each do |scope|\n if scope.include? \" \"\n raise ArgumentError,\n \"Individual scopes cannot contain the space character.\"\n end\n end\n @scope = new_scope\n when String\n @scope = new_scope.split \" \"\n when nil\n @scope = nil\n else\n raise TypeError, \"Expected Array or String, got #{new_scope.class}\"\n end\n end",
"def all\n if current_scope\n current_scope.clone\n else\n default_scoped\n end\n end",
"def last_chain_scope(scope, *args)\n # 5.0 table, reflection, owner, association_klass\n # 5.1 table, reflection, owner\n # 5.2 reflection, owner\n\n reflection = args.size.eql?(2) ? args[0] : args[1]\n return super unless reflection.connected_through_array?\n\n table = args[0] if args.size > 2\n keys = args.size.eql?(4) ? reflection.join_keys(args[3]) : reflection.join_keys\n owner = args.size.eql?(2) ? args[1] : args[2]\n\n value = transform_value(owner[keys.foreign_key])\n constraint, binds = build_id_constraint(reflection, keys, value, table, true)\n\n if Torque::PostgreSQL::AR521\n scope.where!(constraint)\n else\n klass = ::ActiveRecord::Relation::WhereClause\n scope.where_clause += klass.new([constraint], binds)\n scope\n end\n end",
"def bt_same_scope?(other)\n bt_scope_attributes == other.bt_scope_attributes\n end",
"def scope(*args); end",
"def nested_set_scope_without_default_scope(options = {})\n add_scope_conditions_to_options(options)\n\n self.class.base_class.unscoped.nested_set_scope options\n end",
"def scope\n Repository.context << self\n\n begin\n return yield(self)\n ensure\n Repository.context.pop\n end\n end",
"def scope_level; end",
"def scope=(v); end",
"def scope=(v); end",
"def scope\n return @scope if @scope\n\n @scope = hard_scope.dup\n soft_dependencies = []\n\n enabled_dependencies.each do |dependency|\n binds = nil\n node = nil\n\n if dependency.polymorphic?\n alias_prefix = SOFT_PREFIX if @scope.manager.ast.with&.children&.map(&:left)&.map(&:name)&.include?(\"#{HARD_PREFIX}#{dependency.name.to_s.pluralize}\")\n dependency.models.each do |model|\n next unless model.scoped?\n next unless circular_dependency?(dependency, model) || alias_prefix\n\n model_manager = model.hard_scope.manager.dup\n model_manager.projections = [\n Arel::Nodes::As.new(Arel::Nodes::Quoted.new(model.clazz.name), Arel::Nodes::SqlLiteral.new(:type.to_s)),\n model.primary_key.as(:id.to_s)\n ]\n\n if node\n binds.concat(model.hard_scope.binds)\n node = node.union_all(model_manager)\n else\n binds = model.hard_scope.binds\n node = model_manager.ast\n end\n end\n else\n next unless circular_dependency?(dependency) && dependency.soft?\n next unless dependency.models.first.scoped?\n\n model = dependency.models.first\n binds = model.hard_scope.binds\n manager = model.hard_scope.manager.dup\n manager.projections = [model.primary_key.as(:id.to_s)]\n node = manager.ast\n end\n\n next unless node\n\n dependencies = Arel::Table.new(\"#{alias_prefix}#{dependency.name.to_s.pluralize}\")\n\n on = dependencies[:id].eq(arel_table[dependency.foreign_key])\n on = dependencies[:type].eq(arel_table[dependency.foreign_type]).and(on) if dependency.polymorphic?\n\n @scope.manager\n .join(dependencies, Arel::Nodes::OuterJoin)\n .on(on)\n .prepend_with(Arel::Nodes::As.new(dependencies, Arel::Nodes::Grouping.new(node)))\n @scope.binds.unshift(*binds)\n soft_dependencies << DependencyTable.new(dependency, dependencies)\n end\n\n unless soft_dependencies.empty?\n @scope.manager.projections = enabled_columns.keys.map do |column|\n info = soft_dependencies.find { |dt| dt.dependency.foreign_key == column }\n next info.table[info.dependency.models.first.clazz.primary_key].as(info.dependency.foreign_key) if info\n\n info = soft_dependencies.find { |dt| dt.dependency.foreign_type == column }\n next info.table[:type].as(info.dependency.foreign_type) if info\n\n arel_table[column]\n end\n end\n\n @scope\n end",
"def scoped(scope = {}, &block)\n ActiveRecord::NamedScope::Scope.new(self, scope, &block)\n end",
"def local_scope; @scope = :local end",
"def scope\n @scope ||= TestScope.new(self)\n end",
"def scope_parent_association\n @scope_association ||= scoping_object.send(parent_model_to_method_sym).find(parent_param).send(model_name_to_method_sym)\n end",
"def apply_default_scope\n if klass.default_scoping && default_scopable?\n self.default_scopable = false\n fuse(klass.default_scoping)\n else\n self\n end\n end",
"def as(scope); end",
"def nested_set_scope\n raise \"called nested_set_scope\"\n options = {:order => quoted_left_column_name}\n scopes = Array(acts_as_nested_set_options[:scope])\n options[:conditions] = scopes.inject({}) do |conditions,attr|\n conditions.merge attr => self[attr]\n end unless scopes.empty?\n self.class.base_class.scoped options\n end",
"def scope_options; end",
"def scope_options; end",
"def apply_custom_scope\n each_sort do |attribute, direction|\n @scope = custom_scope\n .call(@scope, attribute, direction, resource.context)\n end\n @scope\n end",
"def self_and_ancestors\n nested_set_scope.\n where(\n \"(#{self.class.quoted_table_name}.#{self.class.quoted_total_order_column_name} < ?\n and ? < (#{self.class.quoted_table_name}.#{self.class.quoted_snumv_column_name}/#{self.class.quoted_table_name}.#{self.class.quoted_sdenv_column_name})) or\n #{self.class.quoted_table_name}.#{self.class.quoted_primary_column_name} = ?\", self.total_order, self.total_order, self.primary_id\n )\n end",
"def scope\n assoc_scope = method(:association_scope)\n join_scope = method(:join_association_scope)\n\n ->(join_or_parent) {\n if join_or_parent.is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation)\n join_scope[join_or_parent]\n elsif join_or_parent.is_a?(ActiveRecord::Base)\n assoc_scope[join_or_parent]\n else\n where(nil)\n end.extending(Relation::Iterable)\n }\n end",
"def define_scope_method(name)\n singleton_class.class_eval do\n ruby2_keywords(\n define_method(name) do |*args|\n scoping = _declared_scopes[name]\n scope = instance_exec(*args, &scoping[:scope])\n extension = scoping[:extension]\n to_merge = scope || queryable\n criteria = to_merge.empty_and_chainable? ? to_merge : with_default_scope.merge(to_merge)\n criteria.extend(extension)\n criteria\n end\n )\n end\n end",
"def where!(args={})\n scope.where!(args)\n self\n end",
"def get_scope(cur_scope = nil)\n # base default scope is set up here so that deactivated module can update this\n cur_scope = AssemblyComponent.scoped if (cur_scope.nil?)\n return (defined?(super)) ? super(cur_scope) : cur_scope\n end",
"def siblings_through(other, scope = {})\n self_and_siblings_through(other, scope) - [self]\n end",
"def scope_with_resource_definition_addition(name, opts = {}, &block)\n # if it's a proc, we figure out its parameters\n params = if opts.is_a?(Proc)\n self.get_scope_parameters(opts)\n # otherwise we just use a blank hash\n else\n {}\n end\n\n # update scope definition\n self.stored_scope_definition = self.stored_scope_definition.merge(\n name.to_sym => params\n )\n\n # call the original scope definition method\n self.scope_without_resource_definition_addition(\n name,\n opts,\n &block\n )\n end"
] | [
"0.7560674",
"0.66863286",
"0.6504503",
"0.6476411",
"0.6380694",
"0.6317037",
"0.62521005",
"0.6178332",
"0.60455847",
"0.5993693",
"0.59464115",
"0.5939075",
"0.5919033",
"0.58723295",
"0.5846496",
"0.5746002",
"0.57339793",
"0.5711369",
"0.56971073",
"0.56944644",
"0.56920254",
"0.5689985",
"0.565994",
"0.56552577",
"0.56552577",
"0.5632565",
"0.5622824",
"0.5600197",
"0.5598462",
"0.55878764",
"0.55878764",
"0.55878764",
"0.55878764",
"0.55878764",
"0.55878764",
"0.55878764",
"0.55878764",
"0.55878764",
"0.55878764",
"0.5577421",
"0.55635726",
"0.5549375",
"0.5524551",
"0.55243826",
"0.54981524",
"0.54912156",
"0.54829854",
"0.54679507",
"0.5465918",
"0.54557735",
"0.54535097",
"0.5451018",
"0.544025",
"0.5435221",
"0.54269105",
"0.5423309",
"0.54213184",
"0.54045135",
"0.53863436",
"0.5381554",
"0.5373805",
"0.53668994",
"0.5358142",
"0.5358142",
"0.535803",
"0.53553045",
"0.5334562",
"0.5329629",
"0.5329629",
"0.5329629",
"0.53275347",
"0.53254515",
"0.53213483",
"0.53104633",
"0.53080654",
"0.5305",
"0.53021973",
"0.5286818",
"0.52863634",
"0.52847624",
"0.52782476",
"0.52782476",
"0.5275167",
"0.52746016",
"0.5266209",
"0.5262892",
"0.52550185",
"0.5246343",
"0.52433145",
"0.52422315",
"0.52417415",
"0.52417415",
"0.52360415",
"0.5231214",
"0.5227927",
"0.5223038",
"0.5201568",
"0.5184384",
"0.5171324",
"0.5167538"
] | 0.7458148 | 1 |
Remove all participants from the collection type and only add back in admins | def remove_all_participants
Hyrax::CollectionTypeParticipant.where(hyrax_collection_type_id: id).all.find_each(&:destroy!)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 remove_from_collection(parentCollectionIDs)\n parentCollectionIDs.each do |id|\n c = CwrcCollection.find(id.strip)\n \n self.remove_relationship(:is_member_of_collection, c)\n \n c.remove_relationship(:has_collection_member, self)\n c.save\n end\n self.save\n end",
"def remove_from_general\n # Get general committees (may be more than one)\n general = Committee.where(\n committee_type_id: CommitteeType.general.id\n )\n\n # If this member is in the general members group (tested using set difference)\n if (general - self.committees).empty?\n general.each do |committee|\n self.committees.delete(general)\n end\n end\n end",
"def remove_collection\n source, collection = get_source_and_collection\n collection.updatable_by?(current_user) || raise(Hobo::PermissionDeniedError, \"#{self.class.name}#assign_collection\")\n collection.real_source.delete(source)\n collection.save!\n end",
"def other_participants(user)\n all = recipients\n all.delete(user)\n all.delete(nil) # nil will appear when any of the user in the coversation is deleted later.\n all\n end",
"def remove_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n participant_ids = params[\"participant_ids\"]\n\n if user != nil and meeting != nil and participant_ids.length > 0\n participant_ids.each do |participant_id|\n if meeting.participants.exists?(participant_id)\n # remove all the participant's votes from each suggestion\n meeting.suggestions.each do |suggestion|\n vote = Vote.where(:voter_id => participant_id, :suggestion_id => suggestion.id)\n if vote != nil\n suggestion.votes.delete(vote)\n end\n end\n meeting.participants.delete(User.find(participant_id))\n end\n end\n self.send_ok\n else\n self.send_error 401\n end\n end",
"def remove_all_members\n super\n end",
"def remove_all_members\n super\n end",
"def participants_removed # :nodoc:\n @properties[REMOVED].map { |id| @context.users[id] }\n end",
"def index\n @participants = Participant.all.to_a.delete_if {|participant| @selected_participants.include? participant}\n end",
"def remove_participants(*participants)\n participants = participants.flatten\n self.logger.error(\"Cannot remove participants when match has scores already\") and raise if self.home_score > 0 || self.away_score > 0\n\n self.home_participant = nil if participants.include? self.home_participant\n self.away_participant = nil if participants.include? self.away_participant\n self.save!\n end",
"def rem_admin oid\n self.admins.delete oid\n end",
"def handle_admin_role_ids(role)\n current_members = send(role.to_s.pluralize)\n new_members = Person.find(send(\"#{role}_ids\"))\n\n to_add = new_members - current_members\n to_remove = current_members - new_members\n to_add.each do |person|\n person.send(\"is_#{role}=\", [true, self])\n disable_authorization_checks { person.save! }\n end\n to_remove.each do |person|\n person.send(\"is_#{role}=\", [false, self])\n disable_authorization_checks { person.save! }\n end\n end",
"def handle_admin_role_ids(role)\n current_members = send(role.to_s.pluralize)\n new_members = Person.find(send(\"#{role}_ids\"))\n\n to_add = new_members - current_members\n to_remove = current_members - new_members\n to_add.each do |person|\n person.send(\"is_#{role}=\", [true, self])\n disable_authorization_checks { person.save! }\n end\n to_remove.each do |person|\n person.send(\"is_#{role}=\", [false, self])\n disable_authorization_checks { person.save! }\n end\n end",
"def destroy\n @collection = Collection.find(params[:id])\n authorize! :destroy, @collection\n\n collectifies = Collectify.where(:collection_id=>@collection)\n collectifies.each do |collectify|\n PublicActivity::Activity.where(\"trackable_type = ? AND trackable_id = ?\", \"Collectify\", collectify.id).destroy_all \n end\n\n PublicActivity::Activity.where(\"trackable_type = ? AND trackable_id = ?\", \"Collection\", @collection.id).destroy_all\n\n @collection.destroy\n\n respond_to do |format|\n format.html { redirect_to user_path(current_user.username) }\n format.json { head :no_content }\n end\n end",
"def handle_destroy\n if !self.is_straightforward\n\n\n self.to_remove_array = []\n user = self.collection.user\n # user.default_collections = user.collections.includes(:games).limit(3)\n #Check if the target collection is in the user's defaults\n if user.default_collections.include?(self.collection)\n user.collections.each do |collection|\n if collection.id != self.collection_id &&\n collection.games.include?(self.game)\n CollectionGame.find_by(\n collection_id: collection.id,\n game_id: self.game.id).destroy\n collection.save\n self.to_remove_array.push(collection.id)\n break\n end\n end\n review = Review.find_by(user_id: user.id, game_id: self.game.id)\n if review\n review.destroy\n self.removeReviewId = review.id\n end\n end\n end\n end",
"def remove_access_to(organisations_to_remove)\n self.organisations = self.organisations - Array(organisations_to_remove)\n end",
"def remove_access_to(organisations_to_remove)\n self.organisations = self.organisations - Array(organisations_to_remove)\n end",
"def purge_type!(type)\n\n collection(type).remove\n end",
"def remove_challenge_reviewer_filter_from_submission_box(user)\n sub_collection = parent_submission_box&.submissions_collection\n\n return unless inside_a_challenge? && sub_collection.present? && user&.handle.present?\n\n sub_collection.collection_filters.tagged_with_user_handle(user.handle).destroy_all\n end",
"def destroy\n if current_user.admin?\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: \"Participant was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end \n end",
"def remove_all\n @owner.transaction do\n self.each { |obj| @owner.send(@remove_proc, obj) }\n end\n @members.clear\n @loaded = false # gmosx: IS this needed?\n end",
"def unsubscribeCollection\n if !session[:user_id]\n flash[:notice] = \"Need to login first\"\n redirect_to :action=> 'login'\n end\n\n roomname = params[:unsubscribecollection][\"roomname\"]\n collectionnodename = params[:unsubscribecollection][\"collectionnodename\"]\n\n begin\n am = session[:am]\n acc = Account.find_by_username(session[:user_id])\n if(acc.nil?)\n flash[:notice] = \"Need to login first\"\n redirect_to :action=> 'login'\n return\n end\n am.keepalive(acc.username, acc.password)\n\n result = am.unsubscribeCollection(roomname, collectionnodename)\n flash[:result] = \"subscribeCollection result success: \" + result\n redirect_to :action => 'accountManager'\n rescue Exception => msg\n flash[:notice] = msg\n end\n\n end",
"def remove_moderator(user)\n \n if self.users.moderators != nil && self.users.moderators.include?(user)\n \n #basic validation to ensure that the category has at least 1 moderator\n if (self.users.moderators.count > 0 == false)\n return redirect_to :back, notice: \"Category must have at least 1 moderator.\"\n else\n #remove the moderator\n s = Subscriber.where(:category_id => self.id, :user_id => user.id).limit(1)[0]\n s.moderator = false\n s.save\n end \n else\n nil\n end \n end",
"def remove_users\r\n @userAdmin.destroy\r\n @user2.destroy\r\n @user3.destroy\r\n end",
"def remove\n recipient_list_members.destroy_all\n if message_recipients.count.zero?\n destroy\n else\n self.removed = true\n save!\n end\n end",
"def destroy\n @user=User.find_by name: session[:user]\n if CollectionUser.where('id_collection LIKE ?', \"#{@collection.id}\").count == 1\n CollectionNote.where('id_collection LIKE ?', \"#{@collection.id}\" ).destroy_all\n CollectionUser.where('id_collection LIKE ?', \"#{@collection.id}\" ).destroy_all\n\n @collection.destroy\n end\n\n CollectionUser.where('id_collection LIKE ? AND id_user LIKE ?', \"#{@collection.id}\" , \"#{@user.id}\" ).destroy_all\n redirect_to :collections\n #@collection.destroy\n #respond_to do |format|\n # format.html { redirect_to collections_url, notice: 'Collection was successfully destroyed.' }\n # 3format.json { head :no_content }\n #end\n end",
"def clean_trash\n return unless self.active? == false and self.rank === MemberRank.find_by_name('Declined Applicant')\n\n # Don't care about what they want\n self.wishlists.destroy_all\n\n # Don't care about the achievements they mooched from us\n self.completed_achievements.destroy_all\n end",
"def remove_all\n @batch = Batch.shod(params[:format])\n @students ||= @batch.students\n authorize! :read, @batch\n end",
"def destroy\n if session[:user] != nil\n @current_user = User.find_by username: session[:user]\n if @collection.owner.id == @current_user.id or @collection.user_ids.include? @current_user.id\n @collection.destroy\n respond_to do |format|\n format.html { redirect_to collections_url, success: 'Collection was successfully destroyed.' }\n format.json { render :show, status: :created, location: @collection }\n end\n else\n respond_to do |format|\n format.html { redirect_to root_path, alert: \"You don't have permission to delete this collection.\" }\n format.json { render :show, status: :created, location: @collection }\n end\n end \n else\n respond_to do |format|\n format.html { redirect_to root_path, alert: \"You are not registered\" }\n format.json { render :show, status: :created, location: @collection }\n end\n end\n end",
"def remove_posts usr\n @conv.posts.each do |post|\n if usr.id == post.user_id\n post.status = 'removed'\n elsif usr.id == post.recipient_id\n post.recipient_status = 'removed'\n end\n post.save\n end\n end",
"def unassign_all(type:, rsuser:)\n\t\t\t\t\tconnection.post(build_path('deleteSid'), nil, type: type, sid: rsuser).code == '200'\n\t\t\t\tend",
"def delete_unused_members\n if !member.nil? && !member.is_a?(User) and \nmember.roles(:true).empty?\n member.destroy\n end\n end",
"def destroy\n @recipient = Recipient.find_by(recipient_list: @recipient_list, mail_user: @mail_user)\n\n if !['included', 'excluded'].include?(@type)\n redirect_to @recipient_list, alert: '指定のリストからユーザーは削除できません。'\n elsif @recipient\n @recipient.update_column(@type, false)\n if [email protected] && [email protected] &&\n (@mail_user.mail_groups & @recipient_list.mail_groups).empty?\n @recipient.destroy\n end\n redirect_to @recipient_list, notice: '指定のリストからユーザーを削除しました。'\n else\n redirect_to @recipient_list, alert: 'ユーザーはリストに含まれていません。'\n end\n end",
"def additional_users_for_destroy\n []\n end",
"def delete\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n participants = meeting.participants\n meeting.participants.delete(participants)\n meeting.delete\n self.send_ok\n else\n self.send_error 401\n end\n end",
"def remove_assignment_templates\n assignments = @course_user.assignments\n assignments.each do |assignment|\n WikiCourseEdits.new(action: :remove_assignment, course: @course,\n current_user:, assignment:)\n end\n end",
"def destroy_share_collection(user)\n SharedCollection.where(user_id: user, collection_id: self.id).destroy_all\n self.notes.each do |n|\n SharedNote.where(user_id: user, note_id: n.id).destroy_all\n end\n end",
"def removeCollection(collection)\n collection.drop\n end",
"def destroy\n @collection = @current_user.collections.find(params[:id])\n @collection.destroy\n\n respond_to do |format|\n format.html { redirect_to user_collections_path,\n \t\t notice: 'Collection sucessfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def unvolunteer(user)\n if self.volunteering_allowed? && self.volunteered_for?(user) then\n v = self.volunteers.find_by_user_id(user.id)\n v.destroy unless v.nil?\n end\n end",
"def destroy\n\t\[email protected]\n\n\t\thead :no_content\n\tend",
"def index\n if current_user.admin?\n @participants = Participant.all \n else\n redirect_to new_participant_url\n end\n \n \n end",
"def remove_inscriptions\n next_fixed_shift_users.destroy_all\n end",
"def remove_all_publications\n add_actions 'RemovePublication()'\n end",
"def clear_patron_data\n if User.where(admin: [nil, false]).destroy_all\n flash[:success] = t('users.clear_patron_data_success')\n end\n redirect_to users_url\n end",
"def on_collection_deleted(event)\n return unless event.payload.key?(:collection) # legacy callback\n return if event[:collection].is_a?(ActiveFedora::Base) # handled by legacy code\n\n Hyrax.custom_queries.find_members_of(collection: event[:collection]).each do |resource|\n resource.member_of_collection_ids -= [event[:collection].id]\n Hyrax.persister.save(resource: resource)\n Hyrax.publisher\n .publish('collection.membership.updated', collection: event[:collection], user: event[:user])\n rescue StandardError\n Hyrax.logger.warn \"Failed to remove collection reference from #{work.class}:#{work.id} \" \\\n \"during cleanup for collection: #{event[:collection]}. \"\n end\n end",
"def opt_in(participant)\n opt_outs.unsubscriber(participant).destroy_all\n end",
"def no_admin_set_abilities\n cannot [:edit, :create, :delete], Hydra::Admin::Collection\n end",
"def delete_standard_roles_from_user\n standard_roles = []\n [\"staff\", \"student\", \"guest\"].each {|r| standard_roles << Role.find_or_initialize_by_name(r) } \n\n self.roles.each do |role|\n if standard_roles.include?(role)\n #delete the role\n self.roles.delete(role)\n end\n end\t\t\n end",
"def remove_collaborator\n @project = current_user.projects.find(params[:id])\n @collaborator = User.find(params[:collaborator_id])\n @project.users.delete(@collaborator)\n\n redirect_to project_path(@project), :alert => \"Supervisor is deleted successfully\"\n end",
"def revoke_role_and_cleanup\n role = Role.find_by(name: 'track_organizer', resource: self)\n\n role&.users&.each do |user|\n user.remove_role 'track_organizer', self\n end\n\n self.selected_schedule_id = nil\n save!\n\n schedules.each(&:destroy!)\n\n events.each do |event|\n event.track = nil\n event.state = 'new'\n event.save!\n end\n end",
"def delete_users_choices\n choices = get_choices\n choices.each do |choice|\n choice.delete\n end\n end",
"def fellow_cult_members\n friends = cults.map {|cult| cult.followers}.flatten.uniq\n friends.delete(self)\n friends\n end",
"def collections_to_remove=(collection_ids)\n collection_ids.reject {|id| id.blank?}.map {|id| id.strip}.each do |id|\n c = Collection.find(id) || nil\n remove_from_collection(c)\n end\n end",
"def destroy_collaborated_wikis_before_delete\n #1 fetch list of wiki_ids for that the user is a collaborator on\n wiki_ids = $redis.smembers(self.collaborated_wikis_hash_key)\n #2 iterate over those wiki ids and remove instances where that user/wiki relationship exists\n #not sure about the below\n wiki_ids.each do |wiki_id|\n $redis.srem(Wiki.wiki_collaborators_hash_key(wiki_id), self.id)\n end\n $redis.del(self.collaborated_wikis_hash_key)\n end",
"def remove_all_tenants\n @apt_tenants.clear\n end",
"def unadmin!\n metadata['admin'] = false\n save\n end",
"def delete_assigned_members\n @card.members.each{|member| @card.remove_member member}\n end",
"def destroy\n @tx_land_grants_special_collection.destroy\n respond_to do |format|\n format.html { redirect_to tx_land_grants_special_collections_url }\n format.json { head :no_content }\n end\n end",
"def uninvite\n @meal = Meal.find(params[:meal_id])\n authorize @meal, :update?\n temp_user = @meal.invited_users.find(params[:user_id])\n @meal.invited_users.delete(temp_user)\n redirect_to @meal\n end",
"def remove_competencies\r\n @communication.destroy\r\n @decision_making.destroy\r\n @problem_solving.destroy\r\n end",
"def before_destroy\n super\n self.remove_all_owners\n self.remove_all_members\n self.remove_all_account_configs\n self.delete_all_custom_services\n end",
"def remove_user!(current_user, user)\n if(!user_exists?(current_user))\n raise SecurityError.new \"No Permissions\"\n end\n\n current_user_role = participants.find_by(user_id: current_user.id)\n if super_admin == current_user || current_user_role.member_type == Course.roles[\"admin\"]\n user = participants.find_by(user_id: user.id)\n if(user != nil)\n user.destroy\n end\n #participants.find_by(user_id: user.id).destroy\n return true\n end\n\n raise SecurityError.new \"No Permissions\"\n end",
"def reset_collection\n LogMessage.collection.drop\n create_collection\n end",
"def populate_collections!\n # Only add ADDED/MODIFIED to the collectors so deleted objects will be removed\n notices.reject { |n| n.type == \"DELETED\" }.each do |notice|\n instance_variable_get(\"@#{notice.object.kind.tableize}\") << notice.object\n end\n end",
"def show\n uninvited_users\n end",
"def remove_notes_collection(remove_list)\n \n remove_list.each do |upload_id|\n upload = Upload.find(upload_id)\n if ( @collection.uploads.include?(upload) )\n @collection.uploads.delete(upload)\n end\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @user = User.find(@invitation.user_id)\n @group = Group.find(@invitation.group_id)\n\n if destroy_has_sanitized_input?\n @group.users.push(@user)\n @invitation.delete\n flash[:notice] = \"You now belong to \" + @group.name\n @group.events.each do |event|\n event.appointments.each do |appointment|\n Votation.create(user_id: @user.id, appointment_id: appointment.id, result: 50, access: false)\n end\n end\n end\n redirect_to groups_url\n end",
"def remove(type); end",
"def clear_administrator_accounts\n Administrator.destroy_all\n end",
"def destroy\n @membership_type.destroy\n @membership_types = MembershipType.all\n end",
"def supprimeParticipant(participant_nom)\n participant = self.recupNom(participant_nom)\n @participants.delete(participant)\n end",
"def destroy_as_sender\n participants = Participant.for_message(self).uniq\n participants.each do |participant| \n Event.make(:event_type_name => EvType.find(2).name, :participant => participant, :message => self)\n end if ressource.events\n MembershipMessage.delete_relations(self)\n destroy_or_tag_as_removed\n end",
"def rem_types_pgs\n \tpages = Page.where(type_id: self.id)\n\tpages.each do |p|\n\t p.fields.each do |f|\n\t \tf.destroy\n\t end\n\t p.type_id = nil\n\t p.save\n\tend\n end",
"def remove?\r\n admin? or streamer?\r\n end",
"def delete_validator\n if is_used?\n self.errors.add \"This event is used on participant records. You must remove all participant events before deleteing this event type\"\n false\n end\n end",
"def unmake_volunteer\n @user.remove_role :volunteer\n render_success_message('Removed successfully volunteer badge.')\n end",
"def destroy\n @participant_type.destroy\n respond_to do |format|\n format.html { redirect_to participant_types_url }\n end\n end",
"def destroy\n @users_collection.destroy\n respond_to do |format|\n format.html { redirect_to users_collections_url }\n format.json { head :no_content }\n end\n end",
"def delete_all\n @owner.transaction do\n self.each { |obj| obj.delete }\n end\n @members.clear\n end",
"def remove_course_forum\n @student_forums = ForumContributor.where(:user_id => self.pupil_id)\n @student_forums.each do |f|\n f.destroy\n end\n end",
"def delete_committee_ties\n users = User.all\n users.each do |user|\n next if user.committee.nil?\n\n user.update(committee: nil) unless Committee.exists?(user.committee)\n end\n\n subcomittees = Subcommittee.all\n subcomittees.each do |subcommittee|\n subcommittee.destroy unless Committee.exists?(subcommittee.committee)\n end\n end",
"def remove_all_authentications\n current_user.authentications = []\n current_user.save\n render :text => \"Your Auths Are Destroy\"\n end",
"def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n Partextra.where(participant_id: @participant.id).destroy_all\n Badge.where(participant_id: @participant.id).destroy_all\n end",
"def remove_collection_supernatant(plates, amaps: [])\n return unless plates.present?\n plates.each_with_index do |plate, idx|\n amap = amaps[idx]\n\n unless amap.present?\n amap = one_to_one_association_map(from_collection: plate)\n end\n\n rc_list = amap.map { |hash| hash[:from_loc] }\n\n show do\n title 'Remove Supernatant'\n note \"Remove and discard supernatant from plate #{plate}:\"\n table highlight_collection_rc(plate, rc_list)\n end\n end\n end",
"def wipe_all\n return unless current_user.user_role.can_delete_users\n\n user_role = UserRole.find_by(name: 'User')\n\n users = user_role.users\n users.each(&:destroy)\n flash[:notice] = 'Sytem Wiped of all normal users'\n redirect_to root_path\n end",
"def remove_posts usr\n ConversationProcessor.new(self).remove_posts usr\n end",
"def destroy\n @user_collection.destroy\n respond_to do |format|\n format.html { redirect_to user_collections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @collection\n\n @collection.destroy\n respond_to do |format|\n format.html { redirect_to admin_collections_url, notice: \"Collection '#{@collection.title}' was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def add_participants_to_global_competition\n\t\tusers = User.where({:in_grand_competition=>true})\n\t\t\n\t\tinvitation_count = 0\n\t\tusers.each do |user|\n\t\t\tCompetitionParticipant.add_participant(user.id, self.id)\n\t\t\tinvitation_count += 1\n\t\tend\n\t\tAppMailer.global_race_admin_notify(self.id, users.length, invitation_count).deliver\n\t\t\n\t\treturn \"#{self.name} created. #{invitation_count}/#{users.length} users invited.\"\n\tend",
"def addcourse\n @courses = Course.all\n @me.courses.each do |mine|\n @courses.delete(mine)\n end\n end",
"def refresh_collections(valid_collections)\n collections.delete_all\n valid_collections.each do |collection|\n collection_to_add = Collection.find_or_create_by(druid: collection)\n collections << collection_to_add unless collections.include?(collection_to_add)\n end\n end",
"def destroy\n @interview.destroy\n participants = @interview.participants\n emails = []\n participants.each do |p|\n emails += [p.email]\n ReminderMailer.cancel_email(p.email).deliver_now\n end\n respond_to do |format|\n format.html { redirect_to interviews_url, notice: 'Interview was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collection.destroy\n respond_to do |format|\n format.html { redirect_to account_collections_url }\n format.json { head :no_content }\n end\n end",
"def remove_friend\n end",
"def remove_from_allowed_list(email)\n send_contact_command email, 'RML', '2'\n end",
"def destroy\n @collection.destroy\n end",
"def remove_all\n @peer.remove_all\n# @children.each { |child| scene.unindex_prop(child) } if scene\n# @children = []\n end"
] | [
"0.65713054",
"0.6464294",
"0.63182724",
"0.6244887",
"0.62036663",
"0.61435837",
"0.60248536",
"0.60248536",
"0.59281874",
"0.58952624",
"0.5755043",
"0.5730473",
"0.5687973",
"0.5687973",
"0.5687444",
"0.5677673",
"0.55783665",
"0.55783665",
"0.55681825",
"0.55658275",
"0.5543666",
"0.5543662",
"0.5514644",
"0.55084693",
"0.55029035",
"0.54949474",
"0.5483569",
"0.5479682",
"0.54708815",
"0.5469532",
"0.5450895",
"0.5450287",
"0.5443661",
"0.5437598",
"0.5425402",
"0.54172814",
"0.54035044",
"0.5402263",
"0.5395823",
"0.53948337",
"0.5384171",
"0.538084",
"0.5379983",
"0.5378999",
"0.53780127",
"0.53777826",
"0.5377393",
"0.5374636",
"0.5374392",
"0.5368296",
"0.5348598",
"0.53467727",
"0.53441036",
"0.5341728",
"0.53411645",
"0.5327798",
"0.53223675",
"0.5318048",
"0.53155",
"0.5315075",
"0.531417",
"0.5296382",
"0.5295192",
"0.5294193",
"0.52928495",
"0.5290698",
"0.52815676",
"0.52799034",
"0.5249209",
"0.52389824",
"0.5235143",
"0.5228909",
"0.52213484",
"0.5219105",
"0.52178556",
"0.52148944",
"0.52139914",
"0.52058196",
"0.5203723",
"0.51997167",
"0.51983607",
"0.51947385",
"0.51888084",
"0.5188307",
"0.51832926",
"0.5182818",
"0.5182464",
"0.51765835",
"0.5174892",
"0.5174758",
"0.51685447",
"0.5166155",
"0.5155558",
"0.5155404",
"0.5154371",
"0.51498145",
"0.5148233",
"0.5147006",
"0.514405"
] | 0.75309914 | 1 |
GET /emergency_contacts GET /emergency_contacts.json | def index
@emergency_contacts = @center.emergency_contacts.all
@emergency_contact = @center.emergency_contacts.new
respond_to do |format|
format.html # index.html.erb
format.json { render json: @emergency_contacts }
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n json_response(@contacts, user_id: @user.id, status: :ok)\n end",
"def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end",
"def get_contacts(options = {})\n send_request(\"get\", contacts_url, body: options.to_json)\n end",
"def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end",
"def index\n @contacts = @client.contacts\n end",
"def index\n @applicant_emergency_contacts = current_applicant.applicant_emergency_contacts.all\n end",
"def index\n @contacts = Contact.all\n\n [:first_name, :last_name, :email].each do |param|\n if params[param].present?\n regexp = /\\A#{Regexp.escape(params[param].strip)}\\Z/i # ignore case\n @contacts = @contacts.where(param => regexp)\n end\n end\n\n if params[:phone].present?\n standard_phone = Contact.standardize_phone_format(params[:phone]) # standardize phone number\n @contacts = @contacts.where(phone: standard_phone)\n end\n\n if @contacts.blank?\n payload = {\n success: { full_messages: ['no record found'] }\n }\n render json: payload, status: :ok\n else\n render json: @contacts if stale? last_modified: @contacts.max(:updated_at)\n end\n end",
"def index\n @contacts = Contact.all\n render json: {status: 200, contacts: @contacts}\n end",
"def index\n @contacts = Contact.all\n render json: @contacts\n end",
"def query_contacts(options={}) path = \"/api/v2/contacts\"\n get(path, options, AvaTax::VERSION) end",
"def contacts(options = {})\n params = { :limit => 200 }.update(options)\n response = get(PATH['contacts_full'], params)\n parse_contacts response_body(response)\n end",
"def index\n @contacts = current_user.get_address_book_contacts\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contacts }\n end\n end",
"def index\n ignore = contact_emails_rejected\n @contacts = resource_owner.contacts.reject do |c|\n ignore.include?(c.emailaddress.downcase)\n end.each{ |c| authorize c }\n session[:ret_url] = contacts_path\n end",
"def contacts\n contacts = params[:contacts].map{|c| c[1]}\n if contacts\n logger.debug \">>> received #{contacts.length} contacts\"\n end\n render :text => \"ok\"\n end",
"def index\n @employee_contacts = EmployeeContact.all\n end",
"def index\n respond_with Contact.all\n end",
"def contacts(options = {})\n params = { :limit => 200 }.update(options)\n response = get(params)\n parse_contacts response_body(response)\n end",
"def contacts\n @contacts ||= Harvest::API::Contacts.new(credentials)\n end",
"def index\n @contacts = current_user.contacts.paginate(:page => params[:page], :per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contacts }\n end\n end",
"def index\n @contacts = []\n Facebase::Contact.on_each_shard{|p|\n @contacts.concat(p.limit(20).all())\n }\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contacts }\n end\n end",
"def get_contacts(user_or_identifier)\n identifier = identifier_param(user_or_identifier)\n json = parse_response(get(\"/api/#{API_VERSION}/get_contacts\",\n :apiKey => @api_key,\n :identifier => identifier))\n ContactList.new(json)\n end",
"def index\n @contacts = Mailee::Contact.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contacts }\n end\n end",
"def index\n\t\t@contacts = current_user.contacts.get_active_contacts\n\tend",
"def index\n @contacts = current_company.contacts\n respond_to do |format|\n format.xml { render :xml => @contacts }\n format.json { render :json => @contacts }\n end\n end",
"def my_contacts(opts = {})\n client.get_my_contacts(opts)\n end",
"def get_contacts\n @notification_server.get_contacts\n end",
"def index\n @contactable = find_contactable\n @contactos = @contactable.contactos\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @contactos }\n end\n end",
"def contacts\n contact_client.contacts\n end",
"def index\n @user_contacts = UserContact.all\n render :json => user_contact_data(@user_contacts)\n end",
"def index\n # @contacts = Contact.all\n end",
"def index\n contacts = Contact.order('created_at DESC')\n\n respond_to do |format|\n format.html \n format.json { render json: contacts.as_json }\n end\n end",
"def contacts\n contacts_raw.present? ? JSON.parse(contacts_raw) : {}\n end",
"def index\n\t\t@page_title = \"My Contacts\"\n\t\t@contacts = current_agendify_user.contacts\n\tend",
"def index\n @library_contacts = @library_location.library_contacts.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @library_contacts }\n end\n end",
"def index\n @contacts = current_user.contacts\n end",
"def index\n @contacts = current_user\n .contacts\n .where(active: true)\n .order(id: :desc)\n render json: @contacts\n end",
"def contacts\n Easybill::Api::Contacts\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contacts = Contact.all\n end",
"def index\n @contact = current_user.contacts.find(params[:contact_id])\n @requests = @contact.requests\n\n respond_with @requests\n end",
"def index\n @contacts = Contact.all\n\n end",
"def new\n @contact = current_user.contacts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end",
"def show\n @contact = Contact.find(params[:id])\n\n render json: @contact\n end",
"def lookup\n respond_to do |format|\n format.json { render json: Crm::ContactLookup.new(view_context) }\n end\n end",
"def index\n @form_contacts = FormContact.all\n end",
"def index\n # only show contacts for current login user\n @user = User.find_by_id(current_user.id)\n if ([email protected]?)\n @contacts = @user.contacts\n end\n end",
"def index\n @contacts = Contact.all\n\n #Fazendo chamadas para um metodo de traducao do modelo\n # render json: @contacts, methods: :birthdate_br\n render json: @contacts\n end",
"def where(options = {})\n _, _, root = @client.get(\"/contacts\", options)\n\n root[:items].map{ |item| Contact.new(item[:data]) }\n end",
"def contacts\r\n\r\n end",
"def show\n render json: @contact\n end",
"def show\n render json: @contact\n end",
"def show\n render json: @contact.address\n end",
"def index\n contacteds = @business.contacteds\n \n render json: contacteds\n end",
"def index\n @contact = Contact.all\n end",
"def get_agent_contacts(params)\n message = {\n serviceGroupID: params[:service_group_id],\n serviceID: params[:service_id],\n teamID: params[:team_name],\n agentID: params[:agent_id],\n startDate: params[:start_date],\n endDate: params[:end_date],\n contactTypes: params[:contact_type],\n useServiceTime: false\n }\n\n reply = @client.call(:get_contacts, message: message)\n data = reply.body.dig(:get_contacts_response,\n :get_contacts_result,\n :array_of_string)\n\n data = check_if_data_exists(data)\n data = map_contacts_data(data)\n delete_contact_headers(data)\n data\n end",
"def get_google_contacts\n url = \"https://www.google.com/m8/feeds/contacts/default/full?access_token=#{token}&alt=json&max-results=100\"\n response = open(url)\n json = JSON.parse(response.read)\n my_contacts = json['feed']['entry']\n\n my_contacts.each do |contact|\n name = contact['title']['$t'] || nil\n email = contact['gd$email'] ? contact['gd$email'][0]['address'] : nil\n tel = contact['gd$phoneNumber'] ? contact[\"gd$phoneNumber\"][0][\"$t\"] : nil\n if contact['link'][1]['type'] == \"image/*\"\n picture = \"#{contact['link'][1]['href']}?access_token=#{token}\"\n else\n picture = nil\n end\n contacts.first_or_create({name: name, email: email, tel: tel})\n end\n end",
"def contact(contact, options = {})\n get(\"contacts/#{contact}\", options).pop\n end",
"def index\n @contacts = @current_affiliate_group.contacts.all_open.paginate :page => params[:page], :order => 'created_at desc', :include => [:contact_issue, :issue_status]\n logger.info @contacts.inspect\n respond_to do |format|\n format.html # index.html.erb\n format.js\n format.xml { render :xml => @contacts }\n end\n end",
"def index\n @referral_contacts = @user.referralContact.page(params[:page]).per(params[:per])\n\n render json: @referral_contacts\n end",
"def index\n @contacts = current_user.contacts.all\n\n\n end",
"def get_contacts(options = {})\n request_params = {}\n\n if !options[:updated_after].nil?\n warn '[warning] :updated_after is depracated in XeroGateway#get_contacts. Use :modified_since'\n options[:modified_since] = options.delete(:updated_after)\n end\n\n request_params[:ContactID] = options[:contact_id] if options[:contact_id]\n request_params[:ContactNumber] = options[:contact_number] if options[:contact_number]\n request_params[:order] = options[:order] if options[:order]\n request_params[:ModifiedAfter] = options[:modified_since] if options[:modified_since]\n request_params[:where] = options[:where] if options[:where]\n request_params[:page] = options[:page] if options[:page]\n\n response_xml = http_get(@client, \"#{@xero_url}/Contacts\", request_params)\n\n parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/contacts'})\n end",
"def index\n @contact_infos = ContactInfo.all\n end",
"def get_contacts(options = {})\n request_params = {}\n request_params[:type] = options[:type] if options[:type]\n request_params[:sortBy] = options[:sort] if options[:sort] \n request_params[:direction] = options[:direction] if options[:direction] \n \n response_xml = http_get(\"#{@xero_url}/contacts\", request_params)\n \n parse_response(response_xml, :request_params => request_params)\n end",
"def show\n #@contact = Contact.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact }\n end\n end",
"def list params={}\n params[:fields] = params[:fields].join(',') if params[:fields]\n params[:record_type] ||= 'person'\n @nimble.get \"contacts\", params\n end",
"def index\n # todo implement search and sort and paginate\n @contacts = Legacy::LegacyContact.order(\"first_name\").paginate(:page => params[:page])\n end",
"def contacts\n\t\t@contact = Contact.first();\n\tend",
"def show\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact }\n end\n end",
"def show\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact }\n end\n end",
"def show\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact }\n end\n end",
"def index\n @emergency_calls = EmergencyCall.all\n end",
"def show\n @contact = contacts.find(params[:id])\n end",
"def _index_list\n\t\t\tper = 12\n\n\t\t\tparams[:page] ||= 1\n\t\t\tparams[:page] = params[:page].to_i\n\n\t\t\tcontacts = ContactRequest.need_contact\n\n\t\t\tcount = contacts.count\n\n\t\t\treturn render json: { status: 1 } if count == 0\n\n\t\t\trender json: {\n\t\t\t\tstatus: 0,\n\t\t\t\tresult: {\n\t\t\t\t\tlist: render_to_string(partial: 'contact_requests/index_list', locals: { contacts: contacts.page(params[:page], per) }),\n\t\t\t\t\tpagination: render_to_string(partial: 'shared/pagination', locals: { total: count, per: per, page: params[:page] })\n\t\t\t\t}\n\t\t\t}\n\t\tend",
"def parse_contacts\n case params[:importer]\n when GMAIL, YAHOO, HOTMAIL\n request.env['omnicontacts.contacts'].map { |c| [c[:email], c[:email]] }.to_json\n when LINKEDIN then fetch_linkedin_contacts\n end\n end",
"def contacts\n @contacts = Employee.by_company_id(params[:company_id]).by_search(params[:search]).by_contacts(current_user).paginate :page => params[:page]\n @active_employers = current_user.employers.active_employers.all\n end",
"def show\n @contact = Contact.find(params[:id])\n render :json => { :success => true, :message => \"Show Contacts\", :contact => @contact }\n # respond_to do |format|\n # format.html # show.html.erb\n # format.xml { render :xml => @contact }\n # end\n end",
"def index\n @contacts = @user.contacts\n .page(params[:page]).per_page(12)\n .order(\"#{sort_column} #{sort_direction}\")\n .search(params[:search])\n\n respond_to do |format|\n format.html\n format.json { render json: @contacts }\n format.js\n end\n end",
"def user_contacts(user_id, options={})\n response = connection.get do |req|\n req.url \"/user/#{user_id}/contacts\", simple_params(options)\n end\n response.body\n end",
"def index\n @contact_informations = ContactInformation.all\n end",
"def index\n @contact_informations = ContactInformation.all\n end",
"def index\n @contacts = Contact.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contacts }\n end\n end",
"def index\n params[:page] ||= 1 \n @contacts = Contact.all\n filtering_params(params).each do |key, value|\n @contacts = @contacts.public_send(key, value) if value.present?\n end\n # Order by\n #order=name:asc / order=name:desc / order=name (defaults to ascending)\n @contacts = @contacts.order(params[:order].gsub(':', ' ')) if params[:order]\n\n # if params[:relationship]\n # render json: Contact.relationship(params[:relationship])\n # else\n # render json: Contact.all\n # end\n\n # if (params[:offset] && params[:limit])\n # @contacts = @contacts.page(1).per(params[:limit]).padding(params[:offset])\n # else\n # @contacts = @contacts.page(1).per(25)\n # end\n\n # @contacts = @contacts.relationship(params[:relationship]) if params[:relationship]\n\n render json: @contacts\n\n\n end",
"def show\n render json: Group.find(params[:id]).contacts\n end",
"def create_list\n # First delete all current contacts for this user (no overlapping contacts)\n Contact.delete_all(\"user_id = #{current_user.id}\")\n \n # Parse the list (json encoded) and create individual contact entries\n if params[:contacts].nil? || params[:contacts].empty?\n return render :status => 170, :json => {:message => 'Contacts are missing.'}\n end\n contacts = ActiveSupport::JSON.decode(CGI::unescape(params[:contacts]))\n \n total_saved = 0\n contacts.each do |contact|\n # Verify this contact has all required params\n next if (!contact.key?('name') || !contact.key?('email') || !contact.key?('source'))\n\n # Create new contact entry\n Contact.create({\n :user_id => current_user.id,\n :name => contact['name'],\n :email => contact['email'],\n :source => contact['source']\n })\n\n total_saved += 1\n end\n\n render :status => 200, :json => {:message => \"Contacts saved successfully (#{total_saved} of #{contacts.size}).\"}\n end",
"def contacts(params = {})\n # contacts in this group\n @contacts = nil\n contacts!\n end",
"def contact\n response[\"contact\"]\n end",
"def show_contact(id)\n get(\"contacts/#{id}\")\n end",
"def index\n @contact_infomations = ContactInfomation.all\n end",
"def list\n contacts_index(Contact.all)\n end",
"def get_contact_emails\n if @info == nil || !(@info.key? \"contacts\")\n return Array.new\n end\n \n return @info[\"contacts\"]\n end"
] | [
"0.71869874",
"0.710475",
"0.7029353",
"0.7006708",
"0.6962597",
"0.692548",
"0.6916064",
"0.6889901",
"0.6838649",
"0.6821554",
"0.67712927",
"0.6756197",
"0.66952246",
"0.667467",
"0.664404",
"0.6627212",
"0.6594267",
"0.65733856",
"0.65723616",
"0.6526417",
"0.65031433",
"0.6500985",
"0.6487239",
"0.64808196",
"0.64782554",
"0.64774823",
"0.6473995",
"0.6465676",
"0.64622635",
"0.64605236",
"0.6450031",
"0.644455",
"0.6427",
"0.6425867",
"0.63879424",
"0.6366428",
"0.6361658",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.6359368",
"0.633551",
"0.6317846",
"0.63156503",
"0.6294447",
"0.62937325",
"0.6286767",
"0.62787265",
"0.6273076",
"0.6272871",
"0.6265449",
"0.6249648",
"0.6249648",
"0.6245734",
"0.62318075",
"0.6226082",
"0.62183225",
"0.62096864",
"0.62049246",
"0.6199955",
"0.6199616",
"0.61901706",
"0.61848056",
"0.6181958",
"0.6179075",
"0.6172666",
"0.6169622",
"0.6154229",
"0.6150483",
"0.6149677",
"0.6149677",
"0.6149677",
"0.6148087",
"0.61310124",
"0.61280364",
"0.61254525",
"0.6125026",
"0.61231446",
"0.6112953",
"0.61106235",
"0.61080533",
"0.61080533",
"0.6085377",
"0.60843116",
"0.60723245",
"0.60711503",
"0.6066586",
"0.6064013",
"0.6063491",
"0.6058104",
"0.60575175",
"0.6049455"
] | 0.7200374 | 0 |
POST /emergency_contacts POST /emergency_contacts.json | def create
@emergency_contact = @center.emergency_contacts.new(params[:emergency_contact])
respond_to do |format|
if @emergency_contact.save
format.html { redirect_to center_emergency_contacts_url, notice: 'Emergency contact was successfully created.' }
format.json { render json: @emergency_contact, status: :created, location: center_emergency_contacts_url }
format.js
else
format.html { render action: "index" }
format.json { render json: @emergency_contact.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @applicant_emergency_contact = current_applicant.applicant_emergency_contacts.build(applicant_emergency_contact_params)\n\n respond_to do |format|\n if @applicant_emergency_contact.save\n format.html { redirect_to applicant_emergency_contacts_url, notice: 'Applicant emergency contact was successfully created.' }\n format.json { render :show, status: :created, location: @applicant_emergency_contact }\n else\n format.html { render :new }\n format.json { render json: @applicant_emergency_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end",
"def index\n @emergency_contacts = @center.emergency_contacts.all\n @emergency_contact = @center.emergency_contacts.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @emergency_contacts }\n format.js\n end\n end",
"def create\n if !params.has_key?(:ur_contact) then\n head :internal_server_error\n end\n\n params[:ur_contact].delete(:id)\n newContact = current_user.ur_contacts.new(contact_params)\n\n if newContact.save then\n render json: newContact\n else\n Rails.logger.info \"Error when creating contacts #{newContact.errors.messages}\"\n head :internal_server_error\n return\n end\n end",
"def create\n @employee_contact = EmployeeContact.new(employee_contact_params)\n\n respond_to do |format|\n if @employee_contact.save\n format.html { redirect_to @employee_contact, notice: 'Employee contact was successfully created.' }\n format.json { render :show, status: :created, location: @employee_contact }\n else\n format.html { render :new }\n format.json { render json: @employee_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.create!(contact_params)\n render json: Contact.all\n end",
"def post_contact\n\t\tcontact = Contact.new\n\t\tcontact.first_name = params[:first_name]\n\t\tcontact.last_name = params[:last_name]\n\t\tcontact.phone_number = params[:phone_number]\n\t\tcontact.email = params[:email]\n\t\tcontact.save\n\t\tcurrent_agendify_user.contacts.push(contact)\n\t\tcurrent_agendify_user.save\n\t\tredirect_to root_path\n\tend",
"def create_list\n # First delete all current contacts for this user (no overlapping contacts)\n Contact.delete_all(\"user_id = #{current_user.id}\")\n \n # Parse the list (json encoded) and create individual contact entries\n if params[:contacts].nil? || params[:contacts].empty?\n return render :status => 170, :json => {:message => 'Contacts are missing.'}\n end\n contacts = ActiveSupport::JSON.decode(CGI::unescape(params[:contacts]))\n \n total_saved = 0\n contacts.each do |contact|\n # Verify this contact has all required params\n next if (!contact.key?('name') || !contact.key?('email') || !contact.key?('source'))\n\n # Create new contact entry\n Contact.create({\n :user_id => current_user.id,\n :name => contact['name'],\n :email => contact['email'],\n :source => contact['source']\n })\n\n total_saved += 1\n end\n\n render :status => 200, :json => {:message => \"Contacts saved successfully (#{total_saved} of #{contacts.size}).\"}\n end",
"def create\n contact = Contact.create(contact_params)\n\n if contact.new_record?\n render json: { errors: contact.errors.messages }, status: 422\n else\n render json: contact, status: 201\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n if @contact.save\n render json: @contact, status: :created, location: @contact\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end",
"def create\n @contact = @business.contacts.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to business_contact_path(@business, @contact), notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: business_contact_path(@business,@contact) }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = @user.contacts.build(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to root_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_contact(options = {})\n post(:contacts, contacts: [options]).pop\n end",
"def add_contacts\n \tap \"adding contacts\"\n # asking whether we are already authorized\n AddressBook.request_authorization unless AddressBook.authorized?\n\n \n if AddressBook.authorized?\n 25.times do\n person = AddressBook::Person.create(\n :first_name => Forgery::Name.first_name, \n :last_name => Forgery::Name.last_name, \n :email => [{ :value => Forgery(:internet).email_address , :label => 'Home'}], :phones => [{ :value => rand(10 ** 10).to_s, :label => 'Mobile'}])\n end\n else\n #ap \"This app is not authorized to access the address book.\"\n end\n #enVd\n end",
"def new\n\t\t\t\t# we are going to make a new contact yall\n\t\t\t\t# comes in like post\n\t\t\t\t# {'api_token': ..., 'contact': {}}\n\t\t\t\tcontact_params = params[:contact] # be sure to clean all the values\n\t\t\t\t# clean them up\n\t\t\t\tcontact_params = sanitize_obj(contact_params);\n\t\t\t\t# lets allow rails to build this for us automagically\n\t\t\t\tc = Contact.new\n\t\t\t\tc.from_json(contact_params.to_json) # generate from our cleaned params\n\t\t\t\t# should be it for that, as long as the keys match, rails should set it\n\t\t\t\t\n\t\t\t\t# now we can save the contact\n\t\t\t\tc.save\n\t\t\t\[email protected] << c\n\t\t\t\[email protected]\n\t\t\t\t\n\t\t\t\t# now let's this new contact to the client\n\t\t\t\trender json: {:status => \"success\", :contact => c}\n\t\t\tend",
"def create\n if current_user.student?\n @emergency_contact = current_user.build_emergency_contact(emergency_contact_params.merge({student_id: current_user.student.student_id}))\n elsif current_user.faculty?\n @emergency_contact = current_user.build_emergency_contact(emergency_contact_params.merge({faculty_id: current_user.faculty.faculty_id})) \n end\n authorize @emergency_contact\n\n respond_to do |format|\n if @emergency_contact.save\n format.html { redirect_to @emergency_contact, notice: 'Emergency contact was successfully created.' }\n format.json { render :show, status: :created, location: @emergency_contact }\n else\n format.html { render :new }\n format.json { render json: @emergency_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entity_contact = EntityContact.new(params[:entity_contact])\n\n respond_to do |format|\n if @entity_contact.save\n format.html { redirect_to @entity_contact, notice: 'Entity contact was successfully created.' }\n format.json { render json: @entity_contact, status: :created, location: @entity_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_contact(params={})\n @obj.post('create-contact', @auth.merge(params))\n end",
"def create\n @contact = Contact.new\n @contact.first_name=params[:first_name]\n @contact.last_name=params[:last_name]\n @contact.email=params[:email]\n @contact.org=params[:org]\n @contact.events=params[:events]\n @contact.interests=params[:interests]\n @contact.save\n\n contacts_list\n end",
"def create_contact(name, telephone, email)\n\tcontact_list = {\n\t\tname: name,\n\t\ttelephone: telephone,\n\t\temail: email\n\t}\n\tcontacts = []\n\tcontacts << contact_list\nend",
"def create_contact\n @contact = Spree::Address.new(contact_params)\n # Currently for demo, I will leave the country id to be 1, later update will be noticed!\n hard_code_contact(contact_params)\n respond_to do |format|\n if @contact.save\n @seller.spree_addresses << @contact\n format.html { redirect_to contacts_admin_seller_path, notice: \"Contacts #{@contact.firstname} #{@contact.lastname} is successfully created!\" }\n else\n flash[:error] = @contact.errors.full_messages\n format.html { render :new_contact }\n format.json { render :new_contact, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = contacts.new(params[:contact])\n\n if @contact.save\n redirect_to contacts_path, notice: '联系人创建成功'\n else\n render action: \"new\"\n end\n end",
"def create\n @contact = @resource.contacts.build(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to(@resource, :notice => 'Contact was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n \n @contact = Contact.new(params[:contact])\n \n if @contact.save\n render :json => { :success => true, :message => \"Created new contact #{@contact.id}\", :contact => @contact }\n else\n render :json => { :success => false, :message => \"Failed to create contact\"}\n end\n \n # @contact = Contact.new(params[:contact])\n # \n # respond_to do |format|\n # if @contact.save\n # format.html { redirect_to(@contact, :notice => 'Contact was successfully created.') }\n # format.xml { render :xml => @contact, :status => :created, :location => @contact }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n # end\n # end\n end",
"def post_contacts_with_http_info(contacts, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsApi.post_contacts ...'\n end\n # verify the required parameter 'contacts' is set\n if @api_client.config.client_side_validation && contacts.nil?\n fail ArgumentError, \"Missing the required parameter 'contacts' when calling ContactsApi.post_contacts\"\n end\n # resource path\n local_var_path = '/contacts'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(contacts) \n\n # return_type\n return_type = opts[:return_type] || 'Contact' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContactsApi#post_contacts\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n UserMailer.fale_conosco_enviado(@contact).deliver\n format.html { redirect_to action: \"index\", notice: 'sucess' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n if @contact.save\n fresh_when(@contact)\n render json: @contact, status: :created, location: @contact\n else\n render json: { errors: @contact.errors.messages }, status: :unprocessable_entity\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to edit_contact_path(@contact), notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n @contact.phone_number.entity=@contact\n @contact.user=current_user\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n format.js { render action: \"new\", status: :unprocessable_entity }\n end\n end\n end",
"def create\n @emergency = Emergency.new(create_emergency_params)\n if @emergency.save\n render :show, status: :created, location: @emergency\n else\n render json: { message: @emergency.errors }, status: :unprocessable_entity\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_contact = Admin::Contact.new(admin_contact_params)\n\n respond_to do |format|\n if @admin_contact.save\n format.html { redirect_to admin_contacts_path, notice: mk_notice(@admin_contact, :id, 'Contact', :create) }\n format.json { render json: @admin_contact, status: :created, location: admin_contacts_path }\n else\n format.html { render :new }\n format.json { render json: @admin_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contact }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.new(params[:cust_contact])\n\n respond_to do |format|\n if @cust_contact.save\n format.html { redirect_to @cust_contact.customer, :notice => 'Contact was successfully created.' }\n format.json { render :json => @cust_contact, :status => :created, :location => @cust_contact }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cust_contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @reminder = Reminder.new(params[:reminder])\n\n respond_to do |format|\n if @reminder.save\n # add contacts to schedule_contact table\n\t@loop_over_count = params[:contact_number_name_list].length\n\t\n \tfor @i in 0..(@loop_over_count-1)\n\t\[email protected]_contacts.create(:name => params[:contact_number_name_list][@i], :contact_no => params[:contact_number_list][@i], :status => \"Pending\")\n \tend\n format.html { redirect_to reminders_path, notice: 'Reminder was successfully created.' }\n format.json { render json: @reminder, status: :created, location: @reminder }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reminder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_contact(contact_info)\n self.refresh_access_token!\n\n contact = OpenStruct.new({\n first_name: contact_info[:first_name],\n last_name: contact_info[:last_name],\n phone: contact_info[:phone]\n })\n\n haml_template = File.read(File.join(TEMPLATES_DIR, 'contact.xml.haml'))\n request_body = Haml::Engine.new(haml_template, remove_whitespace: true).render(Object.new, {\n contact: contact,\n user: self\n })\n\n @response = @oauth_access_token.post(\n 'https://www.google.com/m8/feeds/contacts/default/full',\n {\n body: request_body,\n headers: {\n 'Content-type' => 'application/atom+xml',\n 'GData-Version' => '3.0'\n }\n }\n )\n\n @response.status == 201\n end",
"def create\n @emergency_phone = @center.emergency_phones.new(params[:emergency_phone])\n\n respond_to do |format|\n if @emergency_phone.save\n format.html { redirect_to center_emergency_phones_url, notice: 'Phone location was successfully created.' }\n format.json { render json: @emergency_phone, status: :created, location: center_emergency_phones_url }\n format.js\n else\n format.html { render action: \"index\" }\n format.json { render json: @emergency_phone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_contact = UserContact.new(user_contact_params)\n\n respond_to do |format|\n if @user_contact.save\n format.html { redirect_to @user_contact, notice: 'User contact was successfully created.' }\n format.json { render :show, status: :created, location: @user_contact }\n else\n format.html { render :new }\n format.json { render json: @user_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if (Contact.where(\"lower(email_address) = ?\", contact.email_address).count == 0) and @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :edit, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n AdminMailer.notification(@contact).deliver_now\n format.html { redirect_to after_save_path, notice: 'Gracias por comunicarte con Beigel Bienes Raices.<br>Un profesional responderá su consulta a la brevedad.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contacts = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contacts.save\n flash[:notice] = 'Mensagem enviada com sucesso.'\n format.html { redirect_to(root_path) }\n format.xml { render :xml => @contacts, :status => :created, :location => @contacts }\n else\n flash[:notice] = \"Erro ao enviar mensagem\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contacts.errors }\n end\n end\n end",
"def emergency_contact_params\n params.require(:emergency_contact).permit(:last_name, :first_name, :address, :city, :state, :zip, :home_phone, :cell_phone, :office_phone, :faculty_id, :student_id)\n end",
"def create\n @test_contact_detail = TestContactDetail.new(test_contact_detail_params)\n\n respond_to do |format|\n if @test_contact_detail.save\n format.html { redirect_to @test_contact_detail, notice: 'Test contact detail was successfully created.' }\n format.json { render :show, status: :created, location: @test_contact_detail }\n else\n format.html { render :new }\n format.json { render json: @test_contact_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contato foi criado com sucesso.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @emergency = Emergency.new(params[:emergency])\n\n # use userid from family account\n #if params[:id]\n # current_user = User.find(params[:id])\n #else\n # current_user = User.find(session[:user_id])\n #end\n #@emergency.userid = current_user.userid\n @other_user = get_other_user(@emergency.userid) # find the user for the added contact\n \n respond_to do |format|\n if @emergency.save\n flash[:notice] = 'Emergency was successfully created.'\n format.html { redirect_to(@other_user) }\n format.xml { render :xml => @emergency, :status => :created, :location => @emergency }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @emergency.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @contact = current_user.contacts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end",
"def create\n @customer = Customer.find(params[:customer_id])\n @contact = @customer.contacts.build(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to([@contact.customer, @contact], :notice => 'Contact was successfully created.') }\n format.json { render :json => @contact, :status => :created, :location => [@contact.customer, @contact] }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contacte = Contacte.new(contacte_params)\n\n respond_to do |format|\n if @contacte.save\n format.html { redirect_to @contacte, notice: 'Contactul s-a adaugat cu succes' }\n format.json { render :show, status: :created, location: @contacte }\n else\n format.html { render :new }\n format.json { render json: @contacte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact_phone = @contact.phones.new(contact_phone_params)\n\n respond_to do |format|\n if @contact_phone.save\n format.html { redirect_to contact_phone_path(@contact, @contact_phone), notice: 'Phone was successfully created.' }\n format.json { render :show, status: :created, location: contact_phone_path(@contact, @contact_phone) }\n else\n format.html { render :new }\n format.json { render json: @contact_phone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@contact = Contact.new()\n\t\[email protected] = params[:fname] \n\t\[email protected] = params[:lname]\n\t\[email protected] = params[:email]\n\t\[email protected] = params[:reason]\n\t\[email protected] = params[:message]\n\t\[email protected]\n\t\t\n\t\trespond_with(@contact)\n end",
"def create\n Rails.logger.info \"Completed in #{contact_params}\"\n @contact = Contact.new(contact_params)\n @contact.user_id = current_user.id\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Kontakten skapades, success.' }\n format.json { render action: 'show', status: :created, location: @contact }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@contact = Contact.new(contact_params)\n\t\tif @contact.save\n\t\t\tflash[:notice] = \"Contact sucessfully saved!\"\n\t\t\tredirect_to contacts_path\n\t \telse\n\t \t\tflash[:error] = \"Contact could not save!\"\n\t \t\[email protected]_phone_numbers.build unless @contact.contact_phone_numbers.present?\n\t \t\[email protected]_addresses.build unless @contact.contact_addresses.present?\n\t \trender 'new'\n\t \tend\n\tend",
"def create\n @contactperson_phone = ContactpersonPhone.new(contactperson_phone_params)\n\n respond_to do |format|\n if @contactperson_phone.save\n format.html { redirect_to @contactperson_phone, notice: 'Contactperson phone was successfully created.' }\n format.json { render :show, status: :created, location: @contactperson_phone }\n else\n format.html { render :new }\n format.json { render json: @contactperson_phone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact_infomation = ContactInfomation.new(contact_infomation_params)\n\n respond_to do |format|\n if @contact_infomation.save\n format.html { redirect_to @contact_infomation, notice: 'Contact infomation was successfully created.' }\n format.json { render :show, status: :created, location: @contact_infomation }\n else\n format.html { render :new }\n format.json { render json: @contact_infomation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n flash[:notice] = @contact.errors.empty? ? \"Your Contact has not been saved\" : \"Your Contact has not been saved because: \" + @contact.errors.full_messages.to_sentence\n end\n end\n end",
"def create\n @customer_contact = CustomerContact.new(customer_contact_params)\n\n respond_to do |format|\n if @customer_contact.save\n format.html { redirect_to @customer_contact, notice: 'Customer contact was successfully created.' }\n format.json { render :show, status: :created, location: @customer_contact }\n else\n format.html { render :new }\n format.json { render json: @customer_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n @contact.sender = current_user.pseudo\n @contact.state = \"new\"\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to session[:previous_request_url], notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n key = params[:event][:contact].delete(:key).parameterize\n @contact = @user.contacts.where(key: key).first_or_initialize\n @contact.update_attributes(data: @contact.data.merge(params[:event].delete(:contact)))\n @event = @contact.events.new\n @event.created_at = Time.zone.at(params[:event].delete(:remetric_created_at).to_i) if params[:event].has_key? :remetric_created_at\n @event.description = params[:event].delete(:description)\n @event.data = params[:event]\n @event.user = @user\n @event.contact_snapshot = @contact.data\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to contact_event_url(@contact, @event), notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: contact_event_url(@contact, @event) }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def contacts_params\n params.permit(:name, :email, :phone)\n end",
"def create\n @crm_contact = CrmContact.new(params[:crm_contact])\n\n respond_to do |format|\n if @crm_contact.save\n format.html { redirect_to @crm_contact, notice: 'Crm contact was successfully created.' }\n format.json { render json: @crm_contact, status: :created, location: @crm_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @crm_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if get_case\n @contact = @case.contacts.create(contact_params)\n path_contacts = case_contacts_path\n else\n @contact = Contact.new(contact_params)\n path_contacts = contacts_path\n end\n\n # TODO: render partials per each type\n\n @contact.user = @user\n @contact.firm = @firm\n\n if @contact.type != 'Attorney'\n @contact.attorney_type = ''\n end\n\n #@case.contacts << @contact\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to path_contacts, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, contact: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n @contact.user_id = current_user.id\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contactinfo = Contactinfo.new(params[:contactinfo])\n @contactinfo.user_id = current_user.id\n \n respond_to do |format|\n if @contactinfo.save\n format.html { redirect_to person_path(@contactinfo.people_id), :notice => 'Contactinfo was successfully created.' }\n format.json { render :json => @contactinfo, :status => :created, :location => @contactinfo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @contactinfo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n if @point_of_contact.save\n render json: @point_of_contact, status: :created, location: @point_of_contact\n else\n render json: @point_of_contact.errors, status: :unprocessable_entity\n end\n end",
"def create\n @contact = CompanyContact.new(params[:company_contact])\n if @contact.save\n respond_with @contact, status: :created, location: @contact\n else\n respond_with @contact, status: :unprocessable_entity\n end\n end",
"def contacts\n contacts = params[:contacts].map{|c| c[1]}\n if contacts\n logger.debug \">>> received #{contacts.length} contacts\"\n end\n render :text => \"ok\"\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to thank_you_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = current_user.contacts.new(name:params[:name], email:params[:email])\n @contact = current_user.contacts.new(params[:contact])\n @server_id = params[:server_id].to_i\n @contact.save\n end",
"def create\n\t\t@contact = Contact.new(contact_params)\n\n\t\trespond_to do |format|\n\t\t\tif @contact.save\n\t\t\t\tformat.html { redirect_to user_contacts_path, notice: 'Contact was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @contact }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render json: @contact.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @user_contact_num = UserContactNum.new(user_contact_num_params)\n\n respond_to do |format|\n if @user_contact_num.save\n format.html { redirect_to @user_contact_num, notice: 'User contact num was successfully created.' }\n format.json { render :show, status: :created, location: @user_contact_num }\n else\n format.html { render :new }\n format.json { render json: @user_contact_num.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to new_contact_path, notice: 'We got your info! We\\'ve sent you a copy and we\\'ll get back to you soon.' }\n format.json { render :new, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contactperson_email = ContactpersonEmail.new(contactperson_email_params)\n\n respond_to do |format|\n if @contactperson_email.save\n format.html { redirect_to @contactperson_email, notice: 'Contactperson email was successfully created.' }\n format.json { render :show, status: :created, location: @contactperson_email }\n else\n format.html { render :new }\n format.json { render json: @contactperson_email.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n ContactMailer.send_contact_form(@contact).deliver_now\n format.html { redirect_to new_contact_path, notice: 'Mensaje enviado exitosamente.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # contact_params[:phone_number] = contact_params[:phone_number].phony_formatted(:normalize => \"KE\", :format => :international).gsub(/\\D/, '')\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: { id: @contact.id.to_i, status: \"success\" } }\n else\n format.html { render :new }\n format.json { render json: { id: @contact.id.to_i, status: \"failure\" } }\n end\n end\n end",
"def create\n @contactinfo = Contactinfo.new(params[:contactinfo])\n\n respond_to do |format|\n if @contactinfo.save\n format.html { redirect_to @contactinfo, notice: 'Contactinfo was successfully created.' }\n format.json { render json: @contactinfo, status: :created, location: @contactinfo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contactinfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save \n NotifyAdminEmail.new_contact(@contact).deliver\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n flash[:danger] = \"Sorry Please Try Again!\"\n redirect_to root_path\n end\n end\n\n end",
"def create\n flash.clear\n begin\n @contact = Contact.new(params[:contact])\n @contact.update_attribute(:user_id, current_user.id)\n rescue ActiveRecord::RecordNotUnique => e\n if e.message =~ /for key 'index_emails_on_address'/\n email = e.message.scan(/Duplicate entry '(.*)' for key 'index_emails_on_address'.*/).flatten.first\n err = [\"the email address <strong>'#{email.html_safe}'</strong>\",\n \"Check the emails fields\"]\n else\n company = params[:contact][:company] || \"ERROR\"\n country = params[:contact][:country] || \"ERROR\"\n err = [\"the company <strong>\\\"#{company.html_safe}\\\"</strong> in the country: <strong>\\\"#{country.html_safe}\\\"</strong>\",\n \"Check the company, country, address and first name fields\"]\n end\n flash[:error] = <<EOL\n<h3>An error prevented the reccord from being saved (duplicate entry):</h3>\nSorry, #{err.first.html_safe} already exists in the database. Please take one of the following action:\n<ul>\n <li>#{err.last.html_safe}</li>\n <li>Do not create the contact, but find and update the already existing company using the search form on the main contact page</li>\n</ul>\nEOL\n #flash[:error] += e.message\n end\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n format.js { render template: 'contacts/ajax_new_contact_success' }\n else\n @email_error = \"error\" if @contact.errors.full_messages.map{|m| m if(m =~ /email/i)}.size > 0\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n format.js { render template: 'contacts/_form' }\n #format.js { render template: 'contacts/new' }\n end\n end\n end",
"def contact_added(freshdesk_data)\n\t response = HTTParty.post(\n\t \"#{@api_domain}contacts\", \n\t\t basic_auth: { username: @api_key, password: \"password\" },\n\t\t headers: { 'Content-Type' => 'application/json' },\n\t\t body: freshdesk_data.to_json\n\t )\n\tend",
"def create_a_new_contact_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsAndContactListsApi.create_a_new_contact ...'\n end\n # resource path\n local_var_path = '/v3/contacts'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body']) \n\n return_type = opts[:return_type] \n\n auth_names = opts[:auth_names] || []\n data, status_code, headers = @api_client.call_api(:POST, 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 => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContactsAndContactListsApi#create_a_new_contact\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @contact = Contact.new(contact_params)\n @contact.created_by = @current_user.id\n\n @contact = encrypt_contacts(@contact)\n\n respond_to do |format|\n if @contact.save\n format.html {\n flash[:notice] = \"Contact was successfully created.\"\n flash[:color] = \"valid\"\n redirect_to action: \"index\"\n }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n @contacts = Contact.where(active_status: true, del_status: false).order('first_name ASC')\n @regions = Region.where(active_status: true, del_status: false)\n respond_to do |format|\n if @contact.save\n flash.now[:notice] = \"#{@contact.get_full_name} added successfully\"\n format.js\n else\n # flash.now[:alert] = \"Error adding contact\"\n logger.info \"Error Messages :: #{@contact.errors.messages.inspect}\"\n format.js { render :new }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n if @contact.save\n respond_to do |format|\n format.html { redirect_to new_contact_path, notice: 'Thanks for contacting us, we will get back to you shortly.' }\n format.json { render :show, status: :created, location: @contact }\n end\n else\n flash[:alert] = @contact.errors.full_messages.join(\"<br/>\").html_safe\n render :new\n end\n end",
"def create\n @projectcontact = Projectcontact.new(params[:projectcontact])\n #@project = params[:project]\n #@contacts = params[:contact_ids]\n\n #@contacts.each do |c| \n # Projectcontact.create!(:contact_id=>5, :project_id=>params[:project])\n #end\n #redirect_to edit_project_path(@project)\n\n\n respond_to do |format|\n if @projectcontact.save\n format.html { redirect_to project_path(@projectcontact.project_id), notice: 'Contacttype was successfully created.' }\n format.json { render json: @projectcontact, status: :created, location: @projectcontact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @projectcontact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @emergency_contact.destroy\n respond_to do |format|\n format.html { redirect_to emergency_contacts_url, notice: 'Emergency contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def add_contact(email, kyc_data = {})\n custom_params = {\n \"email\" => email,\n \"first_name\" => kyc_data[:first_name] || 'aman',\n \"last_name\" => kyc_data[:last_name] || 'barbaria',\n \"birthdate\" => kyc_data[:birthdate] || '23/07/1991',\n \"street_address\" => kyc_data[:street_address] || 'magarpatta city',\n \"city\" => kyc_data[:city] || 'pune',\n \"state\" => kyc_data[:state] || 'maharashtra',\n \"country\" => kyc_data[:country] || 'INDIA',\n \"postal_code\" => kyc_data[:postal_code] || '411028',\n \"ethereum_address\" => kyc_data[:ethereum_address] || '0x2755a475Ff253Ae5BBE6C1c140f975e5e85534bD',\n \"document_id_number\" => kyc_data[:document_id_number] || \"#{Time.now.to_i}\",\n \"nationality\" => kyc_data[:nationality] || 'INDIAN',\n \"document_id_file_path\" => kyc_data[:document_id_file_path] || '2/i/687eb50ecbe60c37400746a59200c75b',\n \"selfie_file_path\" => kyc_data[:selfie_file_path] || '2/i/24d828f00557817e846ebed6109c0ac8',\n \"residence_proof_file_path\" => kyc_data[:residence_proof_file_path] || '3/i/d3817395b85581eab3068cb43f9c0f63',\n \"investor_proof_files_path\" => kyc_data[:investor_proof_files_path] ||\n ['3/i/d3817395b85581eab3068cb43f9c0f63', '3/i/d3817395b85581eab3068cb43f9c0f63'],\n \"user_ip_address\" => kyc_data[:user_ip_address]\n }\n endpoint = \"/api/#{@version}/kyc/add-kyc/\"\n params = request_parameters(endpoint, custom_params)\n post(params)\n end",
"def create\n @contact = Contact.new(contact_params)\n p @address = Address.create(address_params)\n @job = Job.find_by(id: job_param[:job_id])\n p @contact.address_id = @address.id\n\n respond_to do |format|\n if @contact.save\n if @job\n @job.contact_id = @contact.id\n if @job.save\n\n @contact.phones.destroy_all\n phone_count = phone_params[\"type_ids\"].count\n\n phone_count.times do |index|\n unless phone_params[\"numbers\"][index] == \"\"\n @contact.phones.create(type_id: phone_params[\"type_ids\"][index], number: phone_params[\"numbers\"][index], extension: phone_params[\"extensions\"][index])\n end\n end\n redirect_to job_path(@job), notice: 'Contact was successfully created.'\n return\n else\n render :new\n return\n end\n else\n\n @contact.phones.destroy_all\n phone_count = phone_params[\"type_ids\"].count\n\n phone_count.times do |index|\n unless phone_params[\"numbers\"][index] == \"\"\n @contact.phones.create(type_id: phone_params[\"type_ids\"][index], number: phone_params[\"numbers\"][index], extension: phone_params[\"extensions\"][index])\n end\n end\n\n redirect_to contact_path(@contact), notice: 'Contact was successfully created.'\n return\n\n end\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def applicant_emergency_contact_params\n params.require(:applicant_emergency_contact).permit(:Emergency_Contact_Name, :Emergency_Contact_Number, :Emergency_Contact_Relationship, :applicant_id)\n end",
"def create\n @other_contactinfo = OtherContactinfo.new(other_contactinfo_params)\n\n respond_to do |format|\n if @other_contactinfo.save\n format.html { redirect_to @other_contactinfo, notice: 'Other contactinfo was successfully created.' }\n format.json { render :show, status: :created, location: @other_contactinfo }\n else\n format.html { render :new }\n format.json { render json: @other_contactinfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:cros]!='y'\n #create from page query. @xieyinghua\n @contact = Contact.new(contact_params)\n else\n #create from cros post. @xieyinghua\n new_contact_params=Hash.new\n new_contact_params[:name]=params[:name]\n new_contact_params[:phone]=params[:phone]\n new_contact_params[:reason]=params[:reason]\n new_contact_params[:email]=params[:email]\n\n @contact=Contact.new(new_contact_params)\n end\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def contact_params\n params.require(:contact).permit(:name, :phone_number, :id_number, :group_id, :contact_type, :verified, :verification_code, :estate_id, :estate_number)\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_url, notice: 'Contact was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end"
] | [
"0.7238898",
"0.69134545",
"0.67750245",
"0.677401",
"0.6728599",
"0.6704094",
"0.66930544",
"0.66844046",
"0.66192204",
"0.65934294",
"0.6546587",
"0.65421885",
"0.6525396",
"0.6511407",
"0.65057737",
"0.6478198",
"0.641267",
"0.6406949",
"0.63996226",
"0.6348653",
"0.63089514",
"0.6304322",
"0.630386",
"0.6271666",
"0.6264899",
"0.62464696",
"0.6242915",
"0.62253237",
"0.6218612",
"0.6205821",
"0.6186616",
"0.6181289",
"0.6176417",
"0.6176417",
"0.6176417",
"0.6176417",
"0.6176417",
"0.6176417",
"0.6174637",
"0.61634725",
"0.6163396",
"0.6116931",
"0.6116302",
"0.6115908",
"0.60930496",
"0.6092801",
"0.6074908",
"0.6073805",
"0.6066838",
"0.60526216",
"0.60480833",
"0.6047799",
"0.6043135",
"0.60406905",
"0.60404",
"0.60400045",
"0.60340613",
"0.60293317",
"0.60293144",
"0.6028552",
"0.60216475",
"0.60146046",
"0.6009364",
"0.60092294",
"0.6000243",
"0.5997604",
"0.5995747",
"0.5993407",
"0.59906274",
"0.59864974",
"0.5985342",
"0.5983156",
"0.59813744",
"0.5977592",
"0.59748",
"0.5974667",
"0.59731525",
"0.5967229",
"0.5960669",
"0.5960348",
"0.59580207",
"0.5951604",
"0.5939769",
"0.59318966",
"0.59301233",
"0.59263134",
"0.59259313",
"0.5916993",
"0.59049964",
"0.58946633",
"0.5891113",
"0.58863604",
"0.58826655",
"0.5880799",
"0.5877462",
"0.5873532",
"0.58724624",
"0.587199",
"0.5870732",
"0.58603907"
] | 0.72008085 | 1 |
PUT /emergency_contacts/1 PUT /emergency_contacts/1.json | def update
@emergency_contact = @center.emergency_contacts.find(params[:id])
respond_to do |format|
if @emergency_contact.update_attributes(params[:emergency_contact])
format.html { redirect_to center_emergency_contacts_url, notice: 'Emergency contact was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "index" }
format.json { render json: @emergency_contact.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @emergency_contact.update(emergency_contact_params)\n format.html { redirect_to @emergency_contact, notice: 'Emergency contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @emergency_contact }\n else\n format.html { render :edit }\n format.json { render json: @emergency_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @applicant_emergency_contact.update(applicant_emergency_contact_params)\n format.html { redirect_to applicant_emergency_contacts_url, notice: 'Applicant emergency contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @applicant_emergency_contact }\n else\n format.html { render :edit }\n format.json { render json: @applicant_emergency_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @contact.update(contact_params)\n head :no_content\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n\n if @contact.update(contact_params)\n head :no_content\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end",
"def update\n @contact.update(contact_params)\n if @contact.valid?\n render json: @contact\n end\n end",
"def update\n if !params.has_key?(:ur_contact) then\n head :internal_server_error\n return\n end\n\n #really update the contacts\n contact = UrContact.find(params[:id])\n\n #can't dlete contact you don't own\n if contact.user_id != current_user.id then\n Rails.logger.error \"Attempt to update contact you don't own\"\n head :internal_server_error\n return\n end\n\n if contact.update_attributes(contact_params) then\n render json: contact\n else\n head :internal_server_error\n end\n end",
"def update\n if @contact.update(contact_params)\n fresh_when(@contact)\n render json: @contact, status: :ok, location: @contact\n else\n render json: { errors: @contact.errors.messages }, status: :unprocessable_entity\n end\n end",
"def update\n @emergency_phone = @center.emergency_phones.find(params[:id])\n\n respond_to do |format|\n if @emergency_phone.update_attributes(params[:emergency_phone])\n format.html { redirect_to center_emergency_phones_url, notice: 'emergency_phone was successfully updated.' }\n format.json { render json: @emergency_phone, location: center_emergency_phones_url }\n else\n format.html { render action: \"index\" }\n format.json { render json: @emergency_phone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n\n # respond_to do |format|\n if @contact.update_attributes(params[:contact])\n # format.html { redirect_to(@contact, :notice => 'Contact was successfully updated.') }\n # format.xml { head :ok }\n render :json => { :success => true, :message => \"Created new client #{@contact.id}\", :contact => @contact }\n else\n render :json => { :success => false, :message => \"Failed to create contact\"}\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n # end\n end",
"def update\n respond_to do |format|\n if @employee_contact.update(employee_contact_params)\n format.html { redirect_to @employee_contact, notice: 'Employee contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee_contact }\n else\n format.html { render :edit }\n format.json { render json: @employee_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # contact_params[:photo] = File.open(contact_params[:photo])\n # if contact_params[:phone_number]\n # contact_params[:phone_number] = @contact.phone_number\n # end\n if params[:photo]\n @contact.photo = File.open(params[:photo].tempfile)\n @contact.save!\n end\n if params[:contact][:estate_name] && contact_params[:estate_number]\n estate_id = Estate.find_or_create_by!(estate_name: params[:contact][:estate_name]).id\n @contact.estate_id = estate_id\n @contact.estate_number = params[:estate_number]\n @contact.save!\n end\n if @contact.update(contact_params.except(:phone_number).except(:photo))\n contact = {}\n contact[:id] = @contact.id\n contact[:name] = @contact.name\n contact[:phone_number] = @contact.phone_number\n contact[:group_id] = @contact.group_id\n contact[:contact_type] = @contact.contact_type\n contact[:member_since] = \"#{@contact.created_at.strftime(\"%d/%m/%Y\")} #{@contact.created_at.strftime(\"%I:%M%p\")}\"\n\n render json: contact\n else\n render json: { status: \"FAIL\"}\n end\n end",
"def update_contact(companyId, id, model) path = \"/api/v2/companies/#{companyId}/contacts/#{id}\"\n put(path, model, {}, AvaTax::VERSION) end",
"def update\n @contact = @business.contacts.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(contact_params || {})\n format.html { redirect_to business_contact_path(@business, @contact), notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @contact.address.update(address_params)\n render json: @contact.address\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end",
"def set_emergency_contact\n @emergency_contact = EmergencyContact.find(params[:id])\n authorize @emergency_contact\n end",
"def update_contacts(contacts)\n b = Builder::XmlMarkup.new\n request_xml = b.Contacts {\n contacts.each do | contact |\n contact.to_xml(b)\n end\n }\n\n response_xml = http_post(@client, \"#{@xero_url}/Contacts\", request_xml, {})\n\n response = parse_response(response_xml, {:request_xml => request_xml}, {:request_signature => 'POST/contacts'})\n response.contacts.each_with_index do | response_contact, index |\n contacts[index].contact_id = response_contact.contact_id if response_contact && response_contact.contact_id\n end\n response\n end",
"def update\n @contact = Contact.find(params[:id])\n @contact.person_id = nil if params[:contact][:person_name].present?\n respond_to do |format|\n if @contact.update_attributes(params[:contact].merge(:updated_by => current_user.id))\n format.html { redirect_to client_contacts_path(@firm), :notice => \"#{ Contact.model_name.human } успешно изменен.\"}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n contact = Contact.find(params[:id])\n\n if contact.user_id == current_user.id\n contact.update_attributes(params[:contact])\n render json: contact\n else\n render text: \"That's not your contact!\"\n end\n end",
"def update_contact\n @contact = Contact.find(params[:id])\n @contact.update(params[:contact])\n redirect \"/contacts/#{@contact.id}\"\nend",
"def update\n respond_to do |format|\n if @admin_contact.update(admin_contact_params)\n format.html { redirect_to admin_contacts_path, notice: mk_notice(@admin_contact, :id, 'Contact', :update) }\n format.json { render json: @admin_contact, status: :ok, location: admin_contacts_path }\n else\n format.html { render :edit }\n format.json { render json: @admin_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @emergency.update(update_emergency_params)\n render :show, status: :ok, location: @emergency\n else\n render json: { message: @emergency.errors }, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to contacts_path, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:cros]=='y'\n #update from cros post. @xieyinghua\n new_contact_params=contact_params\n new_contact_params[:name]=params[:name]\n new_contact_params[:phone]=params[:phone]\n new_contact_params[:reason]=params[:reason]\n new_contact_params[:email]=params[:email]\n\n contact_params=new_contact_params\n end\n\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @point_of_contact.update(params[:point_of_contact])\n head :no_content\n else\n render json: @point_of_contact.errors, status: :unprocessable_entity\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n if params[:contact][:clientId] == \"\"\n params[:contact][:clientId] = nil\n end \n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { render :edit, notice: 'Contact was successfully updated.' }\n format.json { render :edit, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @applicant_emergency_contact = current_applicant.applicant_emergency_contacts.build(applicant_emergency_contact_params)\n\n respond_to do |format|\n if @applicant_emergency_contact.save\n format.html { redirect_to applicant_emergency_contacts_url, notice: 'Applicant emergency contact was successfully created.' }\n format.json { render :show, status: :created, location: @applicant_emergency_contact }\n else\n format.html { render :new }\n format.json { render json: @applicant_emergency_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = current_user.contacts.find(params[:id])\n @contact.update_attributes(params[:contact])\n end",
"def update\n respond_to do |format|\n @job = Job.find_by(id: job_param[:job_id])\n if @address = Address.find_by(id: @contact.address_id)\n if @address.update(address_params)\n end\n else\n @address = Address.new(address_params)\n @address.save\n @contact.address_id = @address.id\n end\n if @contact.update(contact_params)\n @contact.phones.destroy_all\n phone_count = phone_params[\"type_ids\"].count\n\n phone_count.times do |index|\n unless phone_params[\"numbers\"][index] == \"\"\n @contact.phones.create(type_id: phone_params[\"type_ids\"][index], number: phone_params[\"numbers\"][index], extension: phone_params[\"extensions\"][index])\n end\n end\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@contact = Contact.find(params[:id])\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to(contacts_url, :notice => t('contacts.was_updated.')) }\n format.json { head :ok }\n format.js { render 'success' }\n else\n format.html { render :action => \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n format.js { render 'failure' }\n end\n end\n end",
"def set_applicant_emergency_contact\n @applicant_emergency_contact = ApplicantEmergencyContact.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to contacts_path, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = CompanyContact.find(params[:id])\n if @contact.update_attributes(params[:company_contact])\n head :no_content\n else\n respond_with @contact, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to root_path, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n params[:client][:contact_ids] ||= []\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to after_save_path, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n if @contact.update_attributes(params[:contact])\n response_message = {:message => \"Contact updated successfully.\", :contact => @contact}\n else\n response_message = {:message => \"Contact updation failed. Please try again!\"}\n end\n\n respond_to do |format|\n format.xml { render :xml => response_message }\n format.json { render :json => response_message }\n end\n end",
"def update\n @local_userid = params[:id]\n @emergency = Emergency.find(@local_userid)\n @other_user = get_other_user(@emergency.userid) # find the user for the edited contact\n\n respond_to do |format|\n if @emergency.update_attributes(params[:emergency])\n flash[:notice] = 'Emergency was successfully updated.'\n format.html { redirect_to(@other_user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @emergency.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @contactinfo = Contactinfo.find(params[:id])\n\n respond_to do |format|\n if @contactinfo.update_attributes(params[:contactinfo])\n format.html { redirect_to person_path(@contactinfo.people_id), :notice => 'Contactinfo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @contactinfo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { render action: 'edit' , notice: 'Kontakten uppdaterades!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n #raise @contact.inspect\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to(admin_contacts_url, :notice => 'Contact was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n client_id = params[:contact].delete(:client_id)\n @contact = Contact.find(params[:id])\n @contact.client = Client.find(client_id.to_i)\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.js\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.js { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def contact_updated(freshdesk_data,contact_id)\n\t\t#Rails.logger.info \"Update method id and data\"\n\t\t#Rails.logger.debug \"#{@api_domain}-#{contact_id}-#{@api_key}\"\n\t\t#Rails.logger.debug \"#{freshdesk_data.to_json}\"\n\t response = HTTParty.put(\n\t \"#{@api_domain}contacts/#{contact_id}\", \n\t\t basic_auth: { username: @api_key, password: \"password\" },\n\t\t headers: { 'Content-Type' => 'application/json' },\n\t\t body: freshdesk_data.to_json\n\t )\n\tend",
"def update\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n\n respond_to do |format|\n if @cust_contact.update_attributes(params[:cust_contact])\n format.html { redirect_to customer_path(@customer), :notice => 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cust_contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @crm_contact = CrmContact.find(params[:id])\n\n respond_to do |format|\n if @crm_contact.update_attributes(params[:crm_contact])\n format.html { redirect_to @crm_contact, notice: 'Crm contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crm_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @crm_contact_info = CrmContactInfo.find(params[:id])\n\n respond_to do |format|\n if @crm_contact_info.update_attributes(params[:crm_contact_info])\n format.html { redirect_to @crm_contact_info, notice: 'Crm contact info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crm_contact_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact_detail.update(contact_detail_params)\n @contact_details = ContactDetail.all\n @contact_detail = ContactDetail.new \n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html{redirect_to([@scenario, @contact], notice: 'Contact was successfully updated.')}\n format.json{render :show, status: :ok, location: @contact}\n else\n format.html{redirect_to :back, flash: {error: \"Error saving contact\"}}\n format.json{render json: @contact.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to contact_url @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: (contact_url @contact) }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @object.update(contact_person_params)\n format.html { redirect_to @object, notice: 'Contact person was successfully updated.' }\n format.json { render :show, status: :ok, location: @object }\n else\n format.html { render :edit }\n format.json { render json: @object.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_contact(id, params)\n put(\"contacts/#{id}\", contact: params)\n end",
"def update\n @organization_contact = OrganizationContact.find(params[:id])\n org_id = Organization.find_by_company_name(params[:organization_contact][:organization_id]).id\n respond_to do |format|\n params[:organization_contact][:organization_id] = org_id\n if @organization_contact.update_attributes(params[:organization_contact])\n format.html { redirect_to organization_contacts_path(:org_id => org_id), notice: 'Organization contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to edit_contact_path(@contact), notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def modify_contact\n\n end",
"def set_contact\n @contact = Contact.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n render json: { message: e.message}, status: :not_found\n end",
"def update\n respond_to do |format|\n if @test_contact_detail.update(test_contact_detail_params)\n format.html { redirect_to @test_contact_detail, notice: 'Test contact detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_contact_detail }\n else\n format.html { render :edit }\n format.json { render json: @test_contact_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact_request = ContactRequest.find(params[:id])\n\n respond_to do |format|\n if @contact_request.update_attributes(params[:contact_request])\n format.html { redirect_to @contact_request, notice: 'Contact request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person_contact = PersonContact.find(params[:id])\n\n respond_to do |format|\n if @person_contact.update_attributes(params[:person_contact])\n format.html { redirect_to(@person_contact, :notice => 'Person contact was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @person_contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @customer = Customer.find(params[:customer_id])\n @contact = @customer.contacts.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to([@contact.customer, @contact], :notice => t('forms.update.sucess')) }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update fields\n self.contact = @nimble.put \"contact/#{self.id}\", { fields: fields }\n return nil unless self.contact\n self\n end",
"def update\n @contactinfo = Contactinfo.find(params[:id])\n\n respond_to do |format|\n if @contactinfo.update_attributes(params[:contactinfo])\n format.html { redirect_to @contactinfo, notice: 'Contactinfo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contactinfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @reminder = Reminder.find(params[:id])\n\n $current_contact_list = params[:contact_number_list]\n $previous_contact_list = @reminder.schedule_contacts.map {|contact| contact.contact_no.to_s}\n \n @common_contacts = ($current_contact_list & $previous_contact_list)\n \n # delete contacts\n @delete_contacts = $previous_contact_list - @common_contacts\n if !@delete_contacts.blank?\n\t@delete_contacts.each do |contact|\n\t\[email protected]_contacts.delete(ScheduleContact.where(\"contact_no = ? AND reminder_id = ?\", contact, @reminder.id))\n\tend\n end\n \n # insert contacts\n @insert_contacts = $current_contact_list - @common_contacts\n if !@insert_contacts.blank?\n\t@insert_contacts.each do |contact|\n\t\t@i = params[:contact_number_list].index(contact)\n\t\[email protected]_contacts.create(:name => params[:contact_number_name_list][@i], :contact_no => contact, :status => \"Pending\")\n\tend\n end\n\n\n respond_to do |format|\n if @reminder.update_attributes(params[:reminder])\n format.html { redirect_to reminders_path, notice: 'Reminder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reminder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to thank_you_path, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_contact_in_salesforce\n \tsf = Salesforce::API.connect_to_salesforce\n \tcontact_id = self.sf_contact_id\n \tsf.update(\n \"Contact\",\n Id: \"#{contact_id}\",\n Name: \"#{self.first_name}\",\n Email: \"#{self.email}\",\n )\n end",
"def update\n @contact = Contact.find(params[:id])\n\n if @contact.update_attributes(params[:contact])\n redirect_to contacts_path, notice: '联系人更新成功'\n else\n render action: \"edit\"\n end\n end",
"def update\n respond_to do |format|\n if @user_contact_num.update(user_contact_num_params)\n format.html { redirect_to @user_contact_num, notice: 'User contact num was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_contact_num }\n else\n format.html { render :edit }\n format.json { render json: @user_contact_num.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_update(options = {})\n options[:id] ||= @phone.id\n options[:phone] ||= @attributes\n\n # options[:email][@email.id.to_s] = @attributes\n put :update,options\n end",
"def update\n @contact = Contact.find(params[:id])\n \n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to(@resource, :notice => 'Contact was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_contact.update(user_contact_params)\n format.html { redirect_to @user_contact, notice: 'User contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_contact }\n else\n format.html { render :edit }\n format.json { render json: @user_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @emergency_contact = @center.emergency_contacts.new(params[:emergency_contact])\n\n respond_to do |format|\n if @emergency_contact.save\n format.html { redirect_to center_emergency_contacts_url, notice: 'Emergency contact was successfully created.' }\n format.json { render json: @emergency_contact, status: :created, location: center_emergency_contacts_url }\n format.js\n else\n format.html { render action: \"index\" }\n format.json { render json: @emergency_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n flash[:notice] = @contact.errors.empty? ? \"Your Contact has not been updated\" : \"Your Contact has not been updated because: \" + @contact.errors.full_messages.to_sentence\n end\n end\n end",
"def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end",
"def update_contact(contact_name, project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:path]['ContactName'] = contact_name\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/contacts/[ContactName]'\n\t\targs[:query]['Action'] = 'UpdateContact'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :contact\n\t\t\targs[:body]['Contact'] = optional[:contact]\n\t\tend\n\t\tself.run(args)\n\tend",
"def update\n respond_to do |format|\n if @contact.update(contact_params)\n update_custom_field_values\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n sql = \"UPDATE contacts SET name = ?, phone_number = ?, address = ?, email = ? WHERE id = ?\"\n DB[:conn].execute(sql, name, phone_number, address, email, id)\n end",
"def update\n respond_to do |format|\n if @contact_infomation.update(contact_infomation_params)\n format.html { redirect_to @contact_infomation, notice: 'Contact infomation was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact_infomation }\n else\n format.html { render :edit }\n format.json { render json: @contact_infomation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contacts_file.update(contacts_file_params)\n format.html { redirect_to @contacts_file, notice: 'Contacts file was successfully updated.' }\n format.json { render :show, status: :ok, location: @contacts_file }\n else\n format.html { render :show }\n format.json { render json: @contacts_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @other_contactinfo.update(other_contactinfo_params)\n format.html { redirect_to @other_contactinfo, notice: 'Other contactinfo was successfully updated.' }\n format.json { render :show, status: :ok, location: @other_contactinfo }\n else\n format.html { render :edit }\n format.json { render json: @other_contactinfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @emailcontact = Emailcontact.find(params[:id])\n\n respond_to do |format|\n if @emailcontact.update_attributes(params[:emailcontact])\n format.html { redirect_to(@emailcontact, :notice => 'Emailcontact was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @emailcontact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contactperson_email.update(contactperson_email_params)\n format.html { redirect_to @contactperson_email, notice: 'Contactperson email was successfully updated.' }\n format.json { render :show, status: :ok, location: @contactperson_email }\n else\n format.html { render :edit }\n format.json { render json: @contactperson_email.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contactperson_phone.update(contactperson_phone_params)\n format.html { redirect_to @contactperson_phone, notice: 'Contactperson phone was successfully updated.' }\n format.json { render :show, status: :ok, location: @contactperson_phone }\n else\n format.html { render :edit }\n format.json { render json: @contactperson_phone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n flash.now[:notice] = 'Contact was successfully updated.' if @contact.update contact_params\n respond_with @contact, location: contacts_path\n end",
"def update\n respond_to do |format|\n if @subcontractor_contact.update(subcontractor_contact_params)\n format.html { redirect_to @subcontractor_contact, notice: 'Subcontractor contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @subcontractor_contact }\n else\n format.html { render :edit }\n format.json { render json: @subcontractor_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact_action = ContactAction.find(params[:id])\n\n respond_to do |format|\n if @contact_action.update_attributes(params[:contact_action])\n format.html { redirect_to @contact_action, notice: 'Contact action was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contactaction = Contactaction.find(params[:id])\n\n respond_to do |format|\n if @contactaction.update_attributes(params[:contactaction])\n format.html { redirect_to @contactaction, :notice => 'Contactaction was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @contactaction.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.69413257",
"0.6739482",
"0.6661685",
"0.6651498",
"0.6629754",
"0.6544506",
"0.65320355",
"0.6517999",
"0.6488193",
"0.64694434",
"0.64680797",
"0.64465714",
"0.63275117",
"0.6323684",
"0.6313558",
"0.63087916",
"0.6301961",
"0.6275024",
"0.61950135",
"0.6186241",
"0.61711264",
"0.61663663",
"0.614351",
"0.6141936",
"0.6141936",
"0.6141936",
"0.61417294",
"0.6136976",
"0.6134492",
"0.6130951",
"0.6115344",
"0.6107589",
"0.60889",
"0.60825133",
"0.6068634",
"0.6068186",
"0.60658234",
"0.6063561",
"0.6055724",
"0.6049896",
"0.6039346",
"0.60377806",
"0.603262",
"0.60316324",
"0.6028107",
"0.60137737",
"0.60127085",
"0.60127085",
"0.60127085",
"0.60127085",
"0.60127085",
"0.60127085",
"0.60127085",
"0.60127085",
"0.60127085",
"0.60119015",
"0.59986",
"0.5996549",
"0.5992652",
"0.5989954",
"0.59814805",
"0.5974969",
"0.5971889",
"0.59711736",
"0.5957873",
"0.59575135",
"0.59448737",
"0.5936788",
"0.5934625",
"0.59271556",
"0.5919159",
"0.5918308",
"0.59143525",
"0.5910652",
"0.5906725",
"0.59032315",
"0.5902574",
"0.59009105",
"0.5899956",
"0.5899337",
"0.5897554",
"0.5895225",
"0.5889007",
"0.58863634",
"0.5876514",
"0.587426",
"0.58731097",
"0.5871734",
"0.58560944",
"0.58512455",
"0.5849104",
"0.5848069",
"0.5843992",
"0.5837759",
"0.5836352",
"0.5831009",
"0.5823997",
"0.58231425",
"0.58208436",
"0.58198255"
] | 0.72265565 | 0 |
DELETE /emergency_contacts/1 DELETE /emergency_contacts/1.json | def destroy
@emergency_contact = @center.emergency_contacts.find(params[:id])
@emergency_contact.destroy
respond_to do |format|
format.html { redirect_to center_emergency_contacts_url }
format.json { head :no_content }
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @emergency_contact.destroy\n respond_to do |format|\n format.html { redirect_to emergency_contacts_url, notice: 'Emergency contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(contactname)\n\n end",
"def destroy\n @contact.destroy\n render json: {status: 204}\n end",
"def destroy\n @applicant_emergency_contact.destroy\n respond_to do |format|\n format.html { redirect_to applicant_emergency_contacts_url, notice: 'Applicant emergency contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n Conshejointable.where(:contact_id =>@contact.id).delete_all\n Description.where(:contact_id =>@contact.id).delete_all\n puts @contact.id.to_s + \": \" + @contact.name\n @contact.delete\n respond_to do |format|\n format.html { redirect_to contacts_path, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n #Contact.delete(@contact.id)\n respond_to do |format|\n format.html { redirect_to contacts_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = @business.contacts.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to business_contacts_url(@business) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to admin_contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n\n @contact.destroy\n #@contact.version\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entity_contact = EntityContact.find(params[:id])\n @entity_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to entity_contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to client_contacts_path(@firm), :notice => \"'#{ Contact.model_name.human } удален.'\" }\n format.json { head :ok }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_contact }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: t('controllers.contacts.people.destroy.success') }\n format.json { head :no_content }\n end\n end",
"def contact_delete(handle)\n query 'contact-delete', { handle: handle }\n end",
"def destroy\n @contact.destroy\n\n head :no_content\n end",
"def delete(options={})\n options.merge!({:basic_auth => Client.credentials})\n self.class.delete(\"#{Client.base_uri}/contacts/#{id}.json\", options)\n end",
"def destroy\n\n ur_contact = UrContact.find(params[:id])\n\n #you can delete contacts you don't own\n if ur_contact.user_id != current_user.id then\n Rails.logger.error \"Attempt to delete contact you don't own\"\n head :internal_server_error\n return\n end\n\n if ur_contact.destroy then\n render json: {message:'Content Deleted'}\n else\n head :internal_server_error\n end\n end",
"def destroy\n @employee_contact.destroy\n respond_to do |format|\n format.html { redirect_to employee_contacts_url, notice: 'Employee contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n render json:Contact.all\n end",
"def destroy\n @contact_request = ContactRequest.find(params[:id])\n @contact_request.destroy\n\n respond_to do |format|\n format.html { redirect_to contact_requests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @admin_contact.destroy\n respond_to do |format|\n format.html { redirect_to admin_contacts_path, notice: mk_notice(@admin_contact, :id, 'Contact', :destroy) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n head :no_content\n end",
"def destroy\n @contactinfo = Contactinfo.find(params[:id])\n @contactinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to contactinfos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crm_contact = CrmContact.find(params[:id])\n @crm_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to crm_contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = @detail.contact\n @detail.destroy\n respond_to do |format|\n format.html { redirect_to @contact, notice: 'Detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_contact(params={})\n @obj.delete('delete-contact', @auth.merge(params))\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to @contact, notice: \"contact has been deleted\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ad_contact = AdContact.find(params[:id])\n @ad_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member_contact.destroy\n respond_to do |format|\n format.html { redirect_to member_contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contactable = find_contactable\n @contactable.contactos.find(params[:id]).destroy\n respond_to do |format|\n format.html { head :ok}\n # format.html { redirect_to @contactable }\n #format.json { head :ok }\n end\n end",
"def destroy\n @emergency.destroy\n respond_to do |format|\n format.html { redirect_to emergencies_url, notice: 'Emergency was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n DNSimple::Client.delete(\"/v1/contacts/#{id}\", options)\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact_information.destroy\n respond_to do |format|\n format.html { redirect_to contact_informations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contactinfo = Contactinfo.find(params[:id])\n @people_id = @contactinfo.people_id\n @contactinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to person_path(@people_id) }\n format.json { head :ok }\n end\n end",
"def destroy\n @test_contact_detail.destroy\n respond_to do |format|\n format.html { redirect_to test_contact_details_url, notice: 'Test contact detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@phone.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_path, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @contact.destroy\n payload = {\n success: { full_messages: [\"deleted id[#{params[:id]}]\"] }\n }\n render json: payload, status: :ok\n else\n render json: { errors: @contact.errors.messages }, status: :unprocessable_entity\n end\n end",
"def destroy\n remove_contacts_dependencies\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to scenario_contacts_url(@scenario), notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to homes_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @phone = Phone.find(params[:id])\n @phone.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end",
"def delete id=nil\n id ||= self.id\n @nimble.delete \"contact/#{id}\"\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to after_destroy_path, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contactaction = Contactaction.find(params[:id])\n @contactaction.destroy\n\n respond_to do |format|\n format.html { redirect_to contactactions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n \n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact = CompanyContact.find(params[:id])\n @contact.destroy\n head :no_content\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @emailcontact = Emailcontact.find(params[:id])\n @emailcontact.destroy\n\n respond_to do |format|\n format.html { redirect_to(emailcontacts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @emergency = Emergency.find(@fire.emergency_id)\n @fire.destroy\n respond_to do |format|\n format.html { redirect_to formularios_path(@emergency), notice: 'Fire was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(contacts)\n @@contacts.delete(contact)\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test_contact_basic.destroy\n respond_to do |format|\n format.html { redirect_to test_contact_basics_url, notice: 'Test contact basic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contact_action = ContactAction.find(params[:id])\n @contact_action.destroy\n\n respond_to do |format|\n format.html { redirect_to contact_actions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crm_contact_info = CrmContactInfo.find(params[:id])\n @crm_contact_info.destroy\n @crm_contact=@crm_contact_info.crm_contact\n\n # respond_to do |format|\n # format.html { redirect_to crm_contact_infos_url }\n # format.json { head :no_content }\n # end\n end",
"def destroy\n @user_contact.destroy\n respond_to do |format|\n format.html { redirect_to user_contacts_url, notice: 'User contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @person_contact = PersonContact.find(params[:id])\n @person_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(person_contacts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @point_of_contact.destroy\n\n head :no_content\n end",
"def delete(id)\n results = connection.exec_params('DELETE FROM contacts WHERE id=$1;', [id]) \n end",
"def delete_contact(id)\n delete(\"contacts/#{id}\")\n end",
"def destroy\n @contact_type.destroy\n respond_to do |format|\n format.html { redirect_to contact_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contactperson.destroy\n respond_to do |format|\n format.html { redirect_to contactpeople_url, notice: 'Contactperson was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.7421368",
"0.73579836",
"0.7348901",
"0.72321564",
"0.721836",
"0.7125018",
"0.710601",
"0.70785946",
"0.7065338",
"0.7065338",
"0.7065338",
"0.7042987",
"0.7018197",
"0.70136285",
"0.7007058",
"0.7007058",
"0.7007058",
"0.7007058",
"0.70043147",
"0.6969277",
"0.6959026",
"0.6942138",
"0.6935796",
"0.6935404",
"0.6931281",
"0.69273674",
"0.6923147",
"0.68903786",
"0.68777394",
"0.6877183",
"0.68758595",
"0.68673575",
"0.6859645",
"0.6851025",
"0.6846711",
"0.6843357",
"0.6834155",
"0.683236",
"0.6831799",
"0.68288064",
"0.6825469",
"0.68240076",
"0.6821912",
"0.68142784",
"0.68136436",
"0.6804711",
"0.6802969",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.6800625",
"0.67807806",
"0.6777089",
"0.6776652",
"0.6762202",
"0.67590016",
"0.6754456",
"0.67489576",
"0.6747114",
"0.67163277",
"0.670574",
"0.6698916",
"0.669535",
"0.669488",
"0.6693183",
"0.6693183",
"0.6693183",
"0.6693183",
"0.66905135",
"0.6678269",
"0.66778475",
"0.667534",
"0.6671753",
"0.66670567",
"0.6664312",
"0.6660851",
"0.6650571",
"0.6638774"
] | 0.7182751 | 5 |
Return a title on a perpage basis. | def title
# Sets the browser title bar display
base_title = "Grademypitch"
if @title.nil?
base_title
else
"#{base_title} | #{@title}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title\n @title_pages.each { |tp| tp.title and return tp.title }\n nil\n end",
"def page_title\n page.title\n end",
"def pagetitle(page)\n \"Page #{page}\"\nend",
"def page_title(title)\n content_for_wrapper(:page_title, title)\n end",
"def page_title\n end",
"def title\n @title ||= begin\n if site_title && page_title != site_title\n page_title + TITLE_SEPARATOR + site_title\n elsif site_description && site_title\n site_title + TITLE_SEPARATOR + site_title_extention_or_description\n else\n page_title || site_title\n end\n end\n\n return page_number + @title if page_number\n\n @title\n end",
"def page_title\n @page_title ||= format_string(page[\"title\"]) || site_title\n end",
"def page_title(page_title = nil)\n @page_title ||= page_title\n @page_title.nil? ? \"Carers: #{action_name}\" : \"#{@page_title} @ Lort Smith\"\n end",
"def title\n return @title if @title\n if matches = class_const(:TITLE_RE).match(page)\n @title = matches[1].to_s.strip\n title_processor\n @title = decode_entities(@title)\n end\n end",
"def page_title; end",
"def page_title(page_title)\n content_for_layout :page_title, page_title\n end",
"def page_title\n title = content_for?(:title) ? \" - #{content_for(:title)}\" : \"\"\n \"Todobadour#{title}\"\n end",
"def page_title\n klass = Module.const_get(self.page.split('_').first)\n return klass.find(self.page.split('_').last.to_i).name || klass.find(self.page.split('_').last.to_i).title\n rescue NameError\n return self.page\n end",
"def title\n page.title\n end",
"def title\n @title ||= hash.fetch('title') { |key|\n raise \"Page id=#{id} is missing #{key}\"\n }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n\t content_for(:title) { page_title }\n\tend",
"def title(page_title)\n content_for :title do\n page_title\n end\n end",
"def page_title\n \t\"PatTalk\"\n end",
"def manageable_page_title(title = nil)\n @title = title unless title.nil?\n @title || \"Untitled Page\"\n end",
"def page_title() nil end",
"def page_title(title)\n content_for :page_title, title\n end",
"def page_title(title)\n \"gbchaosmaster#{\" | #{title}\" unless title.blank?}\"\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for(:title) { page_title }\n end",
"def page_title\n case\n when @post\n \"#{@post.title} - Ben Hoad\"\n when @tag\n \"Tagged with ##{@tag} - Ben Hoad\"\n else\n \"Ben Hoad\"\n end\n end",
"def title(page_title)\n \tcontent_for(:title) { page_title }\n \tend",
"def page_title title= nil\n\t\tif title\n\t\t\tcontent_for(:page_title) { \"#{title} - 2da.re\" }\n\t\t\treturn title\n\t\telse\n\t\t\tcontent_for?(:page_title) ? content_for(:page_title) : \"Ready 2da.re?\"\n\t\tend\n\tend",
"def title_with_page_title_check\n return @page.title if @page && [email protected]?\n title_without_page_title_check\n end",
"def full_title(page_title)\n page_title.blank? ? \"My Defi Pie\" : \"My Defi Pie | #{page_title}\"\n end",
"def page_title(page)\n return site_title if page.title.nil? || page.title.empty?\n\n title = t(\"titles.#{page.title}\",\n flavor: settings.site_name.capitalize,\n default: [\"docs.#{page.parent}.#{page.title}\".to_sym,\n page.title.to_s.titleize])\n\n if page.parent.nil?\n parent_title = site_title\n else\n parent_title = t(\"titles.#{page.parent}\",\n flavor: settings.site_name.capitalize,\n default: site_title)\n end\n\n \"#{title} | #{parent_title}\"\n end",
"def title(page_title)\n content_for(:title) { page_title }\n\n end",
"def page_title_raw\n \t@page_title ? \"#{@page_title}#{page_no} | \" : ''\n end",
"def get_page_title\n uri = request.request_uri\n section = uri.split(\"/\").last\n title = case section\n # these should be consistent now\n when \"questions\" then \"Key Questions\"\n when \"publications\" then \"Publication Information\"\n when \"arms\" then \"Study Arms\"\n when \"design\" then \"Study Design\"\n when \"baselines\" then \"Baseline Characteristics\"\n when \"outcomes\" then \"Outcome Setup\"\n when \"results\" then \"Results\"\n when \"adverse\" then \"Adverse Events\"\n when \"quality\" then \"Study Quality\"\n else \"\"\n end\n return title\n end",
"def page_title\n title = \"Amplify\"\n title.prepend(\"#{@page_title} | \") if @page_title\n title\n end",
"def page_title\n \n page_title = @renderer.title title()\n \n puts \"[Cutlist.page_title]: #{page_title}\" if $cutlister_debug\n \n page_title\n \n end",
"def get_display_title(title)\n page_info_get_val(title, 'displaytitle', 'displaytitle')\n end",
"def page_title\n @page_title || TaliaCore::SITE_NAME\n end",
"def page_title(options = {})\n return \"\" if @page.title.blank?\n\n options = {\n prefix: \"\",\n suffix: \"\",\n separator: \"\"\n }.update(options)\n title_parts = [options[:prefix]]\n title_parts << if response.status == 200\n @page.title\n else\n response.status\n end\n title_parts << options[:suffix]\n title_parts.reject(&:blank?).join(options[:separator]).html_safe\n end",
"def page_title\n \"#{human_readable_type} | #{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}\"\n end",
"def title(page_title)\n @title = page_title\n content_for(:title) { page_title }\n end",
"def title(page_title)\n content_for :page_title, page_title.to_s.html_safe\n end",
"def page_title\n nil\n end",
"def full_title(page_title)\n base_title = \"Proman 2014\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def full_title(page_title)\n base_title = \"Proman 2013\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def page_title\n if @title.present?\n I18n.t('page_title', :page_title => @title, :blog_title => blog_title)\n else\n I18n.t('home_title', :blog_title => blog_title)\n end\n end",
"def page_title(title = nil)\n if title\n content_for(:page_title) { title }\n else\n content_for?(:page_title) ? content_for(:page_title) : APP_CONFIG[:site_name] # or a hard-coded default\n end\n end",
"def title\n base_title = \"CloudSpokes Coding Challenges\"\n if @page_title.nil?\n base_title\n else\n \"#{base_title} - #{@page_title}\"\n end\n end",
"def name; (page.title rescue ''); end",
"def name; (page.title rescue ''); end",
"def title(page_title = nil)\n if page_title\n content_for(:title) do\n page_title\n end\n else\n content_for(:title) do\n \"DateIdeas.ca\"\n end\n end\n end",
"def page_title\n if controller_name == 'pages'\n title = t \"#{action_name}_page\"\n \"#{app_name} | #{title}\" # e.g.: 'Ror4 | Home'\n else\n if @page_title.nil?\n \"#{app_name} | #{t controller_name}-#{t action_name}\" # e.g.: 'Ror4 | groups-index'\n else\n \"#{app_name} | #{t @page_title}\" # e.g.: 'Ror4 | Show group Manager'\n end\n end\n end",
"def title\n @title ||= heirarchy.full_name\n end",
"def full_title(page_title = '')\n base_title = 'My Money'\n if page_title.empty?\n base_title\n else\n \"#{page_title} | #{base_title}\"\n end\n end",
"def base_title(page_title = '')\n base_title = \"Sergio Mironescu\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def page_title\n return \"#{this_webapp.webapp_name} - #{@page_title}\" if @page_title\n return \"#{this_webapp.webapp_name}\"\n end",
"def pagination_title(set)\n return unless set.respond_to?('total_pages')\n \"page #{set.current_page} of #{set.total_pages}\" if set.total_pages > 1\n end",
"def page_title\n self.div(:id=>\"s3d-page-container\").div(:class=>\"s3d-contentpage-title\").text\n end",
"def page_title\n self.div(:id=>\"s3d-page-container\").div(:class=>\"s3d-contentpage-title\").text\n end",
"def title(page_title)\n base_title = \"Blog Secret Santa\" \n content_for(:title) { \"#{page_title} | #{base_title}\" }\n content_for(:heading) { page_title }\n end",
"def title(page_title = '')\n\t\tbase_title = \"AB Online Shop\"\n\t\tif page_title.empty?\n\t\t\tbase_title\n\t\telse\n\t\t\tpage_title + \" | \" + base_title\n\t\tend\n\tend",
"def page_title\n title = t(\"#{controller_name}.#{action_name}.title\")\n html = <<-HTML\n <div class=\"page-header\">\n <h1>#{title}</h1>\n </div>\n HTML\n html.html_safe\n end",
"def page_title\n \"swinfo for #{item}\"\n end",
"def page_title\n @page_title = \"Nursing System\"\n end",
"def scrape_title( page )\n\t\tpage.title.split( ' - ' )[0]\n\tend",
"def full_title(page_title)\n base_title = \"Quick-Score.com\"\n if page_title.empty?\n base_title\n else\n \"#{page_title} @ #{base_title}\"\n end\n end",
"def full_title(page_title)\n base_title = \"Koprulu Sector\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def page_title(page_title, klass=nil)\n unless page_title.blank?\n content_for :page_title do\n content_tag(:h1, page_title, :id => 'page_title', :class => klass)\n end\n end\n end",
"def set_page_title\n case @title\n when 'Winter', 'Spring', 'Summer', 'Fall'\n parent_content = Content.new(@parent_path)\n @page_title = @title + ' ' + parent_content.title\n else\n @page_title = @title\n end\n end",
"def title(page_title)\n content_for(:title) do\n \"#{page_title} - #{MySettings.company_full_name}\"\n end\n end",
"def page_title \n %(<title>#{page_title_raw}My Blog</title>) # Customize this for your blog\n end",
"def page_title(title, some_user=nil, model_name=nil)\n content_for :page_title do\n @page_title = \"\"\n if some_user\n if user_signed_in? && some_user.id == current_user.id\n @page_title = \"Your \"\n else\n @page_title = \"#{some_user.full_name}'s \"\n end\n end\n\n @page_title += model_name || title\n end\n end",
"def full_title(page_title)\n title = base_title\n\n Array(page_title).each do |var|\n title << (' | ' + var) unless var.empty? \n end\n\n title\n end",
"def page_title(*args, &block)\n options = Hash === args.last ? args.last : {}\n before_filter(options) {|c| c.page_title(*args, &block) }\n end",
"def full_title(page_title)\n base_title = \"Relativies\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def page_title(text = nil, &block)\n content_for :page_title do\n if block_given?\n capture(&block)\n else\n text\n end\n end\n end",
"def full_title(page_title)\n if page_title.empty?\n @@base_title\n else\n \"#{@@base_title} | #{page_title}\"\n end\n end",
"def full_title(page_title)\n base_title = \"Anand Sampat\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def\n get_title()\n @title\n end",
"def pageTitle\n (self || Home.new).title\n end",
"def title(title = nil)\n raise TypeError, \"expecting a String or an Array\" unless [String,Array].include?(title.class) || title.nil?\n separator = \" ~ \"\n @page_title = title if title\n if @page_title\n title = @page_title.to_a.flatten\n [@page_title, site_name].flatten.reverse.join(separator)\n else\n site_name\n end\n end",
"def full_title(page_title)\n if page_title.empty?\n site_name\n else\n \"#{page_title} | Alfalfa\"\n end\n end",
"def set_page_title\n if params['listing_user_id']\n @page_title = \"My Tours\"\n else\n @page_title = \"All Tours\"\n end\n end",
"def full_title(page_title)\n\t\tif page_title.empty?\n\t\t\tbase_title\n\t\telse\n\t\t\t\"#{base_title} | #{page_title}\"\n\t\tend\n\tend",
"def get_title()\n return @title\n end",
"def full_title page_title\n base_title = \"emo-search\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} | #{page_title}\"\n end\n end",
"def title\n @title ||= Utilities.longest_common_substring_in_array(titles.values) \n @title = titles[:og_title] unless title_ok?\n @title = titles[:html_title] unless title_ok?\n @title = titles[:from_doc] unless title_ok?\n\n @title\n end",
"def page_title\n active_div.div(:class=>\"s3d-contentpage-title\").text\n end",
"def page_title\n active_div.div(:class=>\"s3d-contentpage-title\").text\n end",
"def page_title\n active_div.div(:class=>\"s3d-contentpage-title\").text\n end",
"def full_title(page_title)\n\t\tpage_title = PAGE_TITLE \n \tbase_title = BASE_TITLE\n if page_title.empty?\n base_title\n else\n \"#{page_title} | #{base_title}\"\n end\n end",
"def page_title!(title)\n @_page_title = title\n end",
"def get_title()\n @title\n end",
"def full_title(page_title)\n\t\tbase_title=\"StemLoops\"\n\t\tif page_title.empty?\n\t\t\tbase_title\n\t\telse\n\t\t\tbase_title+\" | \"+page_title\n\t\tend\n\tend",
"def title_page page, title\n raise ArgumentError, 'Argument is not an integer' unless page.is_a? Integer\n raise ArgumentError, 'Argument is cannot contain a single or double quote' if title =~ /['\"]/\n\n @command << %Q{select #{page}; set-page-title \"#{title}\";}\n end",
"def full_title(page_title)\n base_title = \"Bill Pay Center\"\n if page_title.empty?\n base_title\n else\n \"#{base_title} / #{page_title}\"\n end\n end",
"def page_title \n raw %(<title>#{page_title_raw}My USA Coin</title>)\n end",
"def get_page_title(page_doc)\n\treturn page_doc.css('title').text.strip\nend"
] | [
"0.7777971",
"0.77103335",
"0.75592935",
"0.75191945",
"0.7482916",
"0.73910475",
"0.7365925",
"0.72978526",
"0.72698855",
"0.72201085",
"0.71792275",
"0.7164163",
"0.7158475",
"0.71547365",
"0.7139089",
"0.7119529",
"0.7119529",
"0.7119529",
"0.7119529",
"0.7110865",
"0.7106971",
"0.71025765",
"0.70635784",
"0.7058548",
"0.70508784",
"0.70472664",
"0.7044615",
"0.7044615",
"0.7035415",
"0.70345724",
"0.70232195",
"0.7013986",
"0.7002958",
"0.7002274",
"0.69977206",
"0.6996267",
"0.6993615",
"0.69858575",
"0.69810677",
"0.69796884",
"0.69642466",
"0.69548726",
"0.6938231",
"0.6911313",
"0.69052255",
"0.6897438",
"0.68928546",
"0.6884405",
"0.68724483",
"0.6871273",
"0.68671185",
"0.6862968",
"0.6862968",
"0.6851536",
"0.6848954",
"0.68314946",
"0.6828603",
"0.68259865",
"0.6825081",
"0.6819862",
"0.68123055",
"0.68123055",
"0.6809733",
"0.6809074",
"0.6793717",
"0.6791936",
"0.67918396",
"0.6782964",
"0.67815953",
"0.6778217",
"0.67758745",
"0.677392",
"0.67725354",
"0.67676693",
"0.6766376",
"0.67555153",
"0.67474324",
"0.6745596",
"0.67350125",
"0.67305154",
"0.67266655",
"0.67250663",
"0.6723958",
"0.6723451",
"0.67220527",
"0.67198956",
"0.6717774",
"0.6716328",
"0.6715488",
"0.67082185",
"0.67061234",
"0.67061234",
"0.67061234",
"0.67031795",
"0.66957104",
"0.66943836",
"0.6676219",
"0.66761225",
"0.6674983",
"0.6674839",
"0.6671292"
] | 0.0 | -1 |
Letters also wrap around. For example, if the target is target = 'z' and letters = ['a', 'b'], the answer is 'a'. Examples: Input: letters = ["c", "f", "j"] target = "a" Output: "c" Input: letters = ["c", "f", "j"] target = "c" Output: "f" Input: letters = ["c", "f", "j"] target = "d" Output: "f" Input: letters = ["c", "f", "j"] target = "g" Output: "j" Input: letters = ["c", "f", "j"] target = "j" Output: "c" Input: letters = ["c", "f", "j"] target = "k" Output: "c" | def next_greatest_letter(letters, target)
letters.each do |letter|
return letter if letter > target
end
letters[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spelling_penalty\n chars.inject_with_index(0) do |penalty, char, i| \n if i < @options[:target].size\n # add to penalty the differences between ascii values in the two strongs * the multiplier\n penalty + ((@options[:target][i] - char[0]).abs * @options[:spelling_multiplier])\n else\n penalty # evolver string is longer than the target, return penalty unchanged.\n end\n end\n end",
"def optimal_words_back(current, target)\n output = []\n (1..short_word_len(current, target)+1).each do |index|\n next if current[-index] == target[-index]\n test_word = current.clone\n test_word[-index] = target[-index]\n output << test_word if legal_word?(test_word)\n end\n output\nend",
"def change_one(target)\n # change a random character to the next\n i = rand(target.size)\n \n # now randomly choose it to something else\n newc = new_char\n until newc != target[i]\n newc = new_char\n end\n \n target[i] = newc\n \n target\n end",
"def cipher(word, key) \n #create a code for each letter of the alphabet (index == code)\n up_alpha = [\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\"]\n down_alpha = [\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\"]\n word_arr = []\n word_arr = word.split(//)\n\n #shift the value of each letter in the array \n word_arr.each do |letter|\n new_arr = []\n if up_alpha.include?(letter)\n new_index = up_alpha.index(letter) + key\n #If the new index exceed 25, rollover to index 0 (for uppercase letters)\n if new_index > 25\n new_index = new_index - 26\n new_arr.push(up_alpha[new_index])\n else \n new_arr.push(up_alpha[new_index])\n end\n\n elsif down_alpha.include?(letter)\n new_index = down_alpha.index(letter) + key\n #If the new index exceed 25, rollover to index 0 (for lowercase letters)\n if new_index > 25\n new_index = new_index - 26\n new_arr.push(down_alpha[new_index])\n else \n new_arr.push(down_alpha[new_index])\n end \n else\n new_arr.push(letter)\n end\n #combine the array into a string\n print new_arr.join()\n end\n puts ''\nend",
"def longest_prefix(strings)\n loops = (strings.length) - 1\n comparison_word = strings[0]\n \n loops.times do |i|\n prefix = \"\"\n counter = 0\n \n strings[i + 1].each_char do |letter|\n if letter == comparison_word[counter]\n prefix<<(letter)\n end\n counter += 1\n end\n comparison_word = prefix\n end\n \n return comparison_word\nend",
"def make_word_candidates\n while @e <= l \n @word = str[@s..@e]#.join\n end\n end",
"def adjust_letters(letters_old)\n if letters_old.size < 7 \n letters_old + give_letters(7 - letters_old.size)\n else\n return letters_old\n end\n end",
"def nextLetters(aliasArray)\n\tvowels = 'aeiou'.split('')\n\tconsonants = 'bcdfghjklmnpqrstvwxyz'.split('')\n\n\t# use map! to loop through each character of array\n\taliasArray.map! {|char|\n\t\t\n\t\t# if vowel, provide next vowel [METHOD]\n\t\tif vowels.include? char\n\t\t\tvowels[(vowels.index(char) + 1) % 5]\n\n\t\t# if consonant, provide next consonant [CONSONANT]\n\t\telsif consonants.include? char\n\t\t\tconsonants[(consonants.index(char) + 1) % 21]\n\t\t\n\t\telse\n\t\t\t' '\n\t\tend\n\t}\t\nend",
"def test_10_replace_appropriate_placeholders_with_letter\r\n $build_word = [\"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\", \"_\"]\r\n letter = \"e\"\r\n locations = [1, 3, 6]\r\n results = add_letter(letter, locations)\r\n assert_equal([\"_\", \"e\", \"_\", \"e\", \"_\", \"_\", \"e\", \"_\"], $build_word)\r\n end",
"def elegant_convert(input, source, target)\n value = input.chars.reduce(0) do |s, c|\n source.size * s + source.index(c)\n end\n res = ''\n while value >= 0\n res = target[value % target.size] + res\n value = value < target.size ? -1 : value/target.size\n end\n res\nend",
"def next_letter(name)\r\n\t# Create master replacement list\r\n\t# We'll replace each letter with the next one in the list\r\n\t# Edge cases, upper case, etc. are handled within a single list\r\n\tswap_list = \"aeiouabcdfghjklmnpqrstvwxyzb\"\r\n\t# add upper case letters\r\n\tswap_list = swap_list + swap_list.upcase\r\n\t# divide name into array of characters\r\n\tletters = name.chars\r\n\t# swap each letter in array\r\n\tnew_letters = letters.map do |letter|\r\n\t\ti = swap_list.index(letter)\r\n\t\tif i\r\n\t\t\t# switch letter with next letter in list\r\n\t\t\tswap_list[i+1]\r\n\t\telse\r\n\t\t\t# keep as is\r\n\t\t\tletter\r\n\t\tend\r\n\tend\r\n\t# convert new array into string\r\n\tnew_name = new_letters.join\r\n\treturn new_name\r\nend",
"def typoglycemiaWord(input)\n if input.length <= 3\n input\n end\n letters = input.chars\n last = letters.pop\n first = letters.shift\n letters.shuffle!\n letters << first\n letters.rotate!(-1)\n letters << last\n letters.join\nend",
"def build_word(base_word_arry, available_letters_arry)\n if available_letters_arry.include?(base_word_arry[0])\n available_letters_arry.slice!(available_letters_arry.index(base_word_arry[0]))\n base_word_arry.slice!(0)\n if base_word_arry.length > 0 && available_letters_arry.length > 0\n build_word(base_word_arry, available_letters_arry)\n else\n return true\n end\n else\n return false\n end\nend",
"def test_shift_letters_handle_wrap_from_z\n \tassert_equal shift_letters(array_to_num(string_to_array(\"xyz\")), 3), \n \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t['a','b','c'] \n end",
"def bonus(str, target)\n chars = Hash.new(0)\n \n str.each_char do |char| \n chars[char] += 1\n end\n \n target.each_char do |char| \n chars[char] -= 1\n end\n \n chars.values.all? { |el| el == 0}\n \nend",
"def same_letter(arr)\n new_str = arr.shift\n\n loop do\n if arr[0] == new_str[-1]\n new_str << arr.shift\n else\n break\n end\n end\n new_str\nend",
"def new_letter(start_letter)\n\t \tletter= alphabet\n\t \t\n\t \twhile letter == start_letter do\n\t \t\tletter= alphabet\n\t \tend\n\t \t\n\t \treturn letter\n\tend",
"def longest_prefix(array_of_strings)\n prefix = \"\"\n\n #error checking if array is empty, return strings in common init to empty\n if array_of_strings.length == 0\n return prefix\n end\n # puts \"array of strings here #{array_of_strings}\"\n\n #find longest string\n longest_length = 0\n longest_string = \"\"\n array_of_strings.each do |string|\n if string.length > longest_length\n longest_length = string.length\n longest_string = string\n end\n end\n\n # puts \"longest string #{longest_string}\" #doggo\n #turn longest string into array\n longest_string_array = longest_string.chars\n # puts longest_string_array\n\n #start loop\n i = 0\n while i < longest_string_array.length #[d,o,g,g,o]\n longest_letter = longest_string_array[i]\n j = 0 #start another loop to access words: [\"dogs\", \"doggo\", \"dot\"]\n while j < array_of_strings.length\n #turn array of strings into array of array of chars for each word\n word = array_of_strings[j].chars #[d,o,g,s]\n puts \"Starting #{word}\"\n\n #get i th letter in word, needs to be i not j \n word_letter = word[i] \n\n #compare longest string array at index 0 to words at index 0\n puts \"Comparing #{i} #{longest_letter} : #{word_letter}\"\n if longest_letter != word_letter #d == d \n return prefix\n end\n j += 1\n end\n #finished with j loop without breaking, save prefix BEFORE moving onto next letter comparisons\n prefix = prefix + longest_string_array[i] # d\n puts \"prefix: #{prefix}\"\n\n i += 1\n end\n return prefix\nend",
"def LetterChanges(input_string, offset)\n\n\talphabet = ('a'..'z').to_a\n\tnew_word = []\n\tstring = input_string.split(\"\")\n\n\tstring.each do |letter|\n\n\t\tcurrent_letter_index = alphabet.find_index(letter)\n\t\tcounter = 0\n\n\t\twhile counter < offset\n\t\t\tif current_letter_index < (alphabet.length - 1)\n\t\t\t\tcurrent_letter_index = current_letter_index + 1\n\t\t\t\tcounter += 1 \n\t\t\telse\n\t\t\t\tcurrent_letter_index = 0\n\t\t\t\tcounter += 1\n\t\t\tend\n\t\tend\n\n\t\tnew_word << alphabet[current_letter_index]\n\n\tend\n\n\n\treturn new_word.join(\"\")\n \nend",
"def vigenere_cipher(str, k)\n alpha = (\"a\"..\"z\").to_a\n\n msg = (0...str.length).map do |i|\n old_pos = alpha.index(str[i])\n new_pos = (old_pos + k[i%k.length]) % alpha.length\n alpha[new_pos]\n end\n\n msg.join()\nend",
"def encrypt(word)\nx = 0\n\tword.length.times do\t\n\t\tif word[x] == \" \"\n\t\telsif word[x] == \"z\"\n\t\t\tword[x] = \"a\"\n\t\telse \n\t\t\tword[x] = word[x].next\n\t\tend\n\t\tx += 1\n\tend\nreturn word\nend",
"def in_same_case_as(target)\n to_case(@target, get_case(target))\n end",
"def letter_change(letter)\nvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\nconsonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z' ]\n if vowels.include?(letter) #conditional to check if the letter is in the vowels array above\n vowels.rotate[vowels.index(letter)] #within the vowels array.rotate over by one[the index of the letter in the vowels array]\n elsif consonants.include?(letter) #conditional to check if the letter is in the consonant array defined above\n consonants.rotate[consonants.index(letter)] #because this has met the above condition, we know that the char exists in the array. we are asking for the index of the letter in the consonants array and from there are rotate to the next by one. This movement is being saved into the new name_new array.\n elsif letter == \"z\" #edge case\n letter == \"b\"\n elsif letter == \"u\" #edge case\n letter == \"a\" \n elsif letter == \" \" #edge case\n letter = \" \" \n end\nend",
"def letter_changer(x)\n vowels = ['a','e','i','o','u']\n consonants = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']\n if vowels.include? x\n if x == 'u'\n x = 'a'\n else\n index_x = vowels.index(x)\n next_vowel = vowels[index_x + 1]\n end\n elsif consonants.include? x\n if x == 'z'\n x = 'b'\n else\n index_x = consonants.index(x)\n next_consonant = consonants[index_x + 1]\n end\n end\nend",
"def unordered_match (target_word, matrix, ans_arr_el, index, track, trace)\t\n\tif index == 0 \n\t\t$seed[ans_arr_el[0][0]][:num_groups][ans_arr_el[0][1]].each do |word|\n\t\t\ttemp_word = track + word \n\t\t\tif(target_word == temp_word.chars.sort.join)\t\t\t\t\n\t\t\t\ttemp_answer = trace.dup\n\t\t\t\ttemp_answer.push(word)\n\t\t\t\t$answer[:words].push(temp_answer)\t\t\t\t\n\t\t\tend\n\t\tend\n\telsif index > 0\n\t\t$seed[ans_arr_el[index][0]][:num_groups][ans_arr_el[index][1]].each do |word|\n\t\t\tc = trace.dup\n\t\t\tc.push(word)\n\t\t\tunordered_match(target_word, matrix, ans_arr_el, index - 1, track + word, c)\t\t\t\t\t\t\n\t\tend\t\t\n\tend\t\nend",
"def cipher(create_alias)\n\tcreate_alias.map! {|letter| letter.next}\n\talias_string = create_alias.join('')\n\talias_string['!'] = ' '\n\talias_string.split(' ')\nend",
"def next_letter(array)\n array.map! do |letter|\n next_character(letter)\n end\n array = array.join('')\nend",
"def encrypt_letter alphabet, cipherbet, letter\n# default for things not found in alphabet is to just return as\n encrypted_letter = letter\n # look for letter using method from above, -1 means not found\n pos = get_position_in_list alphabet, letter\n if pos == -1\n return encrypted_letter\n else\n encrypted_letter = cipherbet[pos]\n if is_lowercase(letter) == true\n encrypted_letter = encrypted_letter.downcase\n end\n return encrypted_letter\n end\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 swap_letters(word)\n\n\tword[0], word[-1] = word[-1], word[0]\n\tword\n\t\nend",
"def factor!(target, nonterm)\n rhs = @rules[target]\n seq = @rules[nonterm].to_a\n\n # Counter to make sure not to replace overlapping occurrences.\n offsetwait = 0\n\n # Pad rhs with empty strings so that we append any trailing characters when\n # we loop over subsequences.\n (seq.size - 1).times { rhs << '' }\n\n # Check each subsequence in the target rule against nonterm's RHS,\n # replacing any non-overlapping instances.\n @rules[target] = rhs.each_cons(seq.size).inject(List.new) do |l, subseq|\n if offsetwait > 0 then\n offsetwait -= 1\n next l\n end\n\n if subseq == seq then\n offsetwait = seq.size - 1\n l << nonterm\n else\n l << subseq.first.value\n end\n end\n end",
"def rot_cipher_helper(word)\n\tencrypted = []\n\talphabet = (\"a\"..\"z\").to_a\n\n\tword.chars.each do |letter|\n\t\tciphered_idx = alphabet.index(letter) + 13\n\t\tencrypted << alphabet[ciphered_idx % 26]\n\tend\n\n\toutput = encrypted.join(\"\")\n\tresult = []\n\n\toutput.chars.each do |letter|\n\t\ttrick_idx = (alphabet.index(letter) + 1) * (-1)\n\t\tresult << alphabet[trick_idx]\n\tend\n\n\tresult.join(\"\")\nend",
"def encrypt(str)\n letters = \"abcdefghijklmnopqrstuvwxyz\"\n array = str.split('')\n array.map! do |letter|\n if letter == letters[25]\n letter = letters[0]\n else\n letter.next\n end\n end\n array.join\nend",
"def find_word(letters, unused, mask, target_word, idx, adj_matrix)\n 0.upto mask.length do |letter_idx|\n if (mask[letter_idx] and\n unused[letter_idx] and\n (letters[letter_idx] == target_word[idx]))\n if idx == target_word.length - 1\n return true\n else\n unused[letter_idx] = false\n return find_word(letters, unused, adj_matrix[letter_idx],\n target_word, idx + 1, adj_matrix)\n end\n end\n end\n return false\nend",
"def vigenere_cipher(word, key_seq_arr)\n return word if key_seq_arr.empty?\n \n ciphered = \"\"\n word.chars.each_with_index do |char, i|\n # Can't modulo/divide by zero, so take first key manually\n if i == 0 || key_seq_arr.length == 1\n ciphered += cipher_char(char, key_seq_arr.first)\n else\n curr_key = i % key_seq_arr.length\n ciphered += cipher_char(char, key_seq_arr[curr_key])\n end\n end\n\n ciphered\nend",
"def cipher(sentence, shift)\n # Funtion to cipher the word given a specific shift value to change the letter\n lowercase = 'abcdefghijklmnopqrstuvwxyz'\n uppercase = lowercase.upcase\n\n ciphered_word = []\n\n sentence.each_char.with_index do |char, idx|\n\n if lowercase.include?(char)\n index = lowercase.index(char)\n ciphered_word << lowercase[(index + shift) % 26]\n elsif uppercase.include?(char)\n index = uppercase.index(char)\n ciphered_word << uppercase[(index + shift) % 26]\n else\n ciphered_word << char\n end\n end\n\n return ciphered_word.join('')\n\nend",
"def scramble(s1,s2)\n pile_of_letters = s1.chars\n target_letters = s2.chars\n target_letters.uniq.all? { |letter| pile_of_letters.count(letter) >= target_letters.count(letter) }\nend",
"def word\n @letters.join\n end",
"def play_word(word, loc_let, loc_num, direction)\n letters = []\n word = word.upcase.split(\"\")\n i = 0\n loc_down = BOARD_HASH[loc_let]\n if direction == \"across\"\n word.length.times do\n letters << play_letter(word[i], loc_down, loc_num)\n loc_num += 1\n i += 1\n end\n\n elsif direction == \"down\"\n\n word.length.times do\n letters << play_letter(word[i], loc_down, loc_num)\n loc_down += 1\n i += 1\n end\n end\n\n if letters.include?(false)\n return false\n else\n letters.delete(true)\n return letters\n end\n end",
"def consonant_changer(letter)\r\n\tif letter == \"z\"\r\n\t\tnew_letter = \"b\"\r\n\telsif letter == \" \"\r\n\t \tnew_letter = \" \"\r\n\telse\r\n\t\tconsonant_index = \"bcdfghjklmnpqrstvwxyz\".index(letter)\r\n \tnew_letter =\"bcdfghjklmnpqrstvwxyz\"[consonant_index.next]\r\n\tend\r\nend",
"def consonant_advance(letter)\r\nconsonant = \"abcdefghijklmnopqrstuvwxyz\".delete(\"aeiou\")\r\n if letter == \"z\"\r\n letter = \"b\"\r\n else\r\n letter = consonant[consonant.index(letter) +1]\r\n end \r\nend",
"def letter_changes(string)\n array = (\"a\"..\"z\").to_a\n\n result_array = string.chars.map do |char|\n case\n when char.downcase == \"x\" then char == \"x\" ? \"a\" : \"A\"\n when char.downcase == \"y\" then char == \"y\" ? \"b\" : \"B\"\n when char.downcase == \"z\" then char == \"z\" ? \"c\" : \"C\"\n when char.match(/[a-z]/) then array[array.index(char.downcase) + 3]\n when char.match(/[A-Z]/) then array[array.index(char.downcase) + 3].upcase\n else char\n end\n end\n result_array.join\nend",
"def translate_to_cipher(sentence) # Defining method as translate_to_cipher, takes argument sentence\n alphabet = ('a'..'z').to_a # Sets variable alphabet, turns range into array \n cipher = Hash[alphabet.zip(alphabet.rotate(4))] # Creates a hash in which it takes the alphabet elements as keys and sets up values as 4 letters from the key\n spaces = [\"@\", \"#\", \"$\", \"%\", \"^\", \"&\", \"*\"] # Sets an array \"spaces\" \n \n original_sentence = sentence.downcase # Sets variable original_sentece to be argument but in lower case\n encoded_sentence = [] # Creates empty array encoded_sentence\n original_sentence.each_char do |element| # Begins a loops through each element of the original_sentence array \n if cipher.include?(element) # Checks to see if each element is present\n encoded_sentence << cipher[element] # If present, pushes the key from the cipher hash \n elsif element == ' ' # Checks to see if element is ''\n encoded_sentence << spaces.sample #If present, selects one of the elements from spaces and pushses to encoded_sentence\n else \n encoded_sentence << element #Otherwise, it pushes the element into the encoded_sentence\n end\n end\n \n return encoded_sentence.join #takes encoded sentence and joins it together\nend",
"def encrypt(word)\n\nnew_word = \"\"\n# puts \"Length of word in encrypt method #{word.length}\"\n\ncount = 0 # Set counter to 0\n\n\twhile count < word.length\n\n\t\tnext_letter = word[count].next\n\n\t\t# edge case,\n\t\t# set \"z\" equal to \"a\" and not \"aa\"\n\t\tif word[count] == \"z\"\n\t\t\tnext_letter = \"a\"\n\t\tend\n\n\t\t# leave space character unchanged.\n\t\tif word[count] == \" \"\n\t\t\tnext_letter = \" \"\n\t\tend\n\n\t\t# print out next_letter character for debugging.\n\t\t# p \"next_letter = #{next_letter}\"\n\n\t\tnew_word[count] = next_letter \n\n\t\tcount += 1 # increment counter\n\tend\n\np new_word\n\nend",
"def multiply_word_with_letter_multiplier(word,letter_multiplier)\n local_array = score(word)\n local_array.map do |number|\n number * letter_multiplier\n end\n end",
"def cipher\n\tputs \"Please type in a text what you would like to encript. Please note we convert only letters, everything else remains the same.\"\n\ttext = gets.chomp \t\t\t# Remove the useless enter character from user imput.\n\tputs \"Please give me a number and we'll encript your text with the help of that number.\"\n\tchange = gets.chomp.to_i\n\tif change == 0 \t\t\t\t# When given 0, there's nothing to move.\n\t\tputs \"Nothing to do here, the text remains the same: #{text}\"\n\telse\n\t\twords = text.split(\" \") \t# Split the long text into words by the spaces into an array.\n\t\tresult = []\n\t\twords.each do |wrd| \t\t# Iterating through the array.\n\t\t\t\twrd.scan(/./) do |x| \t# Checking and changing each character within each word seperately.\n\t\t\t\t\ty = x.sum \t\t\t# y is the ASCII value of the currently checked x character.\n\t\t\t\t\tif change > 0 \t\t# The wrapping process is slightly different depending on moving forward or backward the letters in the ASCII table.\n\t\t\t\t\t\tif (64 < y && y < 91) \t# That is between A and Z.\n\t\t\t\t\t\t\tif (y+change) > 90 \t# The part above 90 needs to add after the 64 which is the lowest entry point into our examined changing array.\n\t\t\t\t\t\t\t\ty = 64 - (90-(y+change)) \t# Here we use ' - ' because the difference between 90 and y+change will be bigger than 90 resulting in a negativ number. And - plus - is positive.\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\ty += change \t\t# When the number is not needed to be wrapped at Z or z, just regularly add to it.\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telsif (96 < y && y < 123) # Same as above just with lower case letters.\n\t\t\t\t\t\t\tif (y+change) > 122\n\t\t\t\t\t\t\t\ty = 96 - (122-(y+change))\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\ty += change\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tresult.push(y.chr) \t\t\t# Push the results(the changed letters) into the result array.\n\t\t\t\t\telse\n\t\t\t\t\t\tif (64 < y && y < 91) \t\t# This one is for the negativ numbers, when user wants to move the letters backwards(downwards) on the ASCII table.\n\t\t\t\t\t\t\tif (y+change) < 65\n\t\t\t\t\t\t\t\ty = 91 - (65-(y+change)) # We need to count difference from the other end, but basically the same logic as above.\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\ty += change\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telsif (96 < y && y < 123)\n\t\t\t\t\t\t\tif (y+change) < 97\n\t\t\t\t\t\t\t\ty = 123 - (97-(y+change))\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\ty += change\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tresult.push(y.chr) \t\t\t# Here also need to push the results(the changed letters) into the result array.\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tresult.push(\" \") \t# After each word push a space into that array.\n\t\tend\n\t\tputs words.join(\" \") \t\t# puts out the original string to compare with the new one.\n\t\tputs result.join \t\t\t# Joining the array.\n\tend\nend",
"def lookup target, *arg\n\t\t\toutput = arg[0] ? arg[0] : Array.new\n\t\t\tnode = @root\n\n\t\t\t# If this is a string process each character\n\t\t\tif String(target) == target\n\t\t\t\ttarget.each_char do |char|\n\t\t\t\t\t# Follow the failures until a goto transition is found\n\t\t\t\t\t# or we return to the root node.\n\t\t\t\t\twhile(!node.goto(char) and !node.eql? @root)\n\t\t\t\t\t\tnode = node.failure\n\t\t\t\t\tend\n\n\t\t\t\t\t# If there is a goto transition follow it; otherwise, \n\t\t\t\t\t# we can assume we are at the root node.\n\t\t\t\t\tif node.goto(char)\n\t\t\t\t\t\tnode = node.goto(char)\n\n\t\t\t\t\t\tif node.output\t\t\n\t\t\t\t\t\t\tif block_given?\n\t\t\t\t\t\t\t\toutput = yield output, node.output\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\toutput = output + node.output\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse # Otherwise, target should support \"each\" method.\n\t\t\t\tfor item in target\n\t\t\t\t\t# Follow the failures until a goto transition is found\n\t\t\t\t\t# or we return to the root node.\n\t\t\t\t\twhile(!node.goto(item) and !node.eql? @root)\n\t\t\t\t\t\tnode = node.failure\n\t\t\t\t\tend\n\n\t\t\t\t\t# If there is a goto transition follow it; otherwise, \n\t\t\t\t\t# we can assume we are at the root node.\n\t\t\t\t\tif node.goto(item)\n\t\t\t\t\t\tnode = node.goto(item)\n\n\t\t\t\t\t\tif node.output\t\t\n\t\t\t\t\t\t\tif block_given?\n\t\t\t\t\t\t\t\toutput = yield output, node.output\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\toutput = output + node.output\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn output\n\t\tend",
"def alteration\n (0...length).flat_map { |i|\n LETTERS.map { |letter|\n string.dup.tap { |w| w[i] = letter }\n }\n }.uniq\n end",
"def get_word_ladder(start_word, end_word)\n # FILL ME IN\n return ['dog', 'cat']\n end",
"def alias_modifier(full_name)\n low_vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n up_vowels = [\"A\", \"E\", \"I\", \"O\", \"U\"]\n low_consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n up_consonants = [\"B\", \"C\", \"D\", \"F\", \"G\", \"H\", \"J\", \"K\", \"L\", \"M\", \"N\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"V\", \"W\", \"X\", \"Y\", \"Z\"]\n full_name = full_name.split('')\n updated_name = full_name.map do |char|\n if low_vowels.include?(char)\n low_vowels.rotate[low_vowels.index(char)]\n elsif up_vowels.include?(char)\n up_vowels.rotate[up_vowels.index(char)]\n elsif low_consonants.include?(char)\n low_consonants.rotate[low_consonants.index(char)]\n elsif up_consonants.include?(char)\n up_consonants.rotate[up_consonants.index(char)]\n else\n char\n end\n end\n updated_name.join\nend",
"def longest_prefix(strings)\n arr_length = strings.length\n word_length = strings[0].length\n \n result = \"\"\n \n word_length.times do |i|\n \n current_letter = strings[0][i]\n \n arr_length.times do |j|\n if strings[j][i] != current_letter\n return result\n end\n end\n \n result << current_letter # for future reference: push is O(1)\n end\n \n return result\nend",
"def advance_letter letter\n vowel='aeiou'\n consonant='bcdfghjklmnpqrsvwxyz'\n if vowel.include?(letter)\n if letter==vowel[-1]\n letter=vowel[0]\n else\n letter=vowel[vowel.index(letter)+1]\n end\n elsif consonant.include?(letter)\n if letter==consonant[-1]\n letter=consonant[0]\n else\n letter=consonant[consonant.index(letter)+1]\n end\n end\n letter\nend",
"def vigenere_cipher(str, arr)\n alpha = (\"a\"..\"z\").to_a\n new_str = \"\"\n str.each_char.with_index do |char, i|\n pos = alpha.index(char)\n key = arr[i % arr.length]\n new_pos = (pos + key) % alpha.length\n new_str += alpha[new_pos]\n end\n new_str\nend",
"def encrypt(input_text, offset)\n # Error messages for: empty strings & offset == 0.\n raise ArgumentError, 'String must not be empty' if input_text == ''\n raise ArgumentError, 'Offset must not be zero' if offset == 0\n\n # Makes the input text uppercase letters only.\n input_text = input_text.upcase\n\n # Will hold all letters from input_text.\n text_list = []\n\n # Defines each letter with a number using index.\n letter_index = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\n\n # The encrypted text goes here.\n encrypted_text = ''\n\n # Stopping infinite loops.\n counter = 0\n\n # Sends each character in the input text in to their own element in an array(text_list).\n while counter < input_text.length\n text_list << input_text[counter]\n counter += 1\n end\n\n # Resets the counter.\n counter = 0\n\n # Goes through each character in the list.\n while counter < text_list.size\n # Resets the new_letter.\n new_letter = ''\n\n # Goes through the alphabet for comparison reasons.\n letter_index.each { |x|\n\n # Error message for: current element in array == nil.\n raise ArgumentError, 'Element must not be nil' if text_list[counter] == nil\n\n # Checks if current element in text_list is = to currently selected letter in the alphabet.\n if text_list[counter] == x\n\n # Declares a temporary variable to hold the new offset.\n temp = letter_index.index(text_list[counter]) + offset\n\n # Makes sure that the offset for a new letter isn't a value that is bigger than the lenght of the alphabet.\n if temp > letter_index.size - 1\n temp = temp - letter_index.size\n end\n\n # Declares which new letter whom is to be added to the encrypted text.\n new_letter = letter_index[temp]\n end\n }\n\n # Makes sure to keep spaces so the text don't get messy.\n if new_letter == ''\n new_letter = text_list[counter]\n end\n\n # Adds the new letter to the end of the encrypted text.\n encrypted_text += new_letter\n\n # Increments the counter.\n counter += 1\n end\n\n # Returns the encrypted text.\n return encrypted_text\nend",
"def textEncryptor(keyword, cipherKey)\n cipherText = \"\"\n\n\n #algorithm that uses key to shift letters encrypting given word\n keyword.each_char do |letter|\n \n oldIndex = $alphabet.find_index(letter)\n newIndex = (oldIndex + cipherKey) % $alphabet.count\n cipherText += $alphabet[newIndex]\n \n end\n\n puts \"The cipher text is: #{cipherText}\"\n\n #begin deciphiring encoded text for human readable original word\n textDecryptor(cipherText, cipherKey)\n\nend",
"def game (word, length_temp, length, encryped_word, help_word)\n puts ('Мы загадали вам слово, состоящее из #{length} букв. Введите английскую букву в нижнем регистре, чтобы начать отгадывать.')\n puts (\"Подсказка: загаданное слово в переводе на русский означает #{help_word}\")\n while (length_temp != 0)\n letter = gets\n if (word.include?(letter))\n length_temp -= 1\n puts \"Поздравляем! Вы отгадали букву! Осталось еще #{length_temp} букв. Так держать!\"\n for i in 0..length-1\n if(word[i] == letter)\n encryped_word[i] = letter\n end\n end\n puts \"Вашe слово: #{encryped_word}\"\n end\n end\n if(length_temp == 0)\n puts 'Вы отгадали слово! Поздравляем!'\n end\nend",
"def letter_change(letter)\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\", \"a\"]\n\tconsonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\",\"b\"]\n\n\tif vowels.include? letter\n\t\tvowels[vowels.index(letter)+1]\n\t\telsif consonants.include? letter\n\t\t\tconsonants[consonants.index(letter)+1]\n\t\telsif letter == \" \"\n\t\t\t\" \"\n\t\telse\n\tend\nend",
"def shortest_to_char(s, c)\n shortest_distances = []\n idx_of_target_character = []\n\n s.each_char.each_with_index do |ch, idx|\n if ch == c\n idx_of_target_character << idx\n end\n end\n\n next_target_idx = 0\n\n s.each_char.each_with_index do |ch, current_idx|\n shortest_distances << (idx_of_target_character[next_target_idx] - current_idx).abs\n if ch == c && next_target_idx != idx_of_target_character.length - 1\n next_target_idx += 1\n end\n end\n\n prev_target_idx = idx_of_target_character.length - 1\n current_idx = s.length - 1\n\n while current_idx >= 0\n distance = (current_idx - idx_of_target_character[prev_target_idx]).abs\n if distance < shortest_distances[current_idx]\n shortest_distances[current_idx] = distance\n end\n\n if s[current_idx] == c && prev_target_idx != 0\n prev_target_idx -= 1\n end\n\n current_idx -= 1\n end\n\n shortest_distances\nend",
"def folding_cipher(string)\n alpha = ('a'..'z').to_a\n reverse = alpha.reverse\n\n string.split('').map do |ch|\n idx = alpha.index(ch)\n reverse[idx]\n end.join('') \nend",
"def swap_letters(word)\n SWAP_CASES.each do |c|\n return swap(word, c.length) if word.start_with?(c)\n end\n end",
"def swap_letters(word)\n word[0], word[-1] = word[-1], word[0]\n word\nend",
"def keyword_cipher(string, keyword)\n alphabet = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\", \" \"]\n key = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\", \" \"]\n cipher = { \"a\" => \" \", \"b\" => \" \", \"c\" => \" \", \"d\" => \" \", \"e\" => \" \",\n \"f\" => \" \", \"g\" => \" \", \"h\" => \" \", \"i\" => \" \", \"j\" => \" \",\n \"k\" => \" \", \"l\" => \" \", \"m\" => \" \", \"n\" => \" \", \"o\" => \" \",\n \"p\" => \" \", \"q\" => \" \", \"r\" => \" \", \"s\" => \" \", \"t\" => \" \",\n \"u\" => \" \", \"v\" => \" \", \"w\" => \" \", \"x\" => \" \", \"y\" => \" \",\n \"z\" => \" \", \" \" => \" \"}\n\n keyword.downcase.split(\"\").reverse.each do |keyword_letter|\n key.delete_if { |key_letter| key_letter == keyword_letter }.unshift(keyword_letter)\n end\n\n alphabet.each_with_index do |letter, index|\n if letter != \" \"\n cipher[letter] = key[index]\n else\n cipher[\" \"] = \" \"\n end\n end\n\n answer = string.downcase.split(\"\").map { |letter| cipher[letter] }.join(\"\")\nend",
"def vigenere_cipher(word,arr)\n\n new_arr = []\n alp = (\"a\"..\"z\").to_a\n word.split(\"\").each.with_index do |char,i|\n old_index = alp.index(char)\n new_index = (alp.index(char)+ arr[i % arr.length]) % 26\n new_arr << alp[new_index]\n end\n new_arr.join(\"\")\n\nend",
"def translate(word)\r\n vowels = \"aeio\".split('').to_a\r\n consonant = \"bcdfghjklmnpqrstuvwxyz\".split('').to_a \r\n answer = []\r\n \r\n while word.split(' ').length == 1 \r\n words = word.split('')\r\n until vowels.include?(words[0])\r\n words = words.rotate(1)\r\n end\r\n words << \"ay\"\r\n return words.join('')\r\n end # one word ^^\r\n \r\n if word.split(' ').length > 1 \r\n words = word.split(' ')\r\n end \r\n words.each do |i|\r\n if vowels.include?(i[0])\r\n i << \"ay\"\r\n answer << i\r\n #return answer\r\n end\r\n end\r\n \r\n words.each do |j|\r\n if consonant.include?(j[0])\r\n j = j.split('').rotate(1).join('') until vowels.include?(j[0])\r\n j = j + \"ay\"\r\n #return j\r\n #j << j #correct format for 1 consonant but it doesnt add to array\r\n answer << j\r\n end\r\n end\r\n \r\n return answer.join(' ')\r\n end",
"def caesar_cipher(string, shift = DateTime.now.day) # I set shift to be the current day if I do not include a parameter for it\n string.tr Alphabet.join, Alphabet.map{ |array| array.rotate shift }.join # This looks at every single character in the string and uses .map to rotate the array to bascially let it shift how ever many times within the array to assign the new character to the string variable\nend",
"def solve_cipher(input, shift)\n words = input.split(\"\")\n \n string_container = \"\" \n words.each do | letter|\n \tif letter == \" \"\n \t\tstring_container += \" \"\n\n \telse\n \tstring_container += (letter.ord + shift).chr\n\tend\n end\n\tstring_container\n\t#your code goes here\nend",
"def hangman(word, arr)\n #create variables to store incrementers and chars\n result = []\n i = 0\n #make sure we can compare whether given lower case or capitalized letters by making all cases the same\n word = word.upcase\n arr = arr.join(\"\").upcase\n \n # word = word.split(\"\") do we need to split string into array?\n # create a nested loops to iterate over the characters of the word, \n # each arr char should iterate over all word chars \n # push char back into word[i] position if it matches, \n # otherwise push \"_\"\n while i < word.length\n j = 0\n while j < arr.length\n if word[i] == arr[j]\n result.push(arr[j])\n end\n j += 1\n end\n if word[i] == \" \"\n result[i] = word[i]\n elsif result[i] != word[i]\n result[i] = \"_\"\n end\n i += 1\n end\n puts \"\\\"\" + result.join(\"\").downcase + \"\\\"\"\n end",
"def encrypt2(word)\n\tx = 0\n\twhile x < word.length\n\t\tif word[x] == \"z\"\n\t\t\tword[x] = \"c\"\n\t\t\telsif word[x] == \"y\"\n\t\t\tword[x] = \"b\"\n\t\t\telsif word[x] == \"x\"\n\t\t\tword[x] = \"a\"\t\t\n\t\t\telse\n\t\t\tword[x] = word[x].next.next.next\n\t\tend\n\t\tx = x + 1\n\tend\n\tword.reverse\nend",
"def caesar_cipher(shift, string)\n alphabet = (\"a\"..\"z\").to_a\n blank = string.each_char.map do |letter| alphabet.include?(letter) ? alphabet[(alphabet.index(letter) + shift) % alphabet.length] : letter\n end\n return blank.join #must use return not puts, otherwise tests will not pass! Also no (\" \") needed because mapping adds a \" \"\n #in between every letter and a \"nil\" + \" \" in between every word, and join deletes the spaces in between the letters\n #and deletes the nil in between words, leaving one space in between words.\nend",
"def match_letters \n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = @guess\n\t\tend\n\tend",
"def create_alias(word)\n vowels_lower = ['a','e','i','o','u']\n vowels_upper = vowels_lower.map(&:upcase)\n consonants_lower = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']\n consonants_upper = consonants_lower.map(&:upcase)\n \nupdated_vowels = word.map do |char|\n case\n when vowels_lower.include?(char)\n vowels_lower.rotate(1)[vowels_lower.index(char)]\n when vowels_upper.include?(char)\n vowels_upper.rotate(1)[vowels_upper.index(char)]\n when consonants_lower.include?(char)\n consonants_lower.rotate(1)[consonants_lower.index(char)]\n when consonants_upper.include?(char)\n consonants_upper.rotate(1)[consonants_upper.index(char)]\n else (char)\nend\nend\nend",
"def build_words(letters)\n @letters = letters\n build!\n end",
"def translate_to_cipher(sentence) #Defining the method and the input\n alphabet = ('a'..'z').to_a #creating a variable, alphabet and making it an array\n cipher = Hash[alphabet.zip(alphabet.rotate(4))] # creating variable, cipher. #zip method takes the\n # alphabet variable and generates a sequence of arrays that correspond to the .length of the arguments. \n #The #rotate method will rotate the elements of the array to create a new array. I don't exactly now what \n # they do when put together like this.\n spaces = [\"@\", \"#\", \"$\", \"%\", \"^\", \"&\", \"*\"] #creating variable, spaces, that includes an array of symbols.\n \n original_sentence = sentence.downcase #making the input lowercase\n encoded_sentence = [] #creating a new array, encoded_sentence\n original_sentence.each_char do |element| #loops through the original sentence and takes each character and impliments element\n if cipher.include?(element)\n encoded_sentence << cipher[element] # if the cipher includes the element, the loop returns the encoded_sentence including the cipher.\n elsif element == ' '\n encoded_sentence << spaces.sample # if the element is a space, the encoded_sentence includes the space.\n else \n encoded_sentence << element #otherwise the encoded sentence just includes the element.\n end\n end\n \n return encoded_sentence.join\nend",
"def second_anagram?(str, target)\n # debugger\n str.each_char do |char|\n target_idx = target.index(char) \n target[target_idx] = \"\" if target_idx != nil\n end\n\n target.length == 0\nend",
"def make_word_from_board?(letters, word, i, j)\n matched_dices = []\n unmatched_dices = []\n letter_used = letters.map {|column| column.map { false }}\n letter_used[i][j] = true\n matched_dices.push([i, j])\n word_pos = 1\n while word_pos < word.size\n letter_matched = false\n # move a step next to the current letter to check if we can form the word\n (i-1..i+1).each do |m|\n # ignore if our matching window is outside the dices\n if m == -1 || m == letters.size\n next\n end\n (j-1..j+1).each do |n|\n # ignore if our matching window is outside the dices\n if n == -1 || n == letters[0].size\n next\n end\n # ignore for the central dice\n if m == i && n == j\n next\n end\n # ignore if letter at the position has already been used\n if letter_used[m][n]\n next\n end\n # skip if the dice is already unmatched\n if unmatched_dices.find{|dice| dice[0] == m && dice[1] == n}\n next\n end\n if letters[m][n] == word[word_pos]\n i = m\n j = n\n letter_matched = true\n letter_used[i][j] = true\n matched_dices.push([i, j])\n break\n end\n end\n if letter_matched\n word_pos += 1\n break\n end\n end\n unless letter_matched\n # return false when only a single letter is matching\n if word_pos == 1\n return false\n end\n word_pos -= 1\n # get the last matched dice\n i, j = matched_dices.pop\n letter_used[i][j] = false\n unmatched_dices.push([i, j])\n end\n end\n true\n end",
"def key(word)\n word.upcase_letters.sort.join\n end",
"def caesar_cipher(phrase, shift)\n shifted_array = phrase.chars.map {|char| shift_letter(char, shift)}\n new_phrase = shifted_array.join\nend",
"def cipher(range,name,num,x)\n\n\tres = x.ord + num\t\t\t\t\t\t\t#.ord of the future character\n\tope = range.last.ord - range.first.ord + 1\t\t#the operation to do for drive the new character into the range\n\t\tif res < range.first.ord\t\t\t\t\t\n\t\t\t(ope + res).chr\n\t\telsif res > range.last.ord\n\t\t\t(- ope + res).chr\n\t\telse\n\t\t\tres.chr\t\t\t\t\t\t\t\t\t#the return of the function is the new character\t\t\n\t\tend\t\t\n\nend",
"def vigenere_cipher(str, arr)\n alpha = ('a'..'z').to_a\n new_msg = ''\n\n str.each_char.with_index do |char,idx|\n old_pos = alpha.index(char)\n new_pos = old_pos + arr[idx % arr.length]\n new_msg += alpha[new_pos % 26]\n end\n new_msg\nend",
"def encrypt(word)\n\ti = 0\n\twhile i < word.length\n\t\tif word[i] == \"z\"\n\t\t\tword[i] = \"a\"\n\t\telse\n\t\t\tword[i] = word[i].next!\n\t\tend\n\t\t\ti += 1\n\tend\n\tword\n\t#this method works best by not using puts and letting 'word' be returned implicitly or by using p.\nend",
"def draw_letters\n # Letters A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\n letter_dist = [9, 2, 2, 4, 12, 2, 3, 2, 9, 1, 1, 4, 2, 6, 8, 2, 1, 6, 4, 6, 4, 2, 2, 1, 2, 1]\n hand_size = 10\n # ASCII table number for a\n letter_a_offset = 65\n \n letter_pool = letter_dist.map.with_index { |dist, index| (index + letter_a_offset).chr * dist }\n return letter_pool.join('').split('').sample(hand_size)\nend",
"def cipher(string, offset)\n\t#Splits the inputted string into an array of characters\n\tinput = string.split('') \n\t\n\t#This will store our output string\n\toutput = ''\n\t\n\t#First we define an array of letters to generate our hashes from\n\tletters = ('a'..'z').to_a \n\t\n\t#Generate the hash mapping numbers to letters\n\tnumToLetter = Hash.new()\n\tkey = 0\n\n\tloop do\n\t\tvalue = letters[key]\n\t\tnumToLetter[key] = value\n\t\tkey += 1\n\t\tbreak if key == 26\n\tend\n\t\n\t#BEGIN LOOP OF STRING\n\tposInString = 0 #i is a position tracker in the string\n\tloop do\n\t\tmakeUppercase = false #flag tracking case of letter\n\n\t\t#1) Determine if we are dealing with letter or punctuation\n\t\tif numToLetter.has_value?(input[posInString].downcase)\n\t\t\t#2) Determine case before we scramble the number.\n\t\t\tif !(numToLetter.has_value?(input[posInString]))\n\t\t\t\tmakeUppercase = true\n\t\t\tend\n\n\t\t\t#3) Determine the offsetted letter\n\t\t\thashKey = numToLetter.key(input[posInString].downcase)\n\t\t\tif (hashKey + offset) > 25\n\t\t\t\toffsetKey = (offset + hashKey) - 26\n\t\t\telsif (hashKey + offset) < 0\n\t\t\t\toffsetKey = 26 - (hashKey + offset)\n\t\t\telse\n\t\t\t\toffsetKey = hashKey + offset\n\t\t\tend\n\t\t\t\n\t\t\t#4)Set the value in the output!\n\t\t\tif makeUppercase\n\t\t\t\toutput[posInString] = numToLetter[offsetKey].upcase\n\t\t\telse\n\t\t\t\toutput[posInString] = numToLetter[offsetKey]\n\t\t\tend\n\n\t\telse #5) It wasn't a letter (aka inside our hash), just map the punctuation\n\t\t\toutput[posInString] = input[posInString]\n\t\tend\n\n\t\tposInString += 1\n\t\tbreak if posInString > (input.size - 1)\n\tend #END LOOP OF STRING\n\n\tputs \"You ciphered \\'\"+string+\"\\' into \\'\"+output+\"\\'\" \nend",
"def vogal(str)\n vogals = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n cons = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n# splitting the string given into arrays \n str = str.chars\n str_new = str.map do |char|\n#looping the string into the next letter\n if vogals.include?(char)\n vogals.rotate(1)[vogals.index(char)]\n else cons.include?(char)\n cons.rotate(1)[cons.index(char)]\n end\n end\n#joining the strings back\n str_new.join\nend",
"def ceasar_cipher(input, shifter)\n\n alphabet = Array('a'..'z')\n lower_case = Hash[alphabet.zip(alphabet.rotate(shifter))]\n\n alphabet = Array('A'..'Z')\n upper_case = Hash[alphabet.zip(alphabet.rotate(shifter))]\n\n cipher = lower_case.merge(upper_case)\n\n input.chars.map{ |c| cipher.fetch(c , c)}.join\n \nend",
"def solve(words, letters)\n hash = Hash.new(0)\n hash2 = Hash.new(0)\n letters.each_char do |char|\n hash[char] += 1\n end\n \n longest = 0\n \n words.each_with_index do |word, idx|\n word.each_char.with_index do |char, idx|\n if !hash[char] || hash[char] <= 0\n next\n end\n if hash[char] > 0\n hash[char] -= 1\n end\n end\n \n end\n return longest\nend",
"def folding_cipher(string)\n alpha = ('a'..'z').to_a\n new_str = ''\n (0...string.length).each do |char_i|\n char_index = alpha.index(string[char_i])\n new_char_index = char_index + (25 - (char_index * 2))\n new_str << alpha[new_char_index]\n end\n new_str\nend",
"def letter_swap(agent_name)\n vowels = \"aeiou\"\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n letter_swap = agent_name.split(\"\")\n secret_name = []\n letter_swap.map! do |ltr|\n if vowels.include?(ltr)\n secret_name << vowels[vowels.index(ltr)+1]\n elsif consonants.include?(ltr)\n secret_name << consonants [consonants.index(ltr)+1]\n else\n puts \" \"\n end\n end\n\n secret_name.join(\"\").split.map {|ltr| ltr.capitalize}.join(' ').capitalize\n\nend",
"def text target, *words\n\t\t\twords = [words].flatten\n\t\t\ttxt = [@data['text'][target]].flatten.sample\n\t\t\treturn nil if (txt.nil?)\n\t\t\treturn Input.substitute txt, words unless (words.empty?)\n\t\t\treturn txt\n\t\tend",
"def caesarCipherEncryptor(string, key)\n new_letters = []\n new_key = key % 26\n alphabet = (\"abcdefghijklmnopqrstuvwxyz\").chars\n\n string.each_char do |letter|\n new_letters.append(get_new_letter(letter, new_key, alphabet))\n end\n return new_letters.join\nend",
"def target_to_int(alphabet, target)\n target.split(//).map { |ch| \n v = alphabet.index(ch)\n if (v == nil)\n puts \"Password character '#{ch}' is not part of alphabet\"\n exit -1\n end\n v\n }\nend",
"def translate_word(word)\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\tword = word.split(' ')\n\tif (vowels.include?(word[0]))\n\t\tword.join + \"ay\"\n\telse \n\t\tuntil (!vowels.include?(word[0]))\n\t\t\tword.rotate!\n\t\t\ti += 1\n\t\t\t# word.rotate!\n\t\tend \n\t\treturn word.join + \"ay\"\n\tend \nend",
"def alias_generator(name)\n\nname = name.downcase\n\nvowels_lowcase = %w(a e i o u)\nvowels = vowels_lowcase\nconsonants_lowcase = (\"a\"..\"z\").to_a - vowels\nconsonants = consonants_lowcase\n\n# original = (vowels + consonants)\n# new_letters = (vowels.rotate + consonants.rotate)\n\nname_array = name.split\nname_reverse = name_array.reverse\n\nname_reverse.map! do |word|\n word_split = word.split(\"\")\n # name_reverse[1].split(\"\")\n\n word_split.map! do |letter|\n if vowels.include? letter\n index = vowels.index(letter)\n if letter == vowels.last\n letter = vowels.first\n else\n letter = vowels[index + 1]\n end\n else\n index = consonants.index(letter)\n if letter == consonants.last\n letter = consonants.first\n else\n letter = consonants[index + 1]\n end\n end\n end\n\n word_split[0] = word_split[0].upcase\n word_split.join('')\nend\n\nname_reverse.join(' ')\n# # p name_reverse.tr(original,new_letters)\n\n\n\nend",
"def translator(phrase)\r\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\r\n idx = 0\r\n translation = \"\"\r\n while idx < phrase.length\r\n if alpha.index(phrase[idx].downcase) == nil\r\n translation += \" boing\"\r\n elsif alpha.index(phrase[idx].downcase) < alpha.length / 2 && /[[:upper:]]/ =~ phrase[idx]\r\n translation += \" bloop\"\r\n elsif phrase[idx] == \"e\" || /[[:upper:]]/ =~ phrase[idx]\r\n translation += \" buzz\"\r\n else\r\n translation += \" beep\"\r\n end\r\n idx += 1\r\n end\r\n return translation\r\nend",
"def consonant_changer(name)\n consonant_guide = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n name.map! do |chars|\n counter = 0\n while counter < consonant_guide.length\n if chars == consonant_guide[counter]\n chars = consonant_guide[counter += 1]\n counter += 1\n elsif chars == \"z\"\n chars = \"b\"\n counter += 1\n else\n chars\n counter += 1\n end\n end\n chars\n end\n name\n name.join('').capitalize!\nend",
"def longest_prefix(strings)\n longest_prefix = \"\"\n num_letters = strings[0].length\n \n num_letters.times do |i|\n status = true\n check_letter = strings[0][i]\n strings.each do |string|\n if string[i] != check_letter\n status = false\n end\n end\n if status == true\n longest_prefix += check_letter\n end\n end\n \n return longest_prefix\nend",
"def word_selector array \n while @word_count.size > 0\n number = @word_count.shift\n @answer.push(@letter_array[0...number])\n @letter_array.slice!(0...number)\n number = nil\n end \n end",
"def translate_to_cipher(sentence)\n # this creates an array where each char represents one element and calls it alphabet\n alphabet = ('a'..'z').to_a\n # Takes the alphabet array, uses the zip array to assign merge element to sa key position in a hash, then maps those keys \n # to a new alphabet array that rotates each element by the element 4 positions later than it. \n cipher = Hash[alphabet.zip(alphabet.rotate(4))]\n # define spaces as an array of special char\n spaces = [\"@\", \"#\", \"$\", \"%\", \"^\", \"&\", \"*\"]\n \n #defines original_sentence as input converted to all lowercase letters\n original_sentence = sentence.downcase\n #creates array called encoded_sentence\n encoded_sentence = []\n\n # for each character in the string do\n original_sentence.each_char do |element|\n # if the cipher has the element, push the value of the element into the new array\n if cipher.include?(element)\n encoded_sentence << cipher[element]\n # if cipher has a space, select randomly from the 7 special chars, push sp char to new array\n elsif element == ' '\n encoded_sentence << spaces.sample\n # otherwise, push the element as is to the new arrray\n else \n encoded_sentence << element\n end\n end\n #output the encoded sentence array as a string\n return encoded_sentence.join\nend",
"def encrypt(plaintext) \n l = plaintext.length\n for i in 0...l do \n if plaintext[i] == \"z\"\n plaintext[i] = \"a\"\n elsif (plaintext[i] != ' ')\n letter = plaintext[i]\n letter = letter.next\n plaintext[i] = letter\n end\n end\n plaintext\nend",
"def chars_left\n @target_length - word.length\n end",
"def longest_prefix(strings)\n word_array = strings[0].split(\"\")\n length = strings.length\n\n prefix = \"\"\n\n word_array.each_with_index do |letter,letter_index|\n count_words_with_letter = 0\n\n (length - 1).times do |i|\n if (strings[i+1].split(\"\"))[letter_index] == letter \n count_words_with_letter += 1\n else\n return prefix\n end\n end\n\n if count_words_with_letter = length-1\n prefix += letter\n end\n end\n\n return prefix\nend"
] | [
"0.6263147",
"0.59900063",
"0.56929064",
"0.54568946",
"0.52123284",
"0.5184635",
"0.5175917",
"0.51453555",
"0.5139499",
"0.5135679",
"0.5120789",
"0.5089753",
"0.5039978",
"0.50380373",
"0.50269955",
"0.5017165",
"0.5009133",
"0.49814713",
"0.49745113",
"0.49641395",
"0.4949739",
"0.49470145",
"0.4943587",
"0.49188855",
"0.49093923",
"0.49067762",
"0.4903699",
"0.48968092",
"0.4896581",
"0.4893033",
"0.48797464",
"0.4877955",
"0.48530114",
"0.48471725",
"0.4846113",
"0.48446357",
"0.48440066",
"0.48366264",
"0.48350042",
"0.4829688",
"0.4819391",
"0.48190618",
"0.48067373",
"0.4804787",
"0.48041004",
"0.48020312",
"0.47994697",
"0.47939152",
"0.47924986",
"0.47916424",
"0.47828078",
"0.47822854",
"0.47796193",
"0.47724697",
"0.47582513",
"0.47531617",
"0.47508374",
"0.47438365",
"0.4742239",
"0.4741939",
"0.47410145",
"0.4738387",
"0.47369376",
"0.4730054",
"0.47288558",
"0.47288445",
"0.47283155",
"0.47187766",
"0.47085968",
"0.47079223",
"0.4706218",
"0.4705295",
"0.47031337",
"0.46994135",
"0.46968383",
"0.46950644",
"0.46936074",
"0.46928898",
"0.4688803",
"0.46797308",
"0.46792057",
"0.46788982",
"0.46763718",
"0.46703592",
"0.4669028",
"0.4668938",
"0.46674752",
"0.46652532",
"0.46632636",
"0.46616518",
"0.46573862",
"0.46513796",
"0.46501845",
"0.4649814",
"0.46484476",
"0.46481606",
"0.46472555",
"0.46453145",
"0.46441707",
"0.46419588"
] | 0.55259824 | 3 |
Input: none Return: Array of class name strings | def assemble_race_names
race_names = []
RACES.each_key do | key |
if RACES[key][:subraces].empty?
race_names << key
else
RACES[key][:subraces].each { |subrace| race_names << subrace }
end
end
race_names
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classes\n return [] unless classes = self[\"class\"]\n classes.strip.split(/\\s+/)\n end",
"def class_names\n classes.map &:name\n end",
"def class_names\n return if @class_names.empty?\n @class_names.uniq.sort\n end",
"def class_list\n array = []\n ObjectSpace.each_object(Class) {|m| array << m }\n array\n end",
"def classes\n\t\tlist = []\n\t\teach_class { |class_constant|\n\t\t\tlist\t<< class_constant\n\t\t}\n\t\treturn list\n\tend",
"def classes\n @classes.values\n end",
"def classes\n @classes.values\n end",
"def list_known_classes names = []\n classes = []\n stores.each do |store|\n classes << store.modules\n end\n classes = classes.flatten.uniq.sort\n unless names.empty? then\n filter = Regexp.union names.map { |name| /^#{name}/ }\n classes = classes.grep filter\n end\n puts classes.join(\"\\n\")\n end",
"def sc_all_classes()\n @all_class_names = @driver.get_sc_object_class_names(abs_path) if @all_class_names.nil?\n return @all_class_names\n end",
"def get_classes\n (attr['class'] || '').downcase.split(' ').sort\n end",
"def classes\n @classes\n end",
"def class_names\n descendants.map(&:name)\n end",
"def classes()\n\t\t\t\tlist = []\n\t\t\t\tdir = Dir.new( path() )\n\t\t\t\t\n\t\t\t\tdir.each do |file|\n\t\t\t\t\tnext if File.directory?( path() + \"/\" + file )\n\t\t\t\t\tnext if ( file[/^([A-Z][A-Za-z]*)+\\.class\\.rb$/] == nil )\n\t\t\t\t\tlist << clazz( $1 )\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn list\n\t\t\tend",
"def classes=(ary)\n `for(var result=[],i=0,l=ary.length;i<l;++i){result.push(ary[i].__value__);}`\n `this.__native__.className=result.join(' ')`\n return ary\n end",
"def classes(name = nil)\n if name\n classes.find(:name => name)\n else\n @classes.flatten\n end\n end",
"def classes\n kwattr_values(\"class\")\n end",
"def list_known_classes\n end",
"def extract_class_name(filename)\n nodes = ConstantExtractor.process(filename)\n nodes ? nodes.flat_map(&:children) : []\n end",
"def classes; end",
"def list_known_classes names = []\n classes = []\n\n stores.each do |store|\n classes << store.module_names\n end\n\n classes = classes.flatten.uniq.sort\n\n unless names.empty? then\n filter = Regexp.union names.map { |name| /^#{name}/ }\n\n classes = classes.grep filter\n end\n\n page do |io|\n if paging? or io.tty? then\n if names.empty? then\n io.puts \"Classes and Modules known to ri:\"\n else\n io.puts \"Classes and Modules starting with #{names.join ', '}:\"\n end\n io.puts\n end\n\n io.puts classes.join(\"\\n\")\n end\n end",
"def defined_classes\n # TODO: check content type before scanning\n content.scan(/\\s*class\\s+([A-Za-z0-9_\\.]*)/).flatten\n end",
"def class_names op, deep_inheritance=false\n raise \"#{self.class}.class_names not implemented\"\n end",
"def all_classes\n @classes_hash.values\n end",
"def creatable_classes\n #FIXME: make these discovered automatically.\n #FIXME: very bad method name\n #[Model,DataFile,Sop,Study,Assay,Investigation]\n [\"Method\",\"Survey\",\"Study\"]\n\n end",
"def name_and_class\n [name, self['class']].compact.join('.')\n end",
"def classnames_to_check(object)\n names = []\n clazz = object.getClass\n while clazz\n names << clazz.getName\n clazz.getInterfaces.each {|i| names << i.getName}\n clazz = clazz.getSuperclass\n end\n \n names.uniq\n end",
"def classes\n [self]\n end",
"def classes\n @class_ids.collect { |idx| BClass.store[idx] }\n end",
"def class_names op, deep_inheritance = false\n ret = []\n unless op.is_a? Sfcc::Cim::ObjectPath\n op = Sfcc::Cim::ObjectPath.new(op.to_s, nil) # assume namespace\n end\n flags = deep_inheritance ? Sfcc::Flags::DeepInheritance : 0\n begin\n @client.class_names(op, flags).each do |name|\n\tret << name.to_s\n end\n rescue Sfcc::Cim::ErrorInvalidNamespace\n end\n ret\n end",
"def css_class_names\n @css_class_names ||= []\n end",
"def classes(name = nil)\n find_children_of_type(\"Class\", name)\n end",
"def tag_class_list\n tags = self.tags.collect{|tag| tag.slug}\n tags.join(\" \")\n end",
"def classes\n self\n end",
"def classes()\n return @driver.get_sc_core_query_element_classes(@handle, @index)\n end",
"def get_classes(trans)\n classes = []\n trans.each do |t|\n classes.push(t[:program])\n end\n classes.uniq\n end",
"def classes\n @class_list ||= Element::Classes.new(self)\n end",
"def get_node_classes\n if ENV[\"classes\"]\n ENV[\"classes\"].split(\",\")\n else\n class_dir = File.expand_path(\"../../../modules/govuk/manifests/node\", __FILE__)\n all_class_name = Dir.glob(\"#{class_dir}/s_*.pp\").map { |filepath|\n File.basename(filepath, \".pp\")[2..-1] # Strip leading s_\n }\n all_class_name.reject {|c| $nodes_spec_blacklist_classes.include?(c) }\n end\n end",
"def unique_classes\n @unique_classes\n end",
"def all_classes(noun)\n classes = []\n c = noun\n while(c != :not_defined)\n classes.push(c)\n break if c == :noun\n c = what_is?(c)\n end\n return classes\n end",
"def get_objects_of_class_by_class_name(class_name)\n var_array = []\n @objects.each do |_k, v|\n var_array.push(v) if v.class.to_s == class_name.to_s\n end\n var_array\n end",
"def class_name object\n return object.class.to_s.split(/(?=[A-Z])/).join(' ')\n end",
"def fetch_classes_list\n uri = URI(BASE_URI + \"classes\")\n classes = make_request(uri)\n classes_instances = classes[\"results\"].map do |classes_data|\n Classes.new classes_data[\"name\"]\n end\n end",
"def find_classes\n puppetClasses = []\n Dir.glob( SpkDashboard::MANIFEST_ROOT + \"/modules/**/*.pp\" ).each do |manifest|\n File.read( manifest ).each do |line|\n foundClass = line.match(/^class (\\S+).*\\{/)\n if foundClass and puppetClasses.include?( foundClass[1] ) == false\n puppetClasses << foundClass[1]\n end\n end\n end\n \n return puppetClasses\n end",
"def suite_classes\n suite_names.map(&:safe_constantize).compact\n end",
"def makena_classes_u_p_sym\n makena_classes_u.map{|a| a.underscore.pluralize.to_sym}\n end",
"def full_class_name\n @class_names.join(\"::\")\n end",
"def names\n fs = []\n %w( DEFAULT CPU GPU ACCELERATOR CUSTOM ALL ).each { |f|\n fs.push(f) if self.include?( self.class.const_get(f) )\n }\n return fs\n end",
"def classes\n\t\traise \"classes: Not Implemented\"\n\tend",
"def classes(*args)\n [node ? node.classes(*args) : [], @wrapped_classes].flatten\n end",
"def type_names\n @type_names ||= @types.map { |clazz| clazz.name }\n end",
"def names\n fs = []\n %w( COARSE_GRAIN_BUFFER FINE_GRAIN_BUFFER FINE_GRAIN_SYSTEM ATOMICS ).each { |f|\n fs.push(f) if self.include?( self.class.const_get(f) )\n }\n return fs\n end",
"def get_classes( obj )\n cls = obj.class\n print cls.to_s\n while cls.superclass != nil\n cls = cls.superclass\n print ' < ' + cls.to_s\n end\nend",
"def component_classes( hs = hosts )\n hs.\n map( &:components ).\n flatten.\n map( &:class ).\n uniq\n end",
"def class_name\n klass = single_class\n while klass.name == ''\n klass = klass.superclass\n end\n if list_context?\n \"[#{klass}]\"\n else\n klass.name\n end\n end",
"def objects_of_class(name)\n find_all { |r| name === r['class'] }\n end",
"def test_case_classes\n classes = self.test_cases.dup\n classes.collect do |file|\n actionscript_file_to_class_name(file)\n end\n end",
"def makena_classes\n Rails.application.eager_load!\n pass = ActiveRecord::Base.descendants.map{|a| a.to_s}\n pass.shift\n pass\n end",
"def names\n fs = []\n %w( KERNEL NATIVE_KERNEL ).each { |f|\n fs.push(f) if self.include?( self.class.const_get(f) )\n }\n return fs\n end",
"def subclasses\n @subclasses ||= []\n end",
"def get_class_names_in(directory_name, options = {})\n tableized_names = get_files_in(directory_name, { :full_paths => false }.merge(options)).map { |n| n.subtract(\".rb\") }\n tableized_names.map { |names| names.camelize }\n end",
"def get_sorted_module_list classes\n classes.select do |klass|\n klass.display?\n end.sort\n end",
"def classes\n return @classes if @classes\n @classes = @context.classes.sort.find_all{|c| c.document_self}.collect{|c| R2Doc.all_references[c.full_name]}\n end",
"def findClassesThatMatch(name)\n fname = name.tr(':', '_')\n return ClassIndex.findClasses(fname)\n end",
"def subclasses\n @subclasses ||= []\n end",
"def scan_text_for_class_names(string)\r\n string.scan(TEXT_REGEX).flatten.map { |match| JavaQualifiedName.new(match) }\r\n end",
"def queue_names_routing_class(clazz)\n self.select { |x, y| y.is_a?(clazz) }.map { |x, y| x }\n end",
"def instance_names namespace, classname=nil, properties={}\n # if namespace is unset, sfcc will generate invalid XML\n namespace ||= \"root/cimv2\"\n case namespace\n when Sfcc::Cim::ObjectPath\n objectpath = namespace\n namespace = objectpath.namespace \n else\n objectpath = objectpath namespace.to_s, classname, properties\n end\n ret = []\n begin\n @client.instance_names(objectpath).each do |path|\n path.namespace = namespace # add missing data\n\tret << path\n end\n rescue Sfcc::Cim::ErrorInvalidClass, Sfcc::Cim::ErrorInvalidNamespace\n end\n ret\n end",
"def linked_classes_for(klass)\n return [] unless klass.respond_to?(:linked_classes_for)\n\n klass.linked_classes_for(current_component).map do |k|\n [k.underscore, t(k.demodulize.underscore, scope: \"decidim.filters.linked_classes\")]\n end\n end",
"def class_name\n fetch('heroes_of_the_storm.class_names')\n end",
"def as_names\n __getobj__.map { |i| i.name }\n end",
"def classes\n raise CapabilitiesExceeded\n end",
"def has_class?(name)\n a = []\n \n each do |e|\n if e.get(\"className\").split(\" \").index(name)\n a << e\n end\n end\n \n JS::Collection.new(a)\n end",
"def boring_classes\n return [::Class, *::Class.included_modules,\n ::Module, *::Module.included_modules,\n ::Kernel, *::Kernel.included_modules,\n ::Object, *::Object.included_modules,\n ::BasicObject, *::BasicObject.included_modules].uniq\n end",
"def class_decls; end",
"def dependency_classes\n res = []\n\n eager_loaded_components.keys.each do |aggr|\n res += component_instance(aggr).dependency_classes\n end\n\n res += self.class.class_ancestors\n\n res << self.class\n res.uniq\n end",
"def classes_hash\n @classes\n end",
"def classes_hash\n @classes\n end",
"def names\n fs = []\n %w( NONE CONST RESTRICT VOLATILE PIPE ).each { |f|\n fs.push(f) if self.include?( self.class.const_get(f) )\n }\n return fs\n end",
"def generate_user_classes *klasses\n return [] unless healthy?\n klasses.map do |klass|\n klass.from_hash(raw)\n end\n end",
"def types\n classifications.collect() do |c|\n c[\"classificationTypeName\"]\n end\n end",
"def classes\n curriculums = self.qualifications.collect{ |q| q.curriculums }.flatten\n\n unless curriculums.empty?\n curriculums.collect{ |c| c.school_class }.flatten.uniq\n else\n return []\n end\n end",
"def all_from_class\n begin\n class_name.all\n rescue\n @errors << {message: \"Unable to find this class in the database.\", variable: \"class_name\"}\n []\n end \n end",
"def what_has?(noun)\n components = []\n all_classes(noun).each do |class_iterator|\n Array(@components[class_iterator]).each do |component|\n components.push(component)\n end\n end\n return components\n end",
"def simple_classes\n _simple_classes\n end",
"def construct_klass(name)\n name.to_s.split('_').map{|i|i.capitalize}.join\n end",
"def pretty_class_name\n return self.class.to_s.split(/(?=[A-Z])/).join(' ')\n end",
"def get_class()\n result = nil\n @cont.each { |line|\n if line =~ /\\s*\\w+\\s*=/\n result = /\\w+/.match(line)[0]\n break\n end\n }\n return result\n end",
"def class_choices(stats)\n cl0 = [12, 0, 0, 0, 12, \"Guerrier/Gladiateur\"]\n cl1 = [0, 0, 13, 0, 0, \"Ninja/Assassin\"]\n cl2 = [0, 0, 12, 0, 0, \"Voleur\"]\n cl3 = [0, 0, 0, 12, 0, \"Prêtre\"]\n cl4 = [0, 12, 0, 0, 0, \"Mage/Sorcier\"]\n cl5 = [12, 10, 0, 11, 9, \"Paladin\"]\n cl6 = [0, 0, 10, 10, 0, \"Ranger\"]\n cl7 = [0, 0, 11, 12, 0, \"Ménestrel\"]\n cl8 = [11, 0, 11, 0, 0, \"Pirate\"]\n cl9 = [0, 12, 0, 11, 0, \"Marchand\"]\n cl10 = [0, 0, 11, 0, 0, \"Ingénieur\"]\n cl11 = [0, 10, 0, 11, 0, \"Bourgeois/Noble\"]\n\n classes = []\n i = 0\n while binding.eval(\"defined?(cl#{i})\")\n classes += [binding.eval(\"cl#{i}\")]\n i += 1\n end\n determine_choices(stats, classes)\n end",
"def classes(subnet)\n out = []\n subnet['classes'].each do |clas|\n out << %[ class \"#{clas['class']}\" {]\n out << raw_options(clas['raw_options'], 4)\n out << \" }\"\n out << ''\n end if subnet['classes']\n out << ''\n end",
"def database_classes system_classes: nil\n\t\t@actual_class_hash = get_classes('name', 'superClass') \n all_classes = get_classes('name').map(&:values).sort.flatten\n all_user_classes = all_classes - system_classes()\n\n all_user_classes.each{|x| ActiveOrient.database_classes[x] = \"unset\" unless ActiveOrient.database_classes.has_key?(x) }\n \n ActiveOrient.database_classes.keys # return an array of database-classnames\n end",
"def makena_classes_u\n passsingles = makena_classes.map{|a| a.to_s.underscore}\n passsingles - makena_classes_doubled\n end",
"def provider_list\n @provider_list ||= subclasses.inject([]) do |list, klass_name|\n klass = klass_name.constantize\n begin\n list << klass.instance\n rescue LoadError => exc\n logger.error \"#{klass} load error: #{exc}\"\n end\n list\n end\n end",
"def use_with_class_names\n (\n DynamicModel.model_names +\n ExternalIdentifier.model_names +\n ActivityLog.model_names +\n Master::PrimaryAssociations\n )\n .map { |m| m.to_s.singularize }\n .select { |m| m != 'master' }\n end",
"def names\n fs = []\n %w( HOST CONTENT_UNDEFINED ).each { |f|\n fs.push(f) if self.include?( self.class.const_get(f) )\n }\n return fs\n end",
"def classes\n @_classes ||= vedeu_classes - vedeu_exceptions - ignored_classes\n end",
"def names\n fs = []\n %w( READ_WRITE WRITE_ONLY READ_ONLY SVM_FINE_GRAIN_BUFFER SVM_ATOMICS ).each { |f|\n fs.push(f) if self.include?( self.class.const_get(f) )\n }\n return fs\n end",
"def names\n map(&:names).flatten\n end",
"def card_classes\n model_files = Dir.glob(\"#{Rails.root}/app/lib/#{name.underscore}/*.rb\")\n model_names = model_files.map { |fn| File.basename(fn, '.rb').camelize }\n model_names.map { |mn| \"#{name}::#{mn}\".constantize }.sort_by { |c| [c.try(:raw_cost), c.readable_name] }\n end",
"def all_classes_and_modules\n result = []\n ObjectSpace.each_object(Module) { |m| result << m }\n result.sort_by {|m| m.name}\nend",
"def defined_classname filename\r\n script = File.new filename\r\n script.each_line do |line|\r\n if line =~ /class(.*)[<|\\z]/ \r\n script.close\r\n return $1.strip\r\n end\r\n end \r\n script.close \r\n \"\"\r\nend",
"def terminus_classes(indirection_name)\n setup_instance_loading indirection_name\n instance_loader(indirection_name).files_to_load.map do |file|\n File.basename(file).chomp(\".rb\").intern\n end\n end"
] | [
"0.84288144",
"0.8351828",
"0.7914066",
"0.775523",
"0.7728422",
"0.75971234",
"0.75971234",
"0.7441282",
"0.7420649",
"0.7397904",
"0.7305958",
"0.7299291",
"0.7175605",
"0.71508366",
"0.71216613",
"0.70579606",
"0.7051302",
"0.7014196",
"0.69802696",
"0.69609004",
"0.6887946",
"0.68009704",
"0.67881685",
"0.6751031",
"0.6744564",
"0.6701447",
"0.6688937",
"0.6674722",
"0.66455567",
"0.66421086",
"0.66403097",
"0.6616188",
"0.660503",
"0.65885466",
"0.65800965",
"0.65721196",
"0.6556422",
"0.6552091",
"0.65426385",
"0.6541226",
"0.65312654",
"0.65171313",
"0.6504419",
"0.64809674",
"0.6466727",
"0.6426111",
"0.64230055",
"0.64019126",
"0.63969725",
"0.6337293",
"0.63284194",
"0.63215154",
"0.6318115",
"0.6317834",
"0.6312581",
"0.6308551",
"0.6303368",
"0.62887216",
"0.62815356",
"0.62644434",
"0.6262855",
"0.6260661",
"0.6259896",
"0.62381566",
"0.6232685",
"0.6229135",
"0.62189794",
"0.62185717",
"0.618961",
"0.61884934",
"0.61871415",
"0.6164703",
"0.6160913",
"0.6159059",
"0.6158215",
"0.61368304",
"0.61368304",
"0.61338764",
"0.6115963",
"0.61146694",
"0.6099547",
"0.60956836",
"0.6089468",
"0.6082273",
"0.6081822",
"0.60817945",
"0.607642",
"0.6071654",
"0.60702085",
"0.6059919",
"0.60426325",
"0.604036",
"0.6015158",
"0.6013662",
"0.6008511",
"0.5992575",
"0.59908384",
"0.59780073",
"0.597103",
"0.5960429",
"0.59577554"
] | 0.0 | -1 |
Indent each line of a string by n spaces | def indent(n)
indent = " " * n
gsub '\n', "\n#{indent}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indent(string, n)\n tabs = \"\\t\" * n\n wrap = screen_width - (n * 8) - 1\n\n tabs + string.gsub(/(.{1,#{wrap}})(\\s+|\\Z)/, \"\\\\1\\n#{tabs}\").rstrip\n end",
"def indent(str, count = 2)\n str = require_string! str\n pre = ' ' * count\n\n map_lines(str) { |line| \"#{pre}#{line}\" }\n end",
"def indent(txt, n = 2)\n \"#{' ' * n}#{txt}\"\n end",
"def indent(str, amount=2)\n i = (\" \"*amount)\n (i + str.gsub(/\\n/, \"\\n#{i}\")).rstrip\n end",
"def indentize!(count, char = ' ')\n tap do |s|\n s.gsub!(/([^\\n]*)(\\n|$)/) do\n s1 = Regexp.last_match(1)\n s2 = Regexp.last_match(2)\n not_empty = s1 != '' || s2 != ''\n \"#{char * count}#{s1}#{s2}\" if not_empty\n end\n end\n end",
"def indent(string, amt)\n string.gsub /\\n *([^\\n]+)/m, \"\\n#{' ' * amt}\\\\1\"\n end",
"def indent(str,n)\n return '' unless str\n if n >= 0\n str.gsub(/^/, ' ' * n)\n else\n str.gsub(/^ {0,#{-n}}/, \"\")\n end\n end",
"def indent(n)\n if n >= 0\n gsub(/^/, ' ' * n)\n else\n gsub(/^ {0,#{-n}}/, \"\")\n end\n end",
"def indent(n)\n if n >= 0\n gsub(/^/, ' ' * n)\n else\n gsub(/^ {0,#{-n}}/, \"\")\n end\n end",
"def indent(n)\n if n >= 0\n gsub(/^/, ' ' * n)\n else\n gsub(/^ {0,#{-n}}/, \"\")\n end\n end",
"def indent(str, spaces)\n str.split(\"\\n\").map { |s| (' ' * spaces) + s }.join(\"\\n\")\n end",
"def indent_for(line); end",
"def indent( text, spaces=4 )\n\t\tprefix = ' ' * spaces\n\t\treturn text.gsub( /(?<=\\A|\\n)/m, prefix )\n\tend",
"def indent_all_lines(str, spaces = 2)\n return '' if str.nil? || str.blank?\n\n str.strip.split(/\\n/).map { |line| optimize_indentation(line, spaces.to_i) }.join('')\nend",
"def indent(str, indent=' ')\n str.split(\"\\n\").collect do |frag|\n \"#{indent}#{frag}\"\n end.join(\"\\n\")\n end",
"def indent2(str, count)\n if str\n char = ' '\n #(char * count) + gsub(/(\\n+)/) { $1 + (char * count) }\n str.gsub(/(\\n+)/) { $1 + (char * count) }\n end\n end",
"def indent string, amount\n indent_string = ' ' * amount * INDENT_DEPTH\n string.gsub(/^/, indent_string)\n end",
"def indent!(amount, indent_string = nil, indent_empty_lines = false)\n indent_string = indent_string || self[/^[ \\t]/] || ' '\n re = indent_empty_lines ? /^/ : /^(?!$)/\n gsub!(re, indent_string * amount)\n end",
"def indent!(amount, indent_string=nil, indent_empty_lines=false)\n indent_string = indent_string || self[/^[ \\t]/] || ' '\n re = indent_empty_lines ? /^/ : /^(?!$)/\n gsub!(re, indent_string * amount)\n end",
"def indent_each_line!(indent_sequence=\"\\t\")\n\t\treturn self.collect!{ |line|\t\"#{indent_sequence}#{line}\" }\n\tend",
"def indent(str, depth=2)\n space = \" \"*depth\n str.split(\"\\n\").join(\"\\n#{space}\").gsub(/^ *$/, \"\")\n end",
"def indent_string\n s = \"\"\n @indentCount += 1\n s += \" \" * @indentCount\n end",
"def unindent(txt, n = 2)\n txt.gsub /^[ ]{#{n}}/, ''\n end",
"def indent1\n ' ' * 2\n end",
"def formatIndents(theLines)\n\n\ttheLines.each do |theLine|\n\t\n\t\tif (theLine[:text] =~ /^(\\s+)(.*)/)\n\t\t\ttextPrefix = $1;\n\t\t\ttextSuffix = $2;\n\t\t\t\n\t\t\tnumTabs = textPrefix.size / CONFIG_TAB_WIDTH;\n\t\t\tnumSpaces = textPrefix.size % CONFIG_TAB_WIDTH;\n\n\t\t\ttheLine[:text] = (\"\\t\" * numTabs) + (\" \" * numSpaces) + textSuffix;\n\t\tend\n\n\tend\n\t\n\treturn theLines;\n\nend",
"def word_wrap(text, indent=0)\n chars = text.split(//)\n unless text.length < 80\n count = 1\n last_space = 80\n chars.each_with_index do |char, index|\n count += 1\n last_space = index if char.match(/ /)\n if char == \"\\n\"\n count = indent\n elsif count == 80\n chars[last_space] = \"\\n#{\" \" * indent}\"\n count = indent + index - last_space\n end\n end\n end\n chars.join\n end",
"def insert_indentation(line, indentation)\n line ? \" \" * indentation + line.to_s : \"\"\n end",
"def indent(amount, indent_string=nil, indent_empty_lines=false)\n dup.tap {|_| _.indent!(amount, indent_string, indent_empty_lines)}\n end",
"def wrap(s, width=80)\n s.gsub(/(.{1,#{width}})(\\s+|\\Z)/, \"\\\\1\\n\")\nend",
"def indent!(num)\n replace( ' ' * num + self.gsub(\"\\n\", \"\\n\"+' '*num))\n self\n end",
"def outdent(n)\n indent(-n)\n end",
"def outdent(n)\n indent(-n)\n end",
"def draw_text_indent(line, string, additional=0)\n return if line <= 0\n y = 32 * line - 32\n self.contents.draw_text(35+additional, y, @width, 32, string)\n end",
"def with_indent ()\n thread[:indent] += 1\n yield\n ensure\n thread[:indent] -= 1\n end",
"def wrap_and_indent(prefix, width=nil)\n prefix = \" \"*prefix if prefix.is_a? Numeric\n\n prefix_size = prefix.strip_color.size\n\n if width\n width = width - prefix_size\n else\n width = -prefix_size\n end\n\n wrap(width).each_line.map { |line| prefix + line }.join\n end",
"def tab(str, n=1, chr=' ')\n chr * n + str\nend",
"def indent; end",
"def indent; end",
"def indent; end",
"def indent; end",
"def indent; end",
"def format_lines(lines, indentation)\n lines.gsub(/\\n/, \"\\n\" + indentation)\n end",
"def indent_string(level = 0)\n INDENT * level\n end",
"def unindent str\n lines = str.split(\"\\n\")\n spaces = minimum_leading_spaces lines\n lines.collect do |line|\n line.slice(spaces, line.length).rstrip\n end.join(\"\\n\")\n end",
"def indent_atom; \" \"; end",
"def indents\n lines.map do |line|\n line.chars.take_while { |char| char == \" \" }.size / INDENT_WIDTH\n end\n end",
"def decoration(number, line_length)\n (\"=\" * number * (line_length+1)) << \"\\n\"\nend",
"def indent(indent, *s)\n \"#{\" \" * indent}#{s.join('')}\"\n end",
"def indent(amount, indent_string = nil, indent_empty_lines = false)\n dup.tap { |_| _.indent!(amount, indent_string, indent_empty_lines) }\n end",
"def indent_string(string, *args)\n string = string.dup\n indent_string!(string, *args)\n string\n end",
"def write_indented_lines(where, lines_string, indent_amount)\n lines_as_array = lines_string.split(/\\r|\\n|\\r\\n/)\n lines_as_array.each do |line|\n where << \" \" * indent_amount\n where.puts line\n end\n end",
"def puts_indent(level, text)\n print \" \"*level, text, \"\\n\"\nend",
"def fixed_indent(n)\n self.outdent(self.level_of_indent).indent(n)\n end",
"def horizontalSpacer(n , text)\n n.times {print \" \"}\n puts text\nend",
"def indent(line, index)\n unless line.match(/(^$|^\\S|^( )+\\S)/)\n add_spacing_issue\n @final_spacing_string += \"indentation spacing issue at line #{index} \\n\"\n return \"indentation spacing issue at line #{index} \\n\"\n end\n nil\n end",
"def indent_template(template, index)\n striped_template(template).map do |slice|\n slice.prepend(' ' * index)\n end.join(\"\\n\") + \"\\n\"\n end",
"def indent(prefix=\" \")\n prefix = (\" \" * prefix) if prefix.is_an? Integer\n\n if block_given?\n lines.each { |line| yield prefix + line }\n else\n lines.map { |line| prefix + line }.join('')\n end\n end",
"def optimize_indentation(value, amount = 0)\n return \"#{value}\\n\" unless value.is_a?(String)\n \"#{value.strip_heredoc.indent(amount).chomp}\\n\"\n end",
"def optimize_indentation(value, amount = 0)\n return \"#{value}\\n\" unless value.is_a?(String)\n \"#{value.strip_heredoc.indent(amount).chomp}\\n\"\n end",
"def tabbed_text(text, spaces = 0)\n Array(text).join(\"\\n\").gsub(\"\\n\", \"\\n#{' ' * (4 + spaces.to_i)}\").strip\n end",
"def normalize_indentation text\n lines = text.split(\"\\n\")\n return text if lines.empty?\n\n indent = if lines[0] =~ /^(\\s+)(.+?)$/\n $1.length\n else\n 0\n end\n lines.map{|l| l[indent..-1]}.join \"\\n\"\n end",
"def indent_text( text, mod, first_line = true )\n\t\t\treturn \"\" if text.to_s.empty?\n spacing = indent( mod )\n text = text.gsub( /\\A([^\\n])/, \"#{ spacing }\\\\1\" ) if first_line\n\t\t\treturn text.gsub( /\\n^([^\\n])/, \"\\n#{spacing}\\\\1\" )\n\t\tend",
"def expand_tabs(n=8)\n n = n.to_int\n raise ArgumentError, \"n must be >= 0\" if n < 0\n return gsub(/\\t/, \"\") if n == 0\n return gsub(/\\t/, \" \") if n == 1\n str = self.dup\n while\n str.gsub!(/^([^\\t\\n]*)(\\t+)/) { |f|\n val = ( n * $2.size - ($1.size % n) )\n $1 << (' ' * val)\n }\n end\n str\n end",
"def expand_tabs(n=8)\n n = n.to_int\n raise ArgumentError, \"n must be >= 0\" if n < 0\n return gsub(/\\t/, \"\") if n == 0\n return gsub(/\\t/, \" \") if n == 1\n str = self.dup\n while\n str.gsub!(/^([^\\t\\n]*)(\\t+)/) { |f|\n val = ( n * $2.size - ($1.size % n) )\n $1 << (' ' * val)\n }\n end\n str\n end",
"def indentation\n \" \" * @indent_size * @indent_level\n end",
"def indent()\n #This is a stub, used for indexing\n end",
"def unindent(text)\n lines = text.split(\"\\n\")\n lines.shift while lines.first =~ /^\\s*$/ && !lines.empty?\n lines.pop while lines.last =~ /^\\s*$/ && !lines.empty?\n min_indent = lines.reject { |ln| ln =~ /^\\s*$/ }\n .map { |ln| ln.scan(/^\\s*/) }.flatten.map(&:length).min\n lines.map { |ln| ln.sub(/^\\s{#{min_indent}}/, '') }.join(\"\\n\")\nend",
"def tidy(data)\n indent = 0\n data.split(/\\n/).map do |line|\n line.gsub!(/^\\s*/, '')\n next if line.empty?\n indent -= 1 if line =~ /^\\s*\\}\\s*$/\n line = (' ' * (indent * 2)) + line\n indent += 1 if line =~ /\\{\\s*$/\n line\n end.compact.join(\"\\n\") + \"\\n\"\n end",
"def tabto(n)\n if self =~ /^( *)\\S/\n indent(n - $1.length)\n else\n self\n end\n end",
"def undent\n indent = split(\"\\n\").select { |line| !line.strip.empty? }.map { |line| line.index(/[^\\s]/) }.compact.min || 0\n gsub(/^[[:blank:]]{#{indent}}/, '').chomp\n end",
"def indent(amount, indent_string = nil, indent_empty_lines = false)\n dup.tap { |d| d.indent!(amount, indent_string, indent_empty_lines) }\n end",
"def indent(text)\n text.gsub!(INDENT_REGEX, \"\\\\0#{@indent}\")\n text\n end",
"def Columnize( text, width, indent )\n\treturn indent + text.scan(/(.{1,#{width}})(?: |$)/).join(\"\\n#{indent}\")\nend",
"def indent_width(txt)\n txt.match(/\\A\\s*/).to_s.length\n end",
"def wrap(line, cols=80, tabsize=2)\n line = line.gsub(/\\t/, \" \" * tabsize) unless tabsize == nil\n line.gsub(/(.{1,#{cols}})( +|$\\r?\\n?)|(.{1,#{cols}})/, \"\\\\1\\\\3\\n\").split(/\\s*?\\n/)\n end",
"def indent(leader)\n leader =\n Numeric === leader ? ' ' * leader.to_i : leader.to_s\n str = self.gsub \"\\n\", \"\\n\"+leader\n str.insert 0, leader\n str\n end",
"def indented\n \"#{INDENTATION * indents}#{original}\"\n end",
"def wrap(width)\n width ||= 80\n output = []\n indent = ''\n\n text = gsub(/\\t/, ' ')\n\n text.lines do |line|\n line.chomp! \"\\n\"\n if line.length > width\n indent = if line.uncolor =~ /^(\\s*(?:[+\\-*]|\\d+\\.) )/\n ' ' * Regexp.last_match[1].length\n else\n ''\n end\n new_lines = line.split_line(width)\n\n while new_lines.length > 1 && new_lines[1].length + indent.length > width\n output.push new_lines[0]\n\n new_lines = new_lines[1].split_line(width, indent)\n end\n output += [new_lines[0], indent + new_lines[1]]\n else\n output.push line\n end\n end\n output.map!(&:rstrip)\n output.join(\"\\n\")\n end",
"def outdent(text)\n lines = text.split(\"\\n\")\n indented_with = /^ +/.match(lines.first)[0]\n lines.map { |line| line.gsub(/^#{indented_with}/, '') }.join(\"\\n\") + \"\\n\"\n end",
"def indent(times = 1)\n if ENV['TM_SOFT_TABS'] == 'NO' then \"\\t\" * times\n else ' ' * ENV['TM_TAB_SIZE'].to_i * times\n end\nend",
"def line_wrap(strs, first_indent, rest_indent, max_len)\n\n # First, tokenize the strings\n words = []\n strs.each do |str|\n if str =~ /\\A</\n # String is a tag; treat as atomic unit and don't split\n words << str\n else\n # String of white and non-white tokens.\n # Tokenize into white and non-white tokens.\n str.scan(/\\S+|\\s+/).each { |word| words << word }\n end\n end\n\n # Now merge tokens that are not separated by whitespace tokens. For\n # example, \"<i>\", \"word\", \"</i>\" gets merged to \"<i>word</i>\". But\n # \"<i>\", \" \", \"word\", \" \", \"</i>\" gets left as separate tokens.\n\n words2 = []\n words.each do |word|\n # If there is a previous word that does not end with whitespace,\n # and the currrent word does not begin with whitespace, concatenate\n # current word to previous word. Otherwise append current word to\n # end of list of words.\n if words2.last && words2.last !~ /\\s\\z/ && word !~ /\\A\\s/\n words2.last << word\n else\n words2 << word\n end\n end\n\n lines = [ ]\n line = \"\"\n llen = 0\n # set the indent for the first line\n indent = first_indent\n # saved-up whitespace to put before next non-white word\n white = \"\"\n \n words2.each do |word| # ... while words remain to wrap\n # If word is whitespace, save it. It gets added before next\n # word if no line-break occurs.\n if word =~ /\\A\\s/\n white << word\n next\n end\n wlen = word.size\n if llen == 0\n # New output line; it gets at least one word (discard any\n # saved whitespace)\n line = \" \" * indent + word\n llen = indent + wlen\n indent = rest_indent\n white = \"\"\n next\n end\n if llen + white.length + wlen > max_len\n # Word (plus saved whitespace) won't fit on current line.\n # Begin new line (discard any saved whitespace).\n lines << line\n line = \" \" * indent + word\n llen = indent + wlen\n indent = rest_indent\n white = \"\"\n next\n end\n # add word to current line with saved whitespace between\n line << white + word\n llen += white.length + wlen\n white = \"\"\n end\n \n # push remaining line, if any\n lines << line unless line.empty?\n \n return lines\n end",
"def context_line(lines, index, padding, prefix=nil)\n return '' if index < 1 || index > lines.size\n margin = prefix ? prefix * index.to_s.size : index.to_s\n \"#{margin}#{' ' * ([padding - margin.size, 0].max)} #{lines[index - 1]}\"\n end",
"def wrap(text, line_width = 100)\n text.gsub(/(.{1,#{line_width}})/, \"\\\\1\\n\")\n end",
"def indentation; end",
"def indentation; end",
"def wrap_text(s, width=78) # {{{\n return nil unless s\n\ts.gsub(/(.{1,#{width}})(\\s+|\\Z)/, \"\\\\1\\n\").split(\"\\n\")\nend",
"def tabto(n)\n if self =~ /^( *)\\S/\n indent(n - $1.length)\n else\n self\n end\n end",
"def indent=(_arg0); end",
"def indented_puts(string, indent_level)\n puts \"#{INDENT * indent_level}#{string}\"\n end",
"def print_spacing spaces\n spaces.times do\n puts \"\\n\"\n end\nend",
"def justify(str, size)\n if str.include?('-')\n # ' - ' => ' --- '\n str = ('-' * size).center(size + 2, ' ')\n elsif str.include?('|')\n # put _size_ spaces in between bars\n # Use indexes to grab leftmost/rightmost chars. Each may be a bar, may be a\n # space.\n str = str[0,1] + ' ' * (size) + str[-1,1]\n else\n # Blank strings are always lines that would have dashes (line 0, 2, or 4)\n str = ' ' * (size + 2)\n end\n return str\nend",
"def outdent(str)\n str =~ /\\A(?:\\s*?\\n)( *)(.*)\\z/m ? $2.gsub!(/^ {0,#{$1.length}}/, '') : str\n end",
"def wrap(text, length, indent=0, padding=0)\n if text.length > length - indent\n paragraphs = []\n line = ''\n text.split(/\\s+/).map(&:chomp).reject(&:empty?).each do |fragment|\n if line.length < length - indent\n line << fragment + ' '\n else\n paragraphs << line\n line = padding + fragment + ' '\n end\n end\n paragraphs << line\n text = paragraphs.join(\"\\n\")\n end\n text\n end",
"def tab(n, *string)\r\n string.each_with_index { |e, i| i == 0 ? (puts \" \" * n + e) : (puts e) }\r\n end",
"def line_split (in_string)\n my_string_array = in_string.split(\"\\n\")\n\n my_string_array.each_index do |index|\n # determine digits in largest line num, digits in current line num, & necessary padding\n max_line_digits = my_string_array.count.to_s.length\n this_line_digits = (index+1).to_s.length\n padding = ' ' * (max_line_digits - this_line_digits)\n\n # output the line\n puts \"Line #{padding}#{index + 1}: #{my_string_array[index]}\"\n end\nend",
"def indent_out\n @indent << \" \"\n end",
"def newParagraphSpacer(n) \n n.times {puts \" \" }\nend",
"def space\n 3.times { puts \"\\n\"}\n end",
"def indent( mod = nil )\n #p [ self.id, level, mod, :INDENT ]\n if level <= 0\n mod ||= 0\n else\n mod ||= options(:Indent)\n mod += ( level - 1 ) * options(:Indent)\n end\n return \" \" * mod\n\t\tend",
"def increase_spaces()\n @spaces += 1\n end"
] | [
"0.8151938",
"0.7972252",
"0.78305465",
"0.77427477",
"0.77108395",
"0.76289326",
"0.7585391",
"0.75265837",
"0.75257385",
"0.75050694",
"0.74884945",
"0.74743265",
"0.7383328",
"0.73805463",
"0.73201305",
"0.7262584",
"0.7253317",
"0.71463615",
"0.712658",
"0.7092507",
"0.70639175",
"0.69482046",
"0.6839977",
"0.6837639",
"0.6749307",
"0.6744571",
"0.6682383",
"0.6658806",
"0.6647097",
"0.6631238",
"0.66235214",
"0.66235214",
"0.6602664",
"0.6591919",
"0.65376395",
"0.65299547",
"0.6526223",
"0.6526223",
"0.6526223",
"0.6526223",
"0.6526223",
"0.65108836",
"0.65035516",
"0.64953053",
"0.6494847",
"0.6492442",
"0.6488001",
"0.6484432",
"0.64729816",
"0.6466078",
"0.6450943",
"0.64453584",
"0.64239067",
"0.63697004",
"0.6368752",
"0.6364445",
"0.63628775",
"0.632121",
"0.632121",
"0.6284348",
"0.62755376",
"0.6269122",
"0.6263941",
"0.6263941",
"0.62490654",
"0.62265694",
"0.61972374",
"0.6185591",
"0.61575794",
"0.6155856",
"0.6148256",
"0.6143866",
"0.6140549",
"0.6136742",
"0.61323553",
"0.6128518",
"0.61163944",
"0.6109785",
"0.6106741",
"0.6105159",
"0.60922337",
"0.6087334",
"0.6076002",
"0.6075681",
"0.6075681",
"0.6050878",
"0.60506743",
"0.6041694",
"0.60362667",
"0.603353",
"0.60207653",
"0.6005833",
"0.5999804",
"0.59825724",
"0.59803945",
"0.5973788",
"0.59672624",
"0.5944342",
"0.59429073",
"0.5938543"
] | 0.780284 | 3 |
num The Integer that will be the starting point. Examples previous_number(101) => 100 Returns the number before the input. | def previous_number(num)
return num - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prev_num(num1)\n return num1 + 1\nend",
"def previous_number(number)\n return number - 1\nend",
"def previous_number(number)\n return number - 1\nend",
"def previous_number(number)\n return number - 1 \nend",
"def previous_number(number)\n return number-1\nend",
"def previous_number(input)\n output = 0\n output = input - 1\n \n return output\n end",
"def prev_number(number)\n return number -= 1\nend",
"def next_number(num)\n num + 1\n end",
"def previous_number(number)\n if !number.is_a?(Integer)\n return false\n else \n return number-1\n end\nend",
"def prev_page\n num = current_page - 1\n num if num.positive?\n end",
"def input_to_index(num)\n return num.to_i - 1\n end",
"def prev_page_number\n [page_number - 1, first_page_number].max\n end",
"def start_num\n return @start_num\n end",
"def next_num(num)\n return num + 1\nend",
"def next_number(num)\n return num + 1\nend",
"def next_number(num)\n return num + 1\nend",
"def next_number(num)\n return num + 1\nend",
"def next_number(num)\n return num + 1\nend",
"def input_to_index(num)\n num = num.to_i\n return num - 1\nend",
"def next_number(num)\n return num += 1\nend",
"def start_num=(value)\n @start_num = value\n end",
"def input_to_index(num)\r\n index= num.to_i\r\n index= index - 1\r\nend",
"def next_number(number)\n return number +1\nend",
"def page_start_for(page_num)\n page_size * (page_num - 1) + 1\n end",
"def count_down(num)\n p num;\n count_down(num - 1)\n end",
"def next_number(number)\n number.to_i\n return number+=1\nend",
"def previous(n=1)\n self - n\n end",
"def next_number(number)\n output = number + 1\n return output\nend",
"def calculate_prev\n p = @current_page - 1\n p <= 0 || p > @total_pages ? nil : p\n end",
"def input_to_index(number)\n index = number.to_i\n index = index - 1\nend",
"def next_number\n process_next_block if @numbers.empty?\n\n @numbers.shift\n end",
"def prev_page\n page - 1 if pages.include?(page - 1)\n end",
"def next_number(number)\n return number += 1\nend",
"def next_number(number)\n\n return number + 1\n\nend",
"def start_result_number\n ((page - 1) * per_page) + 1\n end",
"def prev_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page_number\n Hash(previous_page_params).fetch('page', {}).fetch('number', nil)\n end",
"def prev_page\n current_page - 1 unless first_page? || out_of_range?\n end",
"def current_page_number\n (previous_page_number.to_i + 1).to_s\n end",
"def define_num\n self.num ||= from.new_num_message\n end",
"def prev_page\n first_page = pages.first.to_i\n first_page > 1 ? (first_page - 1) : nil\n end",
"def num()\n @num\n end",
"def get_next_number\n if project && number.blank?\n last_invoice_number = Invoice.where(:project_id => project.id).max(:number)\n self.number = last_invoice_number ? ((last_invoice_number + 1).to_i) : 1\n end\n end",
"def which_page_number(page_num, scheme = 0)\n return nil unless @page_numbering\n\n num = nil\n start = start_num = 1\n\n @page_numbering[scheme].each do |kk, vv|\n if kk <= page_num\n if vv.kind_of?(Hash)\n unless vv[:starting].nil?\n start = vv[:starting]\n start_num = kk\n num = page_num - start_num + start\n end\n else\n num = nil\n end\n end\n end\n num\n end",
"def previous_sibling(num = 1, scope = {})\n scope[:limit] = num\n siblings = previous_siblings(scope)\n num == 1 ? siblings.first : siblings\n end",
"def previous_page\n return if page == 1\n page - 1\n end",
"def prev_page\n p = page - 1\n p < 1 && p = nil\n p\n end",
"def prev\n goto(@current_page - 1)\n end",
"def num; end",
"def num; end",
"def num\n @num\n end",
"def previous_page\n return nil if total_pages < 1\n return nil if page == 1\n return page - 1\n end",
"def prev_prime(n=1)\n apply(n, &:get_prev_prime)\n end",
"def previous_row num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)\n @oldrow = @current_index\n # NOTE that putting a multiplier inside, prevents an event from being triggered for each row's\n # on leave and on enter\n num.times { \n @current_index -= 1 if @current_index > 0\n }\n bounds_check\n $multiplier = 0\n end",
"def previous_page\n current_page == 1 ? nil : current_page - 1\n end",
"def up num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)\n #@oldindex = @current_index if num > 10\n @current_index -= num\n #unless is_visible? @current_index\n #if @prow > @current_index\n ##$status_message.value = \"1 #{@prow} > #{@current_index} \"\n #@prow -= 1\n #else\n #end\n #end\n $multiplier = 0\n end",
"def num_to_idx(num)\n [(num - 1) / @n, (num - 1) % @n]\n end",
"def prev_page\n go_to_page(@current_page-1)\n end",
"def page(num)\n limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1))\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def num\r\n @num\r\n end",
"def input_to_index(num)\n input = num.strip\n int = input.to_i\n input = int - 1\n return input\nend",
"def next_page_number\n [page_number + 1, last_page_number].min\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def up num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)\n @oldindex = @current_index if num > 10\n @current_index -= num\n unless is_visible? @current_index\n if @prow > @current_index\n #$status_message.value = \"1 #{@prow} > #{@current_index} \"\n @prow -= 1\n else\n end\n end\n $multiplier = 0\n end",
"def previous_page\n current_page == 1 ? nil : current_page - 1\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def add_num(num)\n insert_index = @nums.bsearch_index{|val| val >= num}\n if insert_index.nil?\n @nums.push(num)\n else\n @nums.insert(insert_index, num)\n end\n end",
"def previous\n return @page - 1\n end",
"def num\n begin\n Integer self\n rescue ArgumentError\n nil\n end\n end",
"def next_num(num, max=9, min=0)\r\n arr = num\r\n done = false\r\n for i in 0...arr.length\r\n index = arr.length - i - 1\r\n \tif arr[index] == max\r\n \t arr[index] = min\r\n \t next\r\n \tend\r\n\t arr[index] += 1\r\n done = true\r\n\t break\r\n end\r\n arr = [min] + arr if not done\r\n arr.join_to_i\r\nend",
"def up_number\n unless number\n if Invoice.count == 0\n self.number = '001'\n else\n last_invoice = Invoice.order(:number).last\n self.number = last_invoice.number.succ\n end\n end\n end",
"def prev\n prev? ? @current - 1 : nil\n end",
"def previous_page\n @current_page - 1 if has_previous_page?\n end",
"def next_step_number\n progress = current_progress\n progress ? current_progress.step.number + 1 : 0\n end",
"def previous_version( number )\n find( :first, :order => 'number DESC', :conditions => [ \"number < ?\", number ] )\n end",
"def get_num\n la = $lookahead\n\n return expected(\"Integer\") unless is_digit(la)\n\n lookahead\n\n la\nend",
"def previous_page\n @current_page > 1 ? (@current_page - 1) : nil\n end",
"def prev_page\n get_page([1, @current_page - 1].sort.last)\n end",
"def prev_by(field)\n \t\t\tstep_by(field, :prev) \n \t\tend",
"def input_to_index(input)\n num = input.to_i\n num -=1\n return num\nend",
"def count_down(num) \n if num == 0\n p \"Houston, we have lift-off!\"\n return;\n end\n\n p num\n count_down(num - 1)\n end",
"def previous_page\n @previous_page ||= (current_page > 1) ? current_page - 1 : 1\n end",
"def from(num)\n params(from: num)\n end",
"def increment_until(num, target)\n while num < target\n num += 1\n print num\n end\n print \"\\n\" + num.to_s + \"\\n\"\nend",
"def prev; pager.page(page - 1); end",
"def get_actual_number(number)\n if number >= 31\n return number + 2\n else\n return number + 1\n end\n end",
"def last_number\n puts \"enter your last number:\"\n @num2 = gets.to_f\n puts \"Your last number is #{@num2}\"\nend",
"def previous\n\t first? ? nil : locate - 1\n\tend",
"def smallest_paledrome(original_num)\n paledrome = (original_num + 1).to_s\n return paledrome if paledrome.eql?(paledrome.reverse)\n number = original_num\n until paledrome.eql?(paledrome.reverse) do\n number += 1\n paledrome = number.to_s\n return paledrome if paledrome.eql?(paledrome.reverse)\n end\nend"
] | [
"0.7594526",
"0.73985696",
"0.73985696",
"0.73568785",
"0.73310405",
"0.7218397",
"0.7161143",
"0.68676937",
"0.65727973",
"0.65406317",
"0.65239036",
"0.6452188",
"0.6416887",
"0.63998336",
"0.63734347",
"0.63734347",
"0.63734347",
"0.63734347",
"0.6274615",
"0.62695825",
"0.62224174",
"0.620381",
"0.6188248",
"0.6173879",
"0.61613274",
"0.61063397",
"0.610036",
"0.60482705",
"0.6028074",
"0.5987308",
"0.5972763",
"0.595924",
"0.5946922",
"0.59411657",
"0.59226805",
"0.5884748",
"0.5860115",
"0.58588034",
"0.58561563",
"0.5818731",
"0.579642",
"0.57949203",
"0.57670265",
"0.57423556",
"0.573329",
"0.5726501",
"0.5718321",
"0.5713735",
"0.5713129",
"0.5713129",
"0.5711739",
"0.5694994",
"0.56872445",
"0.5673447",
"0.56726664",
"0.56615233",
"0.5657944",
"0.5655529",
"0.5655053",
"0.5648851",
"0.5648851",
"0.56482595",
"0.56447864",
"0.5641994",
"0.56358373",
"0.56358373",
"0.56358373",
"0.56358373",
"0.56358373",
"0.5634539",
"0.5631812",
"0.56283015",
"0.562795",
"0.562795",
"0.56228083",
"0.5620063",
"0.56179",
"0.5614162",
"0.5614061",
"0.5605515",
"0.55942637",
"0.5567986",
"0.5567186",
"0.5566532",
"0.5560797",
"0.55593556",
"0.554696",
"0.5542202",
"0.5541277",
"0.5535315",
"0.5474403",
"0.5460068",
"0.5459053",
"0.5458509",
"0.54570675",
"0.5445835",
"0.5438592"
] | 0.77267605 | 3 |
Any variables that need to be changed should be done inside the customize method | def customize
# If the PACKAGE_VERSION variable is passed from the command line, then set
# @package_version equal to what was passed. Else, use the current version
# of puppet
if ENV['PACKAGE_VERSION']
@package_version = ENV['PACKAGE_VERSION']
else
@package_version = '2.7.3'
end
# Puppet-specific Variables
@title = "Puppet_Install"
@reverse_domain = "com.puppetlabs"
@package_major_version = @package_version.split('.')[0]
@package_minor_version = @package_version.split('.')[1] + @package_version.split('.')[2]
@puppet_file = "puppet-#{@package_version}"
@puppet_url = "http://downloads.puppetlabs.com/puppet/"
@puppet_tarfile = "#{@puppet_file}.tar.gz"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom; end",
"def custom; end",
"def use_default_customizations!\n DEFAULT_CUSTOMIZATIONS.each_pair do |field, default_value|\n send(\"#{field}=\".to_sym, default_value)\n end\n DEFAULT_COLORS.each_key do |field|\n send(\"color_#{field}=\".to_sym, nil)\n end\n save\n end",
"def overrides; end",
"def modify\n super\n end",
"def overrides=(_arg0); end",
"def set_additional_values(object, override)\n override.class.attributes.each do |o|\n object.instance_variable_set(\"@#{o}\", override[o])\n object.define_singleton_method(o.to_sym) { instance_variable_get(\"@#{o}\") }\n end\n end",
"def fill_customization_director\n end",
"def processor_options\n original_processor_options.merge!(:style => name)\n end",
"def handle_customization\n @order = current_order(false)\n # Process if we got customization data from the product or cart page\n if params[:customization] # && params[:elected_engraving] == 'true'\n # Find line item that can be customized, and set its preferred_customization_data\n begin\n params[:customization][:data].each do |id, text|\n line_item = (id == 'new') ? @order.line_items.last : @order.line_items.where(id: id).first\n line_item.preferred_customization = text.to_json if line_item.product.engravable?\n end\n rescue Exception => e\n # Don't do anything for now\n Rails.logger.warn \"Failed updating line item with customization data. Order #{@order.number}\"\n end\n else # Check if a customizable SKU has been added without the customizatiob data in the form\n # Find line item that can be customized, and set its preferred_customization_data\n begin\n line_item = @order.line_items.last\n line_item.preferred_customization = {'line1' => '', 'line2' => '', 'line3' => ''}.to_json if line_item.product.engravable?\n rescue Exception => e\n # Don't do anything for now\n Rails.logger.warn \"Failed updating line item with customization data. Order #{@order.number}\"\n end \n end\n end",
"def myletter\n \n end",
"def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend",
"def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend",
"def style=(_); end",
"def styles=(_arg0); end",
"def override\n attributes.override\n end",
"def update!(**args)\n @color = args[:color] if args.key?(:color)\n @priority_override = args[:priority_override] if args.key?(:priority_override)\n end",
"def theme=(_arg0); end",
"def specialist_setting\n\tend",
"def customize(key, value)\n @customizations << [key, value]\n end",
"def prep_variables\n end",
"def override_after(inside, override, after)\n c_ovr = normalize_part(override, :after)\n c_aft = normalize_part(after, :after)\n c_inside = normalize_part(inside, :inside)\n \n # change reset :all to specific resets\n if c_aft[:reset].include?(:all)\n c_aft[:reset] = Resets.keys - [:all]\n end\n # change keep :all to specific resets\n if c_ovr[:keep].include?(:all)\n c_ovr[:keep] = Resets.keys - [:all]\n end\n \n c_aft[:reset] = (c_aft[:reset] + c_ovr[:reset]).uniq\n # remove keeps from resets\n c_aft[:reset] -= c_ovr[:keep]\n \n # clear disable if keep :style\n if c_ovr[:keep].include?(:style) ||\n c_aft[:disable] = []\n end\n \n # if override disables styles, remove blanket style reset\n if c_ovr[:disable].length >= 1\n c_aft[:reset] -= [:style]\n end\n\n # replace reset :style with style specific targets\n if c_inside[:enable].length > 0 && c_aft[:reset].include?(:style)\n c_aft[:reset] -= [:style]\n c_aft[:disable] += c_inside[:enable]\n c_aft[:enable] -= c_inside[:enable]\n end\n\n # If we've reached this point with reset :style, change it into\n # disables\n if c_aft[:reset].include?(:style)\n c_aft[:reset] -= [:style]\n c_aft[:disable] += Styles.keys\n end\n \n # prevent enables from conflicting with disables\n en = (c_aft[:enable] + c_ovr[:enable] - c_ovr[:disable]).uniq\n di = (c_aft[:disable] + c_ovr[:disable] - c_ovr[:enable]).uniq\n \n en -= di\n di -= en\n \n result = { enable: en, disable: di, reset: c_aft[:reset] }\n ColorTargets.keys.each do |k|\n val = (c_ovr[k] || c_aft[k])\n result[k] = val unless val.nil?\n end\n \n return normalize_part(result, :after, true)\n end",
"def construct_data\n add_properties(@adv_settings, :if_missing)\n super\n end",
"def styles; end",
"def styles; end",
"def styles; end",
"def update!(**args)\n @background_color = args[:background_color] if args.key?(:background_color)\n @bold = args[:bold] if args.key?(:bold)\n @font_size = args[:font_size] if args.key?(:font_size)\n @font_type = args[:font_type] if args.key?(:font_type)\n @font_weight = args[:font_weight] if args.key?(:font_weight)\n @handwritten = args[:handwritten] if args.key?(:handwritten)\n @italic = args[:italic] if args.key?(:italic)\n @letter_spacing = args[:letter_spacing] if args.key?(:letter_spacing)\n @pixel_font_size = args[:pixel_font_size] if args.key?(:pixel_font_size)\n @smallcaps = args[:smallcaps] if args.key?(:smallcaps)\n @strikeout = args[:strikeout] if args.key?(:strikeout)\n @subscript = args[:subscript] if args.key?(:subscript)\n @superscript = args[:superscript] if args.key?(:superscript)\n @text_color = args[:text_color] if args.key?(:text_color)\n @underlined = args[:underlined] if args.key?(:underlined)\n end",
"def nooverride()\n merge(tbnooverride: 'true')\n end",
"def special\n override\n end",
"def theme; end",
"def theme; end",
"def theme; end",
"def extra; end",
"def update!(**args)\n @background_color = args[:background_color] if args.key?(:background_color)\n @color = args[:color] if args.key?(:color)\n @font_family = args[:font_family] if args.key?(:font_family)\n @font_size = args[:font_size] if args.key?(:font_size)\n @font_weight = args[:font_weight] if args.key?(:font_weight)\n @text_anchor = args[:text_anchor] if args.key?(:text_anchor)\n @text_decoration = args[:text_decoration] if args.key?(:text_decoration)\n @text_style = args[:text_style] if args.key?(:text_style)\n end",
"def update!(**args)\n @background_color = args[:background_color] if args.key?(:background_color)\n @header_theme = args[:header_theme] if args.key?(:header_theme)\n @landscape_background_image_url = args[:landscape_background_image_url] if args.key?(:landscape_background_image_url)\n @logo_url = args[:logo_url] if args.key?(:logo_url)\n @mask_color = args[:mask_color] if args.key?(:mask_color)\n @portrait_background_image_url = args[:portrait_background_image_url] if args.key?(:portrait_background_image_url)\n @primary_color = args[:primary_color] if args.key?(:primary_color)\n end",
"def update!(**args)\n @background_color = args[:background_color] if args.key?(:background_color)\n @description = args[:description] if args.key?(:description)\n end",
"def style; end",
"def style; end",
"def style; end",
"def customization_params\n params.require(:customization).permit(:color_background, :color_border, :color_text, :color_highlight, :color_hover, :text_apt_suite, :text_inaccurate, :text_select_confirm, :text_select_suggestion, :text_suggest1, :text_suggest2)\n end",
"def prepare_custom_fields(fields)\n fields.each_with_object({}) { |e, o| o[\"copyleaks-client-custom-#{e[0]}\"] = e[1] }\n end",
"def update!(**args)\n @bold = args[:bold] if args.key?(:bold)\n @highlight = args[:highlight] if args.key?(:highlight)\n @italics = args[:italics] if args.key?(:italics)\n @strikethrough = args[:strikethrough] if args.key?(:strikethrough)\n @style = args[:style] if args.key?(:style)\n @underline = args[:underline] if args.key?(:underline)\n end",
"def update!(**args)\n @bold = args[:bold] if args.key?(:bold)\n @highlight = args[:highlight] if args.key?(:highlight)\n @italics = args[:italics] if args.key?(:italics)\n @strikethrough = args[:strikethrough] if args.key?(:strikethrough)\n @style = args[:style] if args.key?(:style)\n @underline = args[:underline] if args.key?(:underline)\n end",
"def setup_variables(options = {})\n @color = (preferred_color || options.delete(:color))\n @width, @height = options.delete(:size)\n @min_value, @max_value = options[:min_value], options[:max_value]\n @opacity = options[:opacity] || 1.0\n @complexity = options[:complexity]\n end",
"def attr_reader(*vars)\n super *(add_tracked_attrs(true, false, *vars))\n end",
"def custom_data\n super.attributes\n end",
"def setting; end",
"def customization\n\t\tbegin\n\t\t\t@toppings = Topping.actives\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend",
"def snapshot_hidden_custom_fields=(_arg0); end",
"def setcharup(*)\n super\n end",
"def set_functions\n super\n end",
"def customize_dictionary(dict_name, dict)\n customize_en_us_dictionary(dict) if dict_name == :en_US\n customize_es_pr_dictionary(dict) if dict_name == :es_PR\n customize_fr_dictionary(dict) if dict_name == :fr_FR\n end",
"def set_defaults\n super\n self.extended_useful_life_months ||= 0\n self.extended_useful_life_miles ||= 0\n end",
"def initialize_copy( original )\n\t\t@settings = original.settings.dup\n\t\t@overridden_settings = {}\n\tend",
"def with_new_options(*args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n\n CONTROLLER_OPTIONS.each{ |key| replace_instance_variable(\"@_#{key}\", options.delete(key)) }\n replace_instance_variable(:@_controller, args)\n replace_instance_variable(:@_defaults, options)\n replace_instance_variable(:@filters, :before => @filters[:before].dup, :after => @filters[:after].dup)\n replace_instance_variable(:@layout, @layout)\n\n yield\n\n @original_instance.each do |key, value|\n instance_variable_set(key, value)\n end\n end",
"def set_defaults\n super\n end",
"def set_defaults\n super\n end",
"def update_custom_properties\n # properties\n properties = %w[Accuracy VesselName VesselType PhotoSize PhotoPerson Comment] # matches name of concern so camelized\n\n models = %w[photograph] # matches file_name so underscore\n models.each do |m|\n file_text = File.read(\"app/models/#{m}.rb\")\n properties.each do |p|\n next if file_text.include? p\n inject_into_file \"app/models/#{m}.rb\", after: 'WorkBehavior' do\n \"\\n include DogBiscuits::#{p}\"\n end\n end\n end\n\n #Add lat long which needs to be indexed but is part of the Geo concern so not required to be processed above\n properties = %w[Accuracy VesselName VesselType PhotoSize PhotoPerson Comment LatLong RightsHolder GeonameId BibliographicCitation]\n\n # solr_doc\n properties.each do |p|\n solr_doc = \"\\n attribute :#{p.underscore.downcase}, Solr::Array, solr_name('#{p.underscore.downcase}')\\n\"\n next if File.read('app/models/solr_document.rb').include? p.underscore.downcase\n inject_into_file 'app/models/solr_document.rb', before: \"\\nend\\n\" do\n solr_doc\n end\n end\n end",
"def change_info(n,h,w)\n @name = n\n @height = h\n @weight = w\nend",
"def css=(_arg0); end",
"def initialize(*)\n super\n apply_defaults\n end",
"def __strval_optkeys\n super() << 'selectcolor' << 'title'\n end",
"def init_custom_fields\n super\n @synthesis_level = 0\n @synthesis_materials = []\n end",
"def original; end",
"def use_style=(style)\n end",
"def overrides\n @overrides ||= {}\n end",
"def overrides\n @overrides ||= {}\n end",
"def customize!(customizing_org)\n raise _('customize! requires an organisation target') unless customizing_org.is_a?(Org) # Assume customizing_org is persisted\n raise _('customize! requires a template from a funder') if !self.org.funder_only? && !self.is_default # Assume self has org associated\n customization = deep_copy(\n attributes: {\n version: 0,\n published: false,\n family_id: new_family_id,\n customization_of: self.family_id,\n org: customizing_org,\n visibility: Template.visibilities[:organisationally_visible],\n is_default: false\n }, modifiable: false, save: true)\n return customization\n end",
"def pre_render\n super\n @selected_indices = @source.selected_indices\n @left_margin = @source.left_margin\n @bg = @source.bgcolor\n @fg = @source.color\n @attr = NORMAL\n @row_focussed_attr ||= $row_focussed_attr\n end",
"def change_info(n, h, w) #these three arguments correspond to the new name height and weight respectively\n @name = n\n @height = h\n @weight = w\nend",
"def extract_custom_settings!(options)\n @heading = options.key?(:heading) ? options.delete(:heading) : default_heading\n @sortable_column = options.delete(:sortable)\n @sortable_start = options.delete(:sortable_start) || 0\n @new_record = options.key?(:new_record) ? options.delete(:new_record) : true\n @destroy_option = options.delete(:allow_destroy)\n options\n end",
"def update!(**args)\n @custom_function_return_value_markup = args[:custom_function_return_value_markup] if args.key?(:custom_function_return_value_markup)\n end",
"def configure_field\n end",
"def around\n ClimateControl.modify(default_env_vars) do\n super\n end\n end",
"def change_info(n, h, w)\n self.name = n\n self.height = h\n self.weight = w\nend",
"def change_info(n, h, w)\n #using self. tells ruby we are calling the set method we created earlier, not a local variable\n self.name = n\n self.height = h\n self.weight = w\n end",
"def apply_overrides\n\t\tself.synchronize do\n\t\t\traise LocalJumpError, \"can't be called re-entrantly\" if self.overridden_settings\n\t\t\tself.overridden_settings = self.gather_current_settings\n\t\tend\n\n\t\tself.log_hosts_to_affect.each do |host|\n\t\t\thost.logger.restore_settings( self.settings )\n\t\tend\n\tend",
"def custom_initialize_instance_variables\n puts \"[Application Error]\".colorize(:color => :white, :background => :red) + \" [#{__FILE__}][Need to override #{__method__} method in #{self.class} class]\".red\n return false\n end",
"def configure_field\n end",
"def override_amounts(reason,new_amounts)\n self.override_reason = reason\n new_amounts.each do |run_code,amount|\n @puc_groups[run_code][:overridden_amount]= amount\n end\n \n end",
"def rn_custom; @rn_custom; end",
"def add_options; end",
"def set_customizing\n @customizing = Customizing.find(params[:id])\n end",
"def update!(**args)\n @background_type = args[:background_type] if args.key?(:background_type)\n @collage = args[:collage] if args.key?(:collage)\n @cropping = args[:cropping] if args.key?(:cropping)\n @model_type = args[:model_type] if args.key?(:model_type)\n @nfs = args[:nfs] if args.key?(:nfs)\n @object_count = args[:object_count] if args.key?(:object_count)\n @overlay = args[:overlay] if args.key?(:overlay)\n @selfie = args[:selfie] if args.key?(:selfie)\n @text_overlay = args[:text_overlay] if args.key?(:text_overlay)\n @version = args[:version] if args.key?(:version)\n end",
"def update!(**args)\n @font_color = args[:font_color] if args.key?(:font_color)\n @format_type = args[:format_type] if args.key?(:format_type)\n end",
"def overrides(args={}, &block)\n @overrides << {:args => args, :block => block}\n self\n end",
"def overrides(args={}, &block)\n @overrides << {:args => args, :block => block}\n self\n end",
"def customizations(root)\n\t\tcustomizations = {}\n\t\t## role\n\t\t## each_Report_on_A_new_page\n\t\t## generate_partial_order_reports\n\t\t## we have pre printed letter heads\n\t\t## we have pre printed footers\n\t\t## generate_header\n\t\t## generate_report_summary\n\t\t## generate_footer\n\t\t## show_patient_details_on_each_page\n\t\t## signature_after_every_Report\n\t\t## outsourced_reports_have_original_format\n\t\t## add_processed_at_footnote_if_using_our_letter_head\n\t\t## premium_percentage_on_outsourced_reports\n\t\t## bill_outsourced_reports_to_patients\n\t\t## bill_outsourced_reports_to_order_creator\n\n\t\t############# ARRAY ELEMENTS #####################\n\t\t[\"lis_enabled\",\"we_have_pre_printed_footers\",\"we_have_pre_printed_letter_heads\",\"generate_header\",\"generate_report_summary\",\"generate_footer\",\"show_patient_details_on_each_page\",\"signature_after_every_report\",\"outsourced_reports_have_original_format\",\"add_processed_at_footnote_if_using_our_letter_head\",\"bill_outsourced_reports_to_patient\",\"bill_outsourced_reports_to_order_creator\",\"each_report_on_new_page\",\"generate_partial_order_reports\"].each do |name|\n\n\n\t\t\tcustomizations[name] = \"<div class='input-field' style='margin-top:4rem !important; margin-bottom: 4rem !important;'>\" + (select_tag(root + \"[#{name}]\",options_for_select(YES_NO_OPTIONS,(self.send(name))))) + \"<label>#{name}</label></div>\"\n\n\t\tend\n\n\n\t\tcustomizations\n\tend",
"def init_custom_fields\n @growth_rate = [0.0] * 8\n @msp = 0\n @capacities = []\n end",
"def disable_colorization=(value); end",
"def process_options\n \n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def update_ui_field_style\n @ui_field.secureTextEntry=@options[:type]==:password\n @ui_field.autocorrectionType = get_auto_correct_type(@options[:auto_correct])\n @ui_field.autocapitalizationType = get_auto_capitalize_type(@options[:auto_capitalize])\n @ui_field.keyboardType = get_keyboard_type(@options[:keyboard])\n @ui_field.enabled = @options[:type] != :label\n\n\n text_view_toolbar = PlasticCup::Base.style(UIToolbar.new, frame: CGRectMake(0,0,320,44))\n done_button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemDone, target: self, action: 'did_return:')\n\n text_view_toolbar.items=[\n UIBarButtonItem.flexible_space, done_button\n ]\n @ui_field.inputAccessoryView = text_view_toolbar\n\n end",
"def colorize!; @colors = true; end",
"def add_standard_properties\n super\n\n @config_manager.add_override_property('run.config_name', self.class.basename)\n end",
"def set_styles\n self.has_styles = true\n self.twitter_style = true\n end",
"def set_attributes\n self.web_name = AppConfig.cloud[:name]\n if self.custom_image_id\n ci = CustomImage.find_by_id!(custom_image_id)\n self.cost = ci.price\n self.region = ci.region\n self.image_id = ci.remote_image_id\n\n #Map product_type or size_type since that is being used across the app.\n if ci.hosting == \"AWS\"\n pt = ProductType.find_by_memory!(ci.ram)\n self.product_type = pt.name\n self.size_type = nil\n elsif ci.hosting == \"DigitalOcean\"\n st = SizeType.find_by_memory!(ci.ram)\n self.size_type = st.size_id\n self.product_type = nil\n end\n else\n if type == \"AWS\"\n self.cost = ProductType.find_by_name(params[:product][:product_type]).cost_per_month\n elsif type == \"DigitalOcean\"\n self.cost = SizeType.find_by_size_id(params[:product][:size_type]).cost_per_month\n end\n end\n\n self.status = 'pending'\n end",
"def settransformationparameters(*)\n super\n end",
"def settings; end"
] | [
"0.622962",
"0.622962",
"0.6183651",
"0.6172321",
"0.6101626",
"0.6065511",
"0.60627764",
"0.60318035",
"0.59992373",
"0.5955803",
"0.59350264",
"0.58234197",
"0.58234197",
"0.5808141",
"0.57784057",
"0.5750394",
"0.57392853",
"0.5703728",
"0.56711465",
"0.5664207",
"0.5602432",
"0.5597781",
"0.55886185",
"0.55810434",
"0.55810434",
"0.55810434",
"0.5547888",
"0.55408627",
"0.5537346",
"0.55278033",
"0.55278033",
"0.55278033",
"0.5521175",
"0.5518687",
"0.5515723",
"0.54871416",
"0.54863703",
"0.54863703",
"0.54863703",
"0.5477681",
"0.5448872",
"0.5447743",
"0.5447743",
"0.5438194",
"0.54331744",
"0.5429592",
"0.54289913",
"0.54224217",
"0.541844",
"0.5408072",
"0.5386183",
"0.5385297",
"0.5382456",
"0.53633714",
"0.53599244",
"0.5359816",
"0.5359816",
"0.5356531",
"0.534868",
"0.5344539",
"0.5343739",
"0.5338509",
"0.5337284",
"0.5329268",
"0.53223896",
"0.53204966",
"0.53204966",
"0.5316129",
"0.53147906",
"0.53134924",
"0.53005",
"0.52993894",
"0.5296137",
"0.52946794",
"0.5293205",
"0.5289981",
"0.5277336",
"0.5270291",
"0.5265686",
"0.52572614",
"0.52516407",
"0.525004",
"0.5249575",
"0.5244259",
"0.52415717",
"0.524065",
"0.524065",
"0.5235986",
"0.5226724",
"0.52246886",
"0.5213167",
"0.5213167",
"0.5213167",
"0.52107126",
"0.52062595",
"0.5201903",
"0.5201151",
"0.51961625",
"0.51931655",
"0.51917726"
] | 0.56186396 | 20 |
The pack method is for adding files to the package's payload. Note that | def pack
# Set the variable here so it can grab the contents of @working_tree (which
# is set in the make_directory_tree method).
@work = "#{@working_tree['WORK_D']}"
# Download and unpack the Puppet Source
safe_system("curl #{@puppet_url}/#{@puppet_tarfile} -o #{@puppet_tarfile}")
safe_system("#{TAR} xzf #{@puppet_tarfile}")
# Make all necessary directories
FileUtils.mkdir_p("#{@work}/private/etc/puppet/")
FileUtils.mkdir_p("#{@work}/usr/bin")
FileUtils.mkdir_p("#{@work}/usr/sbin")
FileUtils.mkdir_p("#{@work}/usr/share/doc/puppet")
FileUtils.mkdir_p("#{@work}/usr/share/man/man5")
FileUtils.mkdir_p("#{@work}/usr/share/man/man8")
FileUtils.mkdir_p("#{@work}/Library/Ruby/Site/1.8/puppet")
# Install necessary files
safe_system("#{INSTALL} -o root -g wheel -m 644 ./#{@puppet_file}/conf/auth.conf #{@work}/private/etc/puppet/auth.conf")
safe_system("#{DITTO} ./#{@puppet_file}/bin/ #{@work}/usr/bin")
safe_system("#{DITTO} ./#{@puppet_file}/sbin/ #{@work}/usr/sbin")
safe_system("#{INSTALL} -o root -g wheel -m 644 ./#{@puppet_file}/man/man5/puppet.conf.5 #{@work}/usr/share/man/man5/")
safe_system("#{DITTO} ./#{@puppet_file}/man/man8/ #{@work}/usr/share/man/man8")
safe_system("#{DITTO} ./#{@puppet_file}/lib/ #{@work}/Library/Ruby/Site/1.8/")
# Setup a preflight script and replace variables in the files with
# the correct paths.
safe_system("#{INSTALL} -o root -g wheel -m 644 ./#{@puppet_file}/conf/osx/preflight #{@working_tree['SCRIPT_D']}")
safe_system("sed -i '' \"s\#{SITELIBDIR}\#/usr/lib/ruby/site_ruby/1.8\#g\" #{@working_tree['SCRIPT_D']}/preflight")
safe_system("sed -i '' \"s\#{BINDIR}\#/usr/bin\#g\" #{@working_tree['SCRIPT_D']}/preflight")
# Install documentation (matching for files with capital letters)
Dir.foreach("./#{@puppet_file}") do |file|
safe_system("#{INSTALL} -o root -g wheel -m 644 ./#{@puppet_file}/#{file} #{@work}/usr/share/doc/puppet") if file =~ /^[A-Z][A-Z]/
end
# Set Permissions
FileUtils.chmod_R(0755, "#{@work}/usr/bin")
FileUtils.chown_R('root', 'wheel', "#{@work}/usr/bin")
FileUtils.chmod_R(0755, "#{@work}/usr/sbin")
FileUtils.chown_R('root', 'wheel', "#{@work}/usr/sbin")
FileUtils.chmod_R(0755, "#{@work}/usr/share/man/man8")
FileUtils.chown_R('root', 'wheel', "#{@work}/usr/share/man/man8")
FileUtils.chmod_R(0644, "#{@work}/Library/Ruby/Site/1.8/")
FileUtils.chown_R('root', 'wheel', "#{@work}/Library/Ruby/Site/1.8/")
Find.find("#{@work}/Library/Ruby/Site/1.8/") do |dir|
FileUtils.chmod(0755, dir) if File.directory?(dir)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pack\n end",
"def pack_and_store(path, payload)\n repo = Git.open(path)\n repo.checkout(\n payload.get(:data, :code_fetcher, :info, :commit_sha)\n )\n asset_key = [\n payload.get(:data, :code_fetcher, :info, :owner),\n payload.get(:data, :code_fetcher, :info, :name),\n payload.get(:data, :code_fetcher, :info, :commit_sha)\n ].join('-') + '.zip'\n _path = File.join(working_directory, Carnivore.uuid)\n begin\n tmp_path = File.join(_path, asset_key)\n FileUtils.mkdir_p(tmp_path)\n origin_path = repository_path(payload)\n files_to_copy = Dir.glob(\n File.join(\n origin_path,\n '{.[^.]*,**}',\n '**',\n '{*,*.*,.*}'\n )\n )\n files_to_copy = files_to_copy.map do |file_path|\n next unless File.file?(file_path)\n relative_path = file_path.sub(\"#{origin_path}/\", '')\n relative_path unless File.fnmatch('.git*', relative_path)\n end.compact\n files_to_copy.each do |relative_path|\n new_path = File.join(tmp_path, relative_path)\n FileUtils.mkdir_p(File.dirname(new_path))\n FileUtils.cp(File.join(origin_path, relative_path), new_path)\n end\n tarball = asset_store.pack(tmp_path)\n asset_store.put(asset_key, tarball)\n ensure\n FileUtils.rm_rf(_path)\n end\n payload.set(:data, :code_fetcher, :asset, asset_key)\n true\n end",
"def pack directory_path\n Dir.chdir directory_path\n name = Dir.pwd.split(@fs).last\n files = Dir.glob \"**#{@fs}*\"\n File.open([name, @ext].join(\".\"), \"wb\") do |tar|\n Minitar.pack(files, tar)\n end\n end",
"def create_from(file_map)\n @izpackVersion ||= '4.3.5' \n @appName ||= project.id\n @izpackBaseDir = File.dirname(@output) if !@izpackBaseDir\n @installerType ||= 'standard'\n @inheritAll ||= 'true'\n @compression ||= 'deflate'\n @compressionLevel ||= '9'\n @locales ||= ['eng']\n @panels ||= ['TargetPanel', 'InstallPanel']\n @packs ||= \n raise \"You must include at least one file to create an izPack installer\" if file_map.size == 0 and !File.exists?(@input) \n izPackArtifact = Buildr.artifact( \"org.codehaus.izpack:izpack-standalone-compiler:jar:#{@izpackVersion}\")\n doc = nil\n if !File.exists?(@input)\n\tgenInstaller(Builder::XmlMarkup.new(:target=>File.open(@input, 'w+'), :indent => 2), file_map)\n\t# genInstaller(Builder::XmlMarkup.new(:target=>$stdout, :indent => 2), file_map)\n\t# genInstaller(Builder::XmlMarkup.new(:target=>File.open('/home/niklaus/tmp2.xml', 'w+'), :indent => 2), file_map)\n end\n Buildr.ant('izpack-ant') do |x|\n\tizPackArtifact.invoke\n\tmsg = \"Generating izpack aus #{File.expand_path(@input)}\"\n\ttrace msg\n\tif properties\n\t properties.each{ |name, value|\n\t\t\t puts \"Need added property #{name} with value #{value}\"\n\t\t\t x.property(:name => name, :value => value) \n\t\t\t}\n\tend\n\tx.echo(:message =>msg)\n\tx.taskdef :name=>'izpack', \n\t :classname=>'com.izforge.izpack.ant.IzPackTask', \n\t :classpath=>izPackArtifact.to_s\n\tx.izpack :input=> @input,\n\t\t :output => @output,\n\t\t :basedir => @izpackBaseDir,\n\t\t :installerType=> @installerType,\n\t\t :inheritAll=> @inheritAll,\n\t\t :compression => @compression,\n\t\t :compressionLevel => @compressionLevel do\n\tend\n end\n end",
"def add_package(package)\n [package_handler(File.extname(package).tr(\".\", \"\")).add(content, package)].flatten.compact\n end",
"def build\n @log.info \"Packaging files\"\n pkgdir = File.join(@path, \"pkg\")\n FileUtils.mkdir_p pkgdir\n\n FileUtils.chmod(0755, Dir[\"#{Ian.debpath(@dir)}/*\"])\n FileUtils.chmod(0755, Ian.debpath(@dir))\n\n pkg = File.join(pkgdir, \"#{pkgname}.deb\")\n output = %x[fakeroot dpkg-deb -b #{@dir} #{pkg}]\n\n return [$?.success?, pkg, output]\n end",
"def package!\n Backup::Packager.new(self).package!\n end",
"def package!\n Logger.message \"#{ self.class } started packaging the backup files.\"\n run(\"#{ utility(:tar) } -c -f '#{ File.join(Backup::TMP_PATH, \"#{ Backup::TIME }.#{ Backup::TRIGGER }.tar\") }' -C '#{ Backup::TMP_PATH }' '#{ Backup::TRIGGER }'\")\n end",
"def add(hash, package)\n info = extract_fields(package)\n info.merge!(generate_checksums(package))\n filenames = inject_package(hash, info, package)\n filenames\n end",
"def emitIzPackXML(xm)\n # raise \"xm must be an Builder::XmlMarkup object, but is #{xm.class}\" if xm.class != Builder::XmlMarkup\n xm.pack(@attributes) {\n xm.description(@description)\n @files.each{ |src, dest| xm.singlefile('src'=> src, 'target' =>dest) }\n }\n end",
"def compress\n @env[:ui].info I18n.t(\"vagrant.actions.general.package.compressing\", :tar_path => tar_path)\n File.open(tar_path, Platform.tar_file_options) do |tar|\n Archive::Tar::Minitar::Output.open(tar) do |output|\n begin\n current_dir = FileUtils.pwd\n\n copy_include_files\n\n FileUtils.cd(@env[\"package.directory\"])\n Dir.glob(File.join(\".\", \"**\", \"*\")).each do |entry|\n Archive::Tar::Minitar.pack_file(entry, output)\n end\n ensure\n FileUtils.cd(current_dir)\n end\n end\n end\n end",
"def write\n entries = Dir.entries(@input_dir); entries.delete(\".\"); entries.delete('..')\n io = Zip::File.open(@server_pack_file, Zip::File::CREATE)\n write_entries(entries, '', io)\n io.close\n end",
"def bundle!(export_dir= Rails.configuration.gtdinbox_export_dir)\n @bundle_filename = \"#{export_dir}/#{@bundle_id}-translation-export.zip\"\n\n\n Zip::ZipFile.open(@bundle_filename, Zip::ZipFile::CREATE) do |zipfile|\n pp @dir_names\n @dir_names.each {|dirname|zipfile.mkdir(dirname)}\n @dir_files.each do |dir_file|\n dirname, file = dir_file\n zip_filepath = File.basename(file.path).gsub(\"#{dirname}-#{@bundle_id}-\",'')\n zipfile.add([dirname, zip_filepath].join('/'), file.path)\n end\n end\n\n File.chmod(0644, @bundle_filename)\n clean_up\n\n @bundle_filename\n end",
"def pack\n #Throw the postflight script into the Scripts directory\n safe_system(\"sudo #{INSTALL} -m 0755 postflight #{@working_tree['SCRIPT_D']}\")\n safe_system(\"sudo #{INSTALL} -m 0755 Welcome.txt #{@working_tree['RESOURCE_D']}\")\nend",
"def add_payload_of(fz,payloadx,of)\n\n\t# get file ext\n\text = @options[\"file\"].split(\".\").last\n\tnname = \"output_#{Time.now.to_i}_all\"\n\trand_file = \"./output/#{nname}.#{ext}\"\n\tFileUtils::copy_file(@options[\"file\"],rand_file)\n\n\tfz.each do |name|\n\n\t\tdocument = \"\"\n\t\t# Read in the XLSX and grab the document.xml\n\t\tZip::Archive.open(rand_file, Zip::CREATE) do |zipfile|\n\t\t\tzipfile.fopen(name) do |f|\n\t\t\t\tdocument = f.read # read entry content\n\t\t\tend\n\t\tend\n\n\t\tdocx_xml = payload(document,payloadx)\n\n\t\tZip::Archive.open(rand_file, Zip::CREATE) do |zipfile|\n\t\t\tzipfile.add_or_replace_buffer(name,\n\t\t\t\t\t\t\t\t\t docx_xml)\n\t\tend\n\tend\n\tputs \"|+| Created #{rand_file}\"\nend",
"def push_package!\n require 'packagecloud'\n pkg = Packagecloud::Package.new(file: package_file)\n client.put_package('duo-openvpn', pkg, distro_id)\n end",
"def pack(generate = false)\n self.class.template.pack(self, generate)\n end",
"def transfer!\n remote_path = remote_path_for(@package)\n\n files_to_transfer_for(@package) do |local_file, remote_file|\n Logger.info \"#{storage_name} started transferring '#{ local_file }'.\"\n\n File.open(File.join(local_path, local_file), 'r') do |file|\n connection.put_object(\n container, File.join(remote_path, remote_file), file\n )\n end\n end\n end",
"def add(filename, body)\n io = Zip::OutputStream.write_buffer do |zip|\n zip.put_next_entry filename\n zip.write body.respond_to?(:read) ? body.read : body\n end\n io.rewind\n io.set_encoding 'ASCII-8BIT'\n d = Zip::CentralDirectory.read_from_stream io\n\n e = d.entries.first\n payload_size = 30 + e.name.length + e.compressed_size\n\n io.rewind\n @data += io.read(payload_size)\n\n e.zipfile = nil\n @entries << e\n nil\n end",
"def add_gem_contents\n @tar_writer.add_file \"data.tar.gz\", 0644 do |inner|\n sio = @signer ? StringIO.new : nil\n Zlib::GzipWriter.wrap(sio || inner) do |os|\n\n Gem::Package::TarWriter.new os do |data_tar_writer|\n def data_tar_writer.metadata() @metadata end\n def data_tar_writer.metadata=(metadata) @metadata = metadata end\n\n yield data_tar_writer\n\n @metadata = data_tar_writer.metadata\n end\n end\n\n # if we have a signing key, then sign the data\n # digest and return the signature\n if @signer then\n digest = Gem::Security::OPT[:dgst_algo].digest sio.string\n @data_signature = @signer.sign digest\n inner.write sio.string\n end\n end\n\n self\n end",
"def packer_add\n {\n output: output || output_path.join(\"#{packer_name}.box\").to_s\n }\n end",
"def package(path, target)\n # Load manifest\n puts \"Load manifest...\"\n manifest = YAML::load_file(File.join(path, 'manifest.yml'))\n \n # Target directory for package files\n puts \"Target is: #{target}\"\n Dir.mkdir(target) if not File.exists?(target)\n \n # Package name\n package = \"#{manifest['name']}-#{manifest['version']}\"\n puts \"Package: #{package}\"\n \n # Tgz\n manifest['package'] = \"#{package}.tgz\"\n command = \"tar -czf #{package}.tgz --exclude pkg -C #{path} .\"\n puts \"Packing: #{command}\"\n system command\n \n # Move\n puts \"Finishing..\"\n FileUtils.mv(\"#{package}.tgz\", target)\n File.open(File.join(target, \"#{package}.yml\"), 'w') do |f|\n f.puts(manifest.to_yaml)\n f.close\n end\n \n puts \"Done.\"\nend",
"def extract_pack\n io = Zlib::GzipReader.new(DataDragon.data_pack_path.open)\n\n Gem::Package::TarReader.new(io) do |tar|\n tar.each do |tarfile|\n destination_file = (DataDragon.data_unpacked_path + tarfile.full_name)\n\n if tarfile.directory?\n destination_file.mkpath\n else\n destination_directory = destination_file.dirname\n destination_directory.mkpath unless destination_directory.directory?\n destination_file.write(tarfile.read)\n end\n end\n end\n end",
"def add_files(zip)\n ZipFileGenerator.new(@manifest.base_dir, zip).write\n end",
"def package_stemcell\n @stemcell_files << generate_image << generate_manifest\n # package up files\n package_files\n end",
"def create_arch_package(arch, arch_dir, src_dir, out_dir, pack_config)\n # Load manifest\n manifest = YAML.load_file(\"#{src_dir}/manifest.yaml\")\n manifest['arch'] = arch\n name = manifest['name']\n version = manifest['version']\n info \"Packing #{src_dir} (#{arch})\"\n\n npk = \"#{out_dir}/#{name}-#{arch}-#{version}.npk\"\n\n # TODO: do this seperatly\n # Remove existing containers\n Dir.glob(\"#{out_dir}/#{name}-#{arch}-*\").each { |c| FileUtils.rm(c, :verbose => false) }\n\n create_npk(src_dir, npk, manifest, arch_dir, pack_config)\n\n # Update/Create version list\n version_info_path = File.join(out_dir, \"packages-#{arch}.yaml\")\n update_version_list(version_info_path, name, version)\nend",
"def package!\n Packager.package!(self)\n Cleaner.remove_packaging(self)\n end",
"def package!\n return unless @model.compressor\n\n pipeline = Pipeline.new\n base_dir = File.dirname(@dump_path)\n dump_dir = File.basename(@dump_path)\n timestamp = Time.now.to_i.to_s[-5, 5]\n outfile = @dump_path + '-' + timestamp + '.tar'\n\n Logger.info(\n \"#{ database_name } started compressing and packaging:\\n\" +\n \" '#{ @dump_path }'\"\n )\n\n pipeline << \"#{ utility(:tar) } -cf - -C '#{ base_dir }' '#{ dump_dir }'\"\n @model.compressor.compress_with do |command, ext|\n pipeline << command\n outfile << ext\n end\n pipeline << \"cat > #{ outfile }\"\n\n pipeline.run\n if pipeline.success?\n Logger.info(\n \"#{ database_name } completed compressing and packaging:\\n\" +\n \" '#{ outfile }'\"\n )\n FileUtils.rm_rf(@dump_path)\n else\n raise Errors::Database::PipelineError,\n \"#{ database_name } Failed to create compressed dump package:\\n\" +\n \"'#{ outfile }'\\n\" +\n pipeline.error_messages\n end\n end",
"def upload_packages(packages)\n test_payload.set(:packages, packages)\n end",
"def pack_file(entry, outputter) # :yields action, name, stats:\n if outputter.is_a?(Archive::Tar::Minitar::Output)\n outputter = outputter.tar\n end\n\n stats = {}\n\n if entry.is_a?(Hash)\n name = entry[:name]\n entry.each { |kk, vv| stats[kk] = vv unless vv.nil? }\n else\n name = entry\n end\n\n name = name.sub(%r{\\./}, \"\")\n stat = File.stat(name)\n stats[:mode] ||= stat.mode\n stats[:mtime] ||= stat.mtime\n stats[:size] = stat.size\n\n if windows?\n stats[:uid] = nil\n stats[:gid] = nil\n else\n stats[:uid] ||= stat.uid\n stats[:gid] ||= stat.gid\n end\n\n if File.file?(name)\n outputter.add_file_simple(name, stats) do |os|\n stats[:current] = 0\n yield :file_start, name, stats if block_given?\n File.open(name, \"rb\") do |ff|\n until ff.eof?\n stats[:currinc] = os.write(ff.read(4096))\n stats[:current] += stats[:currinc]\n yield :file_progress, name, stats if block_given?\n end\n end\n yield :file_done, name, stats if block_given?\n end\n elsif dir?(name)\n yield :dir, name, stats if block_given?\n outputter.mkdir(name, stats)\n else\n raise \"Don't yet know how to pack this type of file.\"\n end\n end",
"def add_payload(name,payloadx)\n\tdocument = \"\"\n\n\t# Read in the XLSX and grab the document.xml\n\tZip::Archive.open(@options[\"file\"], Zip::CREATE) do |zipfile|\n\t\tzipfile.fopen(name) do |f|\n\t\t\tdocument = f.read # read entry content\n\t\tend\n\tend\n\t# get file ext\n\text = @options[\"file\"].split(\".\").last\n\tnname = \"output_#{Time.now.to_i}_#{name.gsub(\".\",\"_\").gsub(\"/\",\"_\")}\"\n\trand_file = \"./output/#{nname}.#{ext}\"\n\n\tdocx_xml = payload(document,payloadx)\n\n\tputs \"|+| Creating #{rand_file}\"\n\tFileUtils::copy_file(@options[\"file\"],rand_file)\n\tZip::Archive.open(rand_file, Zip::CREATE) do |zipfile|\n\t\tzipfile.add_or_replace_buffer(name,\n\t\t\t\t\t\t\t\t docx_xml)\n\tend\nend",
"def package_stemcell\n @stemcell_files << generate_image << generate_manifest << stemcell_files\n # package up files\n package_files\n end",
"def transfer!\n remote_path = remote_path_for(@package)\n FileUtils.mkdir_p(remote_path)\n\n files_to_transfer_for(@package) do |local_file, remote_file|\n Logger.info \"#{storage_name} started transferring '#{ local_file }'.\"\n\n src_path = File.join(local_path, local_file)\n dst_path = File.join(remote_path, remote_file)\n FileUtils.send(transfer_method, src_path, dst_path)\n end\n end",
"def call\n INSTALL_DIRS.each do |dir|\n FileUtils.mkdir_p Karafka.root.join(dir)\n end\n\n INSTALL_FILES_MAP.each do |source, target|\n target = Karafka.root.join(target)\n next if File.exist?(target)\n\n source = Karafka.core_root.join(\"templates/#{source}\")\n FileUtils.cp_r(source, target)\n end\n end",
"def build_skeleton\n raise \"File not valid\"\n file = ZipFile.new(path)\n file.mkdir \"META-INF\"\n file.mkdir \"OEBPS\"\n\n container_xml = <<-END.strip_heredoc\n <?xml version=\"1.0\"?>\n <container version=\"1.0\" xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">\n <rootfiles>\n <rootfile full-path=\"OEBPS/content.opf\" media-type=\"application/oebps-package+xml\"/>\n </rootfiles>\n </container>\n END\n\n content_opf = <<-END.strip_heredoc\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <package xmlns=\"http://www.idpf.org/2007/opf\" unique-identifier=\"BookID\" version=\"2.0\">\n <metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:opf=\"http://www.idpf.org/2007/opf\">\n </metadata>\n <manifest></manifest>\n <spine toc=\"ncx\"></spine>\n </package>\n END\n\n file.write(\"META-INF/container.xml\", container_xml)\n file.write(\"OEBPS/content.opf\", content_opf)\n file\n end",
"def assemble_tgz\n banner \"Assembling #{TAR}...\"\n rm_and_mkdir(DIR)\n \n # gem\n run(\"cp\", [\"-r\", \"#{File.dirname(__FILE__)}/../../lib\", GEM])\n # data\n mkdir(DATA)\n copy = []\n copy << \"Telfile\"\n copy += Dir[\"files*\"]\n copy.sort.each { |i| run(\"cp\", [\"-r\", i, DATA]) }\n # config.sh\n File.open(\"#{DIR}/config\", \"w\") do |f|\n f.puts(\"CONFIG_HOST='#{@options[:host]}'\") \n f.puts(\"CONFIG_RUBY='#{@config.ruby}'\")\n f.puts(\"CONFIG_RUBYGEMS='#{RUBYGEMS}'\") \n end\n # keys\n ssh_key = \"#{ENV[\"HOME\"]}/.ssh/#{PUBKEY}\"\n if File.exists?(ssh_key)\n run(\"cp\", [ssh_key, DIR])\n end\n \n Dir.chdir(File.dirname(DIR)) do\n run(\"tar\", [\"cfpz\", TAR, File.basename(DIR)])\n end\n end",
"def addPack(pack)\n\t\tpack.each do |card|\n\t\t\t@cards[card].addCopy\n\t\tend\n\tend",
"def package\n unless @package\n @package = package_resource_class.new(download_dest, run_context)\n tailor_package_to_platform\n end\n @package\n end",
"def pack_command(appx_file)\n \"makeappx.exe pack /d \\\"#{windows_safe_path(project.install_dir)}\\\" /o /p #{appx_file}\"\n end",
"def archive_package(name)\n destination_dir = File.join(@project.full_path, \"output\", name)\n FileUtils.mkdir_p(destination_dir)\n destination_file = File.join(destination_dir, \"#{name}.tar.xz\")\n\n archive_single(File.join(\"src\", name), destination_file)\n end",
"def pack_box\n\t\t# @packages = ActiveShipping::Package.new((WEIGHT * 16), DIMENSIONS, UNITS)\n\t\t@packages = ActiveShipping::Package.new((WEIGHT * 16), DIMENSIONS, UNITS)\n\tend",
"def transfer!\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n dest = File.join('/', remote_path, filename)\n Logger.info \"Storing '#{ dest }'...\"\n\n File.open(src, 'r') do |file|\n @uploader = ChunkedUploader.new(client, file)\n with_retries do\n @uploader.upload(1024**2 * chunk_size)\n end\n end\n\n with_retries do\n @uploader.finish(dest)\n end\n end\n rescue => err\n raise Error.wrap(err, \"Upload Failed!\")\n end",
"def extract_files\n while file = @package_file.next_header\n if file.pathname == \"control.tar.gz\"\n control_tar_gz = Archive.read_open_memory(@package_file.read_data)\n while control_entry = control_tar_gz.next_header\n case control_entry.pathname\n when \"./control\"\n @control_file_contents = control_tar_gz.read_data\n when \"./preinst\"\n @preinst_contents = control_tar_gz.read_data\n when \"./prerm\"\n @prerm_contents = control_tar_gz.read_data\n when \"./postinst\"\n @postinst_contents = control_tar_gz.read_data\n when \"./postrm\"\n @postrm_contents = control_tar_gz.read_data\n end\n end\n end\n if file.pathname == \"data.tar.gz\"\n data_tar_gz = Archive.read_open_memory(@package_file.read_data)\n while data_entry = data_tar_gz.next_header\n # Skip dirs; they're listed with a / as the last character\n @filelist << data_entry.pathname.sub(/^\\./, \"\") unless data_entry.pathname =~ /\\/$/\n end\n end\n end\n end",
"def add_files(*files)\n Rails.logger.info \"Adding #{files.map(&:upload_file_name).join(', ')} to bundle #{self.bundle_type}:#{self.id} in #{self.study.name}\"\n files.each do |file|\n file.update!(study_file_bundle_id: self.id)\n end\n additional_files = StudyFileBundle.generate_file_list(*files)\n self.original_file_list += additional_files\n self.save!\n Rails.logger.info \"File addition to bundle #{self.bundle_type}:#{self.id} successful\"\n end",
"def package_files\n Dir.mktmpdir {|tmpdir|\n @stemcell_files.flatten.each {|file| FileUtils.cp(file, tmpdir) if file && File.exists?(file) } # only copy files that are not nil\n Dir.chdir(tmpdir) do\n @logger.info(\"Package #@stemcell_files to #@target ...\")\n sh \"tar -czf #@target *\", {:on_error => \"unable to package #@stemcell_files into a stemcell\"}\n end\n }\n @target\n end",
"def package_files\n Dir.mktmpdir {|tmpdir|\n @stemcell_files.flatten.each {|file| FileUtils.cp(file, tmpdir) if file && File.exists?(file) } # only copy files that are not nil\n Dir.chdir(tmpdir) do\n @logger.info(\"Package #@stemcell_files to #@target ...\")\n sh \"tar -czf #@target *\", {:on_error => \"unable to package #@stemcell_files into a stemcell\"}\n end\n }\n @target\n end",
"def add_package(opts = {})\n shipment_root << PackageBuilder.new('Package', opts).to_xml\n end",
"def add_extra_files(*files); end",
"def install(pkg)\n package pkg do\n action :install\n end\nend",
"def tarball\n tarfile = StringIO.new(\"\")\n Gem::Package::TarWriter.new(tarfile) do |tar|\n path = \"#{staging_dir}/#{packager.package_name}\"\n name = packager.package_name\n mode = File.stat(path).mode\n\n tar.add_file(name, mode) do |tf|\n File.open(path, \"rb\") do |file|\n tf.write(file.read)\n end\n end\n end\n\n tarfile.rewind\n tarfile\n end",
"def extra_package_file(val)\n @extra_package_files << val\n end",
"def add_file file\n if not File.file? file\n raise ArgumentError\n else\n @files.push file\n puts \"#{File.basename file} added to package #{@name}\" if @verbose\n end\n end",
"def generate_packaging_artifacts(workdir, name, binding, project)\n [\"pkginfo\", \"depend\", \"preinstall\", \"preremove\", \"postinstall\", \"proto\"].each do |template|\n target_dir = File.join(workdir, 'packaging')\n FileUtils.mkdir_p(target_dir)\n erb_file(File.join(VANAGON_ROOT, \"resources/solaris/10/#{template}.erb\"), File.join(target_dir, template), false, { :binding => binding })\n end\n end",
"def send_files(name, files)\n if @request.env[\"HTTP_MOD_ZIP_ENABLED\"]\n filenames = []\n files.each do |file|\n path = ::File.expand_path(file.path)\n filename = file.name\n while filenames.include? filename\n extname = ::File.extname(filename)\n basename = ::File.basename(filename, extname)\n if basename =~ /-(\\d+)$/\n counter = $1.to_i + 1\n else\n counter = 2\n end\n filename = \"#{basename}-#{counter}#{extname}\"\n end\n filenames << filename\n if file.respond_to?(:checksum)\n puts(\"#{file.checksum(:pkzip)} #{::File.size(path)} #{path} #{filename}\")\n else\n puts(\"#{Harbor::File.new(path).checksum(:pkzip)} #{::File.size(path)} #{path} #{filename}\")\n end\n end\n headers[\"X-Archive-Files\"] = \"zip\"\n self.content_type = \"application/zip\"\n @headers[\"Content-Disposition\"] = \"attachment; filename=\\\"#{escape_filename_for_http_header(name)}\\\"\"\n else\n @io = ZippedIO.new(files)\n self.size = @io.size\n self.content_type = \"application/zip\"\n @headers[\"Content-Disposition\"] = \"attachment; filename=\\\"#{escape_filename_for_http_header(name)}\\\"\"\n end\n end",
"def create_packages\n gem 'fpm', '= 0.4.3'\n require 'fpm'\n\n @package.packagedata.each do |type, data|\n next unless data\n @tmpdir = Dir.mktmpdir(\"mcollective_packager\")\n @workingdir = File.join(@tmpdir, @libdir)\n FileUtils.mkdir_p @workingdir\n prepare_tmpdirs data\n create_package type, data\n cleanup_tmpdirs\n end\n end",
"def build_work(work_files)\n work_files.each do |file|\n next if file.blank?\n if file.end_with? '-metadata.json'\n @work_metadata = JSON.parse(File.read(file))\n work_metadata[:packaged_by_package_name] = dip_id\n write_json(work_metadata)\n else\n FileUtils.cp_r(file, src)\n end\n end\n write_dc\n end",
"def AddPackage(doc, file, desc)\n\tfiles = NameTree.Create(doc.GetSDFDoc, \"EmbeddedFiles\")\n\tfs = FileSpec.Create(doc.GetSDFDoc, file, true)\n\tfiles.Put(file, file.length, fs.GetSDFObj)\n\tfs.SetDesc(desc)\n\t\n\tcollection = doc.GetRoot.FindObj(\"Collection\")\n\tif collection.nil?\n\t\tcollection = doc.GetRoot.PutDict(\"Collection\")\n\tend\n\t\n\t# You could here manipulate any entry in the Collection dictionary. \n\t# For example, the following line sets the tile mode for initial view mode\n\t# Please refer to section '2.3.5 Collections' in PDF Reference for details.\n\tcollection.PutName(\"View\", \"T\")\nend",
"def packaging_task(dir_path, pkg_name)\n chdir dir_path do\n sh \"#{ZIP} #{ZIP_ARGS} -r -o ../#{pkg_name} * **/*\"\n end\nend",
"def inject_package(hash, info, package)\n arch = info[\"Architecture\"]\n arch = arch == \"all\" ? all_map : [arch]\n arch.map do |arch|\n package_file_name = File.join(\n package_root, package_bucket, origin,\n dist, component, \"binary-#{arch}\",\n File.basename(package)\n )\n hash.deep_merge!(\n \"apt\" => {\n origin => {\n dist => {\n \"components\" => {\n component => {\n \"binary-#{arch}\" => {\n info[\"Package\"] => {\n info[\"Version\"] => info.merge!(\n \"Filename\" => package_file_name,\n \"Size\" => File.size(package),\n ),\n },\n },\n \"binary-i386\" => {},\n },\n },\n },\n },\n },\n )\n File.join(\"apt\", origin, package_file_name)\n end\n end",
"def pack(directory, name=nil)\n tmp_file = Tempfile.new(name || File.basename(directory))\n file_path = \"#{tmp_file.path}.zip\"\n tmp_file.delete\n entries = Hash[\n Dir.glob(File.join(directory, '**', '{*,.*}')).map do |path|\n next if path.end_with?('.')\n [path.sub(%r{#{Regexp.escape(directory)}/?}, ''), path]\n end\n ]\n Zip::File.open(file_path, Zip::File::CREATE) do |zipfile|\n entries.keys.sort.each do |entry|\n path = entries[entry]\n if(File.directory?(path))\n zipfile.mkdir(entry.dup)\n else\n zipfile.add(entry, path)\n end\n end\n end\n file = File.open(file_path, 'rb')\n file\n end",
"def create_package(sub_path)\n package = Tempfile.new(@commit_hash)\n @logger.info \"Creating #{package.path}\"\n Dir.chdir(@source_location + '/' + sub_path) do\n # add a commit_hash file whose contents represent the key for this package\n IO.write('commit_hash', @commit_hash)\n RakeUtils.system \"tar -zcf #{package.path} *\"\n end\n @logger.info 'Created'\n package\n end",
"def transfer!\n backup = connection.backups.create\n Logger.info \"Created backup [#{backup.id}]\"\n\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n metadata = {}\n\n [:sha512sum, :sha1sum, :cksum].each do |cmd|\n if !`which #{cmd}`.empty?\n metadata[cmd] = %x|#{cmd} #{src}|.split.first\n break\n end\n end\n\n metadata[:size] = %x|ls -sh #{src}|.split.first\n\n backup_file = backup.files.create(filename: src, metadata: metadata)\n Logger.info \"Created backup file [#{backup_file.id}]\"\n\n Logger.info \"EngineYard performing upload of '#{File.join(src)}' to '#{backup_file.upload_url}' with metadata '#{metadata.inspect}'.\"\n\n backup_file.upload(file: src)\n end\n Logger.info \"Finished uploading files for backup [#{backup.id}]\"\n\n backup.finish!\n\n Logger.info \"Finished backup [#{backup.id}]\"\n end",
"def pack_template\n selfclass.pack_template\n end",
"def install_custom!\n package package_name do\n source new_resource.source.to_s\n checksum new_resource.checksum unless new_resource.checksum.nil?\n end\n end",
"def zipIt\r\n puts \"Creating EPUB package:\"\r\n STDOUT.flush\r\n path = @dirs[:tmp]\r\n FileUtils.rm @epub, :force=>true\r\n Zip::ZipFile.open(@epub, 'w') do |zipfile|\r\n progress = ProgressBar.new(\"Compressing\", Dir[\"#{path}/**/**\"].length)\r\n Dir[\"#{path}/**/**\"].each do |file|\r\n zipfile.add(file.sub(path+'/', ''), file)\r\n progress.inc\r\n end\r\n progress.finish\r\n puts ''\r\n end\r\n end",
"def generate_package\n if @language_package_service.autograded?\n new_package = @language_package_service.generate_package(@question.attachment)\n @question.file = new_package if new_package.present?\n else\n templates = @language_package_service.submission_templates\n @question.imported_attachment = nil\n @question.import_job_id = nil\n @question.non_autograded_template_files = templates.map do |template|\n Course::Assessment::Question::ProgrammingTemplateFile.new(template)\n end\n end\n end",
"def add(*files)\n # due to the multi passing of splat args, we can get Array-in-Array situations here\n files.flatten.each do |fn|\n @files.push(fn)\n if ! File.exists?(fn)\n next if self.class.skipmissing\n raise ArgumentError, \"file #{fn} does not exist\"\n end\n begin\n data = YAML.load(File.open(fn))\n if ! data.instance_of?(Hash)\n raise ArgumentError, \"file #{fn} does not contain a Hash\"\n end\n @cfg.deep_merge!(data.deep_symbolize_keys).deep_symbolize_keys\n rescue\n if ! self.class.skipbad\n raise\n end\n end\n end\n\n # resolve templates\n if self.class.templates\n resolve_templates\n end\n end",
"def packaging_task(dir_path, pkg_name)\n chdir dir_path do\n sh \"#{ZIP} -9 -r -o ../#{pkg_name} * **/*\"\n end\nend",
"def create\n @file_package = FilePackage.new(file_package_params)\n respond_to do |format|\n if @file_package.save\n @file_to_update_file_package = FileToUpdateFilePackage.new(file_package_id: @file_package.id)\n @file_to_update_file_package.save\n format.html { redirect_to @file_package, notice: 'File package was successfully created.' }\n format.json { render :show, status: :created, location: @file_package }\n else\n format.html { render :new }\n format.json { render json: @file_package.errors, status: :unprocessable_entity }\n end\n end\n end",
"def package_tarballs( mods_dirs )\n pwd = Dir.pwd\n mods_dirs.each do |module_dir|\n next unless File.directory? module_dir\n FileUtils.chdir module_dir, :verbose => (verbose?)\n\n cmd = \"puppet module build --render-as=json\"\n puts cmd if verbose?\n tgz = `#{cmd}`.split(\"\\n\").last.gsub('\"','')\n puts \"--[tgz] built module archive: #{tgz}\" if verbose?\n FileUtils.cp tgz, @tars_dir, :verbose => verbose?\n end\n FileUtils.chdir pwd, :verbose => verbose?\n end",
"def add_signatures\n if @data_signature then\n @tar_writer.add_file 'data.tar.gz.sig', 0644 do |io|\n io.write @data_signature\n end\n end\n\n if @meta_signature then\n @tar_writer.add_file 'metadata.gz.sig', 0644 do |io|\n io.write @meta_signature\n end\n end\n end",
"def create\n # Save file\n file_path = DataFile.store(params[:upload])\n unless file_path\n @package.errors.add :file, 'upload failed, please try again'\n render :action => \"new\"\n return\n end\n @package.file_path = file_path\n\n respond_to do |format|\n if @package.save\n format.html { redirect_to(@package, :notice => 'Package was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def install\n safe_system \"pax --insecure -rz -f Payload.gz -s ',./bin,#{bin},' -s ',./man,#{man},' -s ',./lib,#{lib},' -s ',./license_gpl_pdftk,#{prefix}/LICENSE,' -s ',./,#{prefix}/README/,'\"\n end",
"def zipfile; end",
"def add_file_from_files(files, format)\n return false if files == []\n @@minified_files.concat files\n # return false if files.collect(&:error) != []\n contents = []\n\n key = files.join(':') + \":#{format}\"\n return @@cached_files[key] if @@cached_files[key]\n\n files.each do |file|\n # TODO: We need a better way of getting the compiled contents of a file.\n contents << parse_file(file, format)\n\n if format == :js\n contents << \";\"\n end\n end\n contents = contents.join(\"\\n\\n\\n\\n\")\n if format == :css\n engine = Sass::Engine.new(contents, syntax: :scss, style: :compressed)\n contents = engine.render\n elsif format == :js\n contents = Uglifier.compile(contents, mangle: false)\n end\n filename = Digest::MD5.hexdigest(contents)\n assets_directory = \"#{output_directory}/assets\"\n Dir.mkdir(assets_directory) unless Dir.exist?(assets_directory)\n file = add_file(\"assets/#{filename}.#{format}\", contents, files)\n # file.source_files = files # TODO\n\n @@cached_files[key] = file\n\n file\n end",
"def zip_contents; end",
"def pack\n puts heading(\"Packing Bugsnag packages\")\n\n BUGSNAG_PACKAGES.each do |package|\n path = \"#{ROOT}/packages/#{package}\"\n flags = DEBUG ? \"--verbose\" : \"--quiet\"\n\n success = system(\"npm pack #{flags} #{path}/\")\n\n raise \"Failed to pack #{package}\" unless success\n end\n\n # Strip the version suffix from the packages\n Dir[\"#{FileUtils.pwd}/bugsnag-*.tgz\"].each do |package|\n package_with_no_version = package.gsub(/-\\d+\\.\\d+\\.\\d+.*(?=\\.tgz)/, '')\n File.rename(package, package_with_no_version)\n end\nend",
"def add_subpackage pack\n if not pack.is_a? Package\n raise TypeError\n end\n if pack.name =~ JTools::PACKAGE_NAME\n @subpackages[pack.name] = pack # map name to package object\n else puts \"Invalid pacakge name '#{pack.name}'. Skipping.\"\n end\n end",
"def build_package\n # Force timestamp to be initialized before anything else. This gives us a\n # stable timestamp for the process.\n timestamp\n # Prepare the work area: copy files from root_path to work_path based on\n # the resolved Manifest.txt.\n prepare_work_area\n # Anything that has been modified locally needs to be reset.\n restore_modified_files\n # Save both the final release metadata and the in-package release metadata.\n save_release_metadata\n # Vendor the dependencies for the package.\n vendor_dependencies\n # Request that supporting plug-ins build the package.\n request_build_package\n end",
"def install!\n refresh_file_accessors\n prepare_pod_groups\n add_source_files_references\n add_frameworks_bundles\n add_vendored_libraries\n add_resources\n add_developer_files unless sandbox.development_pods.empty?\n link_headers\n end",
"def each(&block)\n fake_stream = Zipline::FakeStream.new(&block)\n Zipline::OutputStream.open(fake_stream) do |zip|\n @package.parts.each do |name, part|\n begin\n if part.respond_to?(:stream) && part.respond_to?(:size)\n zip.put_next_entry name, part.size\n part.stream zip\n else\n data = @package.marshal_part(name)\n zip.put_next_entry name, data.size\n zip << data\n end\n rescue => e\n raise e unless @ignore_part_exceptions\n end\n end\n end\n end",
"def compress(entries)\n puts \"\\nadding the following entries into zip package\"\n puts \"#{ entries.map{ |x| x.name }.join(\"\\n\")}\"\n buffer = Zip::File.add_buffer do |zio|\n entries.each do |file|\n if file.is_a? FileEntry\n zio.add(file.path == nil ? file.name : file.path, file.name)\n else\n zio.get_output_stream(file.name) { |os| os.write file.buffer.string }\n end\n end\n end\n end",
"def extra_package_file(val)\n extra_package_files << val\n extra_package_files.dup\n end",
"def extra_package_file(val)\n extra_package_files << val\n extra_package_files.dup\n end",
"def copy_include_files\n include_directory = Pathname.new(@env[\"package.directory\"]).join(\"include\")\n\n @env[\"package.files\"].each do |from, dest|\n # We place the file in the include directory\n to = include_directory.join(dest)\n\n @env[:ui].info I18n.t(\"vagrant.actions.general.package.packaging\", :file => from)\n FileUtils.mkdir_p(to.parent)\n\n # Copy direcotry contents recursively.\n if File.directory?(from)\n FileUtils.cp_r(Dir.glob(from), to.parent, :preserve => true)\n else\n FileUtils.cp(from, to, :preserve => true)\n end\n end\n end",
"def pack\n packed_count = 0\n count.times do |i|\n @file.pos = @record_offset + @record_size*i\n data = @file.read(@record_size)\n unless data[0, 1]=='*'\n if i!=packed_count\n @file.pos = @record_offset + @record_size*packed_count\n @file.write data\n end\n packed_count += 1\n end\n end\n\n file_end = @record_offset + @record_size*packed_count\n @file.pos = file_end\n @file.write \"\\x1a\"\n @file.truncate file_end+1\n\n self.count = packed_count\n update_header\n end",
"def packing_started\n end",
"def call\n zip_content!\n\n swatches_path\n end",
"def make_bag\n move_files_to_bag\n bag.write_chipmunk_info(common_tags.merge(audio_metadata))\n bag.download_metadata\n bag.manifest!\n end",
"def pack(input_path, output_path, algorithm)\n\n\t\t# open input, convert to binary\n\t\tin_file = File.read(input_path)\n\t\tin_file.each_line do |line|\n\t\t\t@pre << line.to_binary(@pre_size)\n\t\tend\n\n\t\t# run compression algorithm\n\t\tcase algorithm\n\t\t\twhen :rle\n\t\t\t\t@post = rle_pack(@pre, true)\n\t\t\twhen :lz78\n\t\t\t\t@post = lz78_pack(@pre)\n\t\t\twhen :huff\n\t\t\t\t@post = huff_pack(@pre)\n\t\tend\n\n\t\t# open output, write binary\n\t\tout_file = File.open(output_path, 'wb')\n\t\[email protected] do |byte|\n\t\t\tout_file.write byte\n\t\tend\n\n\tend",
"def call(params)\n res = client.post('/api/rest/v1/bundles/zip.json', params.to_h.compact)\n\n BrickFTP::Types::BundleZip.new(**res.symbolize_keys)\n end",
"def generate!(path)\n if File.exists? path\n raise IOError, \"Destination '#{path}' already exists!\"\n end\n\n raise InvalidPackageError unless valid?\n\n archive = Zip::File.open(path, Zip::File::CREATE)\n\n archive.get_output_stream('definition.ald') do |s|\n s << definition.to_s\n end\n\n files.each do |path, src|\n archive.add(path, src)\n end\n\n Package.new(file)\n end",
"def create_packages\n begin\n puts \"Building module for #{@package_name} plugin.\"\n\n @tmpdir = Dir.mktmpdir('mcollective_packager')\n make_module\n run_build\n move_package\n\n puts \"Completed building module for #{@package_name} plugin.\"\n ensure\n if @keep_artifacts\n puts 'Keeping build artifacts'\n puts \"Build artifacts saved - #{@tmpdir}\"\n else\n cleanup_tmpdirs\n end\n end\n end",
"def targz\n files = procedure.get_adapter_configuration.attributes['files']\n if files.is_a?(Array)\n puts system_messages[:archiving]; puts system_messages[:compressing]\n %x{ tar -czf #{File.join(tmp_path, compressed_file)} #{files.map{|f| f.gsub(' ', '\\ ')}.join(' ')} }\n elsif files.is_a?(String)\n puts system_messages[:archiving]; puts system_messages[:compressing]\n %x{ tar -czf #{File.join(tmp_path, compressed_file)} #{files.gsub(' ', '\\ ')} }\n end\n end",
"def each\n files.each do |f|\n content = File.read(path(f))\n content = compress(content) if @app.compress_bundles\n # Include a new line to prevent weirdness at file boundaries\n yield(\"#{content}\\n\")\n end\n end",
"def generate_pkg_contents\n shellout!(\"pkgsend generate #{source_dir} | pkgfmt > #{pkg_manifest_file}.1\")\n shellout!(\"pkgmogrify -DARCH=`uname -p` #{pkg_manifest_file}.1 #{pkg_metadata_file} #{transform_file} | pkgfmt > #{pkg_manifest_file}.2\")\n end",
"def unpack(args)\n full_path, file = args[:full_path], args[:file]\n \n # Is unpack activated?\n if self.config[:unpack][:active]\n self.files = File.directory?(full_path) ? Unpack.runner!(full_path, self.config[:unpack]) : []\n else\n self.files = []\n end\n \n if files.any?\n self.growl(self.messages[:unpack][:title], file, :unpack); return 5\n else\n return 6\n end\n end",
"def make_file_package(path, content, options = {})\n path.dirname.mkpath\n\n path.open('w') do |f|\n if options.any?\n f.puts stringify_hash_keys(options).to_yaml\n f.puts '---'\n end\n\n f.puts content\n end\nend",
"def tar___( directory, filename )\r\n raise StandardError, \"Under investigation\"\r\n got = @ndev.rpc.file_archive( :destination => filename, :source => directory )\r\n end",
"def package_build!(tmp_dir)\n # copying template files\n FileUtils.cp_r(File.expand_path(File.join(File.dirname(__FILE__), \"debian\")), tmp_dir)\n Dir.chdir(tmp_dir) do\n ppath = File.join(\"..\", self.package_filename)\n File.delete(ppath) if File.exists? ppath\n deb_files = File.join(\"..\", \"#{@package.name}_#{@package.version}*\")\n res = run_dpkg tmp_dir, @package.gpg_key \n if res or File.exists? ppath \n # mv can raise\n FileUtils.mv(Dir.glob(deb_files) , @dest_dir, :force => true)\n else\n ActiveRecord::Base.logger.debug \"Dpkg-buildpackage failed\"\n raise \"dpkg-buildpackage failed\"\n end\n end\n end"
] | [
"0.6717095",
"0.6685833",
"0.63863534",
"0.62842476",
"0.6281442",
"0.6254959",
"0.61852974",
"0.6153507",
"0.6123465",
"0.6112158",
"0.60896695",
"0.6053871",
"0.5985677",
"0.5981764",
"0.59525067",
"0.59082395",
"0.5865977",
"0.585019",
"0.5844643",
"0.5834223",
"0.58309823",
"0.5804153",
"0.5798152",
"0.57906085",
"0.57864076",
"0.57732147",
"0.5735017",
"0.57277673",
"0.57236266",
"0.57182825",
"0.56517595",
"0.5648332",
"0.56292",
"0.5620942",
"0.5611682",
"0.5603984",
"0.5594653",
"0.55906117",
"0.5577913",
"0.5563016",
"0.5541251",
"0.55317783",
"0.5528789",
"0.5526156",
"0.5522078",
"0.5522078",
"0.5519991",
"0.5518056",
"0.5515383",
"0.55081785",
"0.54846096",
"0.54796654",
"0.5478987",
"0.5468351",
"0.54632205",
"0.5435652",
"0.54279566",
"0.5425416",
"0.54204726",
"0.54200006",
"0.54171896",
"0.5414214",
"0.5411802",
"0.54096115",
"0.5406004",
"0.53965396",
"0.5382555",
"0.537753",
"0.5361223",
"0.5357702",
"0.53555685",
"0.53516626",
"0.5344935",
"0.5339189",
"0.5337458",
"0.5334446",
"0.533026",
"0.5315425",
"0.53131294",
"0.52969384",
"0.529508",
"0.5294489",
"0.52901155",
"0.52901155",
"0.5272596",
"0.52604645",
"0.5256509",
"0.5252335",
"0.52519375",
"0.5245237",
"0.5239456",
"0.52377385",
"0.52367467",
"0.52338463",
"0.5231488",
"0.5221545",
"0.5218387",
"0.52146685",
"0.5211778",
"0.5204369"
] | 0.5878857 | 16 |
GET /generations/1 GET /generations/1.json | def show
@generation = Generation.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @generations = Generation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @generations }\n end\n end",
"def show\n @generator = Generator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @generator }\n end\n end",
"def index\n @generations = Generation.all\n end",
"def show\n @generation = Generation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @generation }\n end\n end",
"def show\n @gen = Gen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gen }\n end\n end",
"def new\n @generation = Generation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generation }\n end\n end",
"def getgenerate\n @api.request 'getgenerate'\n end",
"def new\n @generator = Generator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator }\n end\n end",
"def new\n @gen = Gen.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gen }\n end\n end",
"def index\n @generator = Generator.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @generator }\n end\n end",
"def getgenerate\n request :getgenerate\n end",
"def generation\n @gapi[\"generation\"]\n end",
"def show\n @generator_info = GeneratorInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @generator_info }\n end\n end",
"def index\n @generes = Genere.all\n end",
"def get_generation(n)\n\t\treturn @generations[n]\n\tend",
"def new\n @small_generator = SmallGenerator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @small_generator }\n end\n end",
"def new\n @generator_info = GeneratorInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator_info }\n end\n end",
"def create\n @gen = Gen.new(params[:gen])\n\n respond_to do |format|\n if @gen.save\n format.html { redirect_to @gen, notice: 'Gen was successfully created.' }\n format.json { render json: @gen, status: :created, location: @gen }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def render_generals\n render json: GeneralsSerializer.new(@general_data).to_serialized_json\n end",
"def create_generations\n @generations.each do |g|\n create_generation(g) unless Generation.find_by(name: g['name'])\n end\n end",
"def show\n @generator = Generator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def create\n @generation = Generation.new(generation_params)\n\n respond_to do |format|\n if @generation.save\n format.html { redirect_to [:admin, @generation], notice: 'Generation was successfully created.' }\n format.json { render json: @generation, status: :created, location: @generation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @generation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @generation = Generation.new(generation_params)\n\n respond_to do |format|\n if @generation.save\n format.html { redirect_to ['admin', @generation], notice: 'Generación Creada' }\n format.json { render :show, status: :created, location: @generation }\n else\n format.html { render :new }\n format.json { render json: @generation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_genere\n @genere = Genere.find(params[:id])\n end",
"def get_generation\n @generation\n end",
"def show\n @genotype = Genotype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @genotype }\n end\n end",
"def show\n @generators = Generator.where(id: params[:id], user_id: current_user.id )\n end",
"def set_genero\n @genero = Genero.find(params[:id])\n end",
"def set_genero\n @genero = Genero.find(params[:id])\n end",
"def create\n @generator = Generator.new(generator_params)\n\n respond_to do |format|\n if @generator.save\n format.html { redirect_to @generator, notice: 'Generator was successfully created.' }\n format.json { render :show, status: :created, location: @generator }\n else\n format.html { render :new }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @generation = Generation.find(params[:id])\n @generation.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_generations_url }\n format.json { head :no_content }\n end\n end",
"def print_generations\n\t\[email protected]_with_index do | gen, n |\n\t\t\tputs n.to_s + \" - \" + gen.to_s\n\t\tend\n\tend",
"def set_generation\n @generation = Generation.find(params[:id])\n end",
"def get_genres(options = {})\n object_from_response(GogoKit::PagedResource,\n GogoKit::CategoriesRepresenter,\n :get,\n get_root.links['viagogo:genres'].href,\n options)\n end",
"def create\n @generator = Generator.new(params[:generator])\n \n respond_to do |format|\n if @generator.save\n format.html { redirect_to admin_generator_path(@generator.id), notice: 'Generator was successfully created.' }\n format.json { render json: @generator, status: :created, location: @generator }\n else\n format.html { render action: \"new\" }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @genotype = Genotype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @genotype }\n end\n end",
"def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :guid => HttpClient::Preconditions.assert_class_or_nil('guid', HttpClient::Helper.to_uuid(opts.delete(:guid)), String),\n :key => HttpClient::Preconditions.assert_class_or_nil('key', opts.delete(:key), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/generators\").with_query(query).get.map { |hash| Apidoc::Models::Generator.new(hash) }\n end",
"def show\n @opportunity_generator = OpportunityGenerator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @opportunity_generator }\n end\n end",
"def create\n @genere = Genere.new(genere_params)\n\n respond_to do |format|\n if @genere.save\n format.html { redirect_to @genere, notice: 'Genere was successfully created.' }\n format.json { render :show, status: :created, location: @genere }\n else\n format.html { render :new }\n format.json { render json: @genere.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n format.html {render json: @gig, status: :ok}\n format.json { render json: @gig, status: :ok }\n end\n end",
"def generate\n generations = 0\n loop do\n print\n sleep(0.5)\n newGeneration\n generations += 1\n p \"Number of generations: #{generations} [Ctrl-C to exit]\"\n end\n end",
"def destroy\n @gen = Gen.find(params[:id])\n @gen.destroy\n\n respond_to do |format|\n format.html { redirect_to gens_url }\n format.json { head :no_content }\n end\n end",
"def index\n @creations = Creation.where(user_id: params[:user_id])\n\n render json: @creations\n end",
"def index\n @genotypes = Genotype.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @genotypes }\n end\n end",
"def new\n @gig_request = GigRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig_request }\n end\n end",
"def show\n @gpath = Gpath.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gpath }\n end\n end",
"def index\n @marco_generals = MarcoGeneral.all\n end",
"def index\n @generators = Generator.all \n\n \n \n end",
"def show\n @gram = Gram.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gram }\n end\n end",
"def destroy\n @generation.destroy\n respond_to do |format|\n format.html { redirect_to generations_my_url, notice: 'Сгенерированные варианты были успешно удалены.' }\n format.json { head :no_content }\n end\n end",
"def index\n\t\t@genres = Genre.all\n\tend",
"def is_generations?(); @type == GRT_GENERATIONS; end",
"def set_generator\n @generator = Generator.find(params[:id])\n end",
"def index\n respond_with Genre.all\n end",
"def show\n @gig_request = GigRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gig_request }\n end\n end",
"def show\n @program_genre = ProgramGenre.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @program_genre }\n end\n end",
"def new\n @gpath = Gpath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gpath }\n end\n end",
"def new\n @opportunity_generator = OpportunityGenerator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @opportunity_generator }\n end\n end",
"def index\n @genres = Genre.all\n end",
"def index\n @genres = Genre.all\n end",
"def show\n @grm_grappt = GrmGrappt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @grm_grappt }\n end\n end",
"def new\n @go = Go.new\n code = RandomAlphaGenerator.generate\n while Go.find_by_code(code)\n code = RandomAlphaGenerator.generate\n end\n @go.code = code\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @go }\n end\n end",
"def new\n @gram = current_user.grams.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gram }\n end\n end",
"def create\n @small_generator = SmallGenerator.new(params[:small_generator])\n\n respond_to do |format|\n if @small_generator.save\n format.html { redirect_to @small_generator, notice: 'Small generator was successfully created.' }\n format.json { render json: @small_generator, status: :created, location: @small_generator }\n else\n format.html { render action: \"new\" }\n format.json { render json: @small_generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @genre_type = GenreType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @genre_type }\n end\n end",
"def new\n @grm_grappt = GrmGrappt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @grm_grappt }\n end\n end",
"def new\n @impgen = Impgen.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @impgen }\n end\n end",
"def index\n @book_genres = BookGenre.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_genres }\n end\n end",
"def show\n @impgen = Impgen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @impgen }\n end\n end",
"def genere_params\n params.require(:genere).permit(:genere_id, :name, :description)\n end",
"def new\n @gravity = Gravity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gravity }\n end\n end",
"def list_genres_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: GenreApi.list_genres ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling GenreApi.list_genres, must be greater than or equal to 0.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 50\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling GenreApi.list_genres, must be smaller than or equal to 50.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling GenreApi.list_genres, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && opts[:'order_direction'] && !['asc', 'desc'].include?(opts[:'order_direction'])\n fail ArgumentError, 'invalid value for \"order_direction\", must be one of asc, desc'\n end\n # resource path\n local_var_path = \"/genres\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'parent_id'] = opts[:'parent_id'] if !opts[:'parent_id'].nil?\n query_params[:'program_id'] = opts[:'program_id'] if !opts[:'program_id'].nil?\n query_params[:'broadcast_id'] = opts[:'broadcast_id'] if !opts[:'broadcast_id'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'order-by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'order-direction'] = opts[:'order_direction'] if !opts[:'order_direction'].nil?\n query_params[:'_external_station_id'] = opts[:'_external_station_id'] if !opts[:'_external_station_id'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['API Key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'GenreResults')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: GenreApi#list_genres\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @gift_template = GiftTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gift_template }\n end\n end",
"def show\n @gopy = Gopy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gopy }\n end\n end",
"def set_generator\n @generator = Generator.find(params[:id])\n end",
"def set_generator\n @generator = Generator.find(params[:id])\n end",
"def new\n @genre_type = GenreType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @genre_type }\n end\n end",
"def generation_params\n params.require(:generation).permit(:model_id, :name)\n end",
"def random\n offset = rand(@ingredients.count)\n render json: @ingredients.offset(offset).first.as_json\n end",
"def new\n @program_genre = ProgramGenre.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @program_genre }\n end\n end",
"def show\n @gravity = Gravity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gravity }\n end\n end",
"def show\n @creation = Creation.find(params[:id])\n @creations = Creation.order(\"created_at DESC\").limit(5)\n rids = Creation.find( :all, :select => 'id' ).map( &:id )\n @random = Creation.find( (1..5).map { rids.delete_at( rids.size * rand ) } )\n @users = User.order(\"created_at DESC\").limit(4)\n @context = 'all'\n if params[:context]\n @context = params[:context]\n end\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @creation }\n end\n end",
"def new\n @gift_template = GiftTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gift_template }\n end\n end",
"def new\n @gig = Gig.new()\n @gig.build_attachment\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig }\n end\n end",
"def new\n @gasto = Gasto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gasto }\n end\n end",
"def new\n @gid2name = Gid2name.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gid2name }\n end\n end",
"def show\n @grm = Grm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @grm }\n end\n end",
"def index\n @textures = Texture.find(:all, :limit => 20, :order=> 'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @textures }\n end\n end",
"def show\n @gasto = Gasto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gasto }\n end\n end",
"def index\n @grams = Gram.all #if we wanted to make an app so that user can only see their own pin make = current_user.pins.all if not Gram.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @grams }\n end\n end",
"def destroy\n @genere.destroy\n respond_to do |format|\n format.html { redirect_to generes_url, notice: 'Genere was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def generate\n end",
"def index\n @page_title = 'Genres'\n @genres = Genre.all\n end",
"def new\n @gene_name = GeneName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gene_name }\n end\n end",
"def new\n @gopy = Gopy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gopy }\n end\n end",
"def new\n @grm = Grm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @grm }\n end\n end",
"def new\n @galeria = Galeria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @galeria }\n end\n end",
"def create\n @generator = Generator.new(generator_params)\n create_scaffold\n respond_to do |format|\n if @generator.save\n format.html { redirect_to @generator, notice: 'Generator was successfully created.' }\n format.json { render :show, status: :created, location: @generator }\n else\n format.html { render :new }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @gene_name = GeneName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gene_name }\n end\n end",
"def generate\n end"
] | [
"0.72182393",
"0.69145536",
"0.68541217",
"0.67455214",
"0.66895014",
"0.66623473",
"0.6657807",
"0.6629121",
"0.65609545",
"0.6556157",
"0.65105367",
"0.6473188",
"0.6347972",
"0.63292503",
"0.6297179",
"0.6195624",
"0.61636966",
"0.61082566",
"0.6102985",
"0.607009",
"0.60689265",
"0.60011625",
"0.5952807",
"0.59429187",
"0.59087783",
"0.5893348",
"0.5879259",
"0.58688045",
"0.58688045",
"0.58574027",
"0.5830559",
"0.5820415",
"0.5813878",
"0.57992965",
"0.57820004",
"0.5763386",
"0.57232976",
"0.5711561",
"0.5673605",
"0.5649548",
"0.5640798",
"0.56323034",
"0.5598237",
"0.5581684",
"0.55546284",
"0.5544794",
"0.5534904",
"0.5529891",
"0.55198765",
"0.54983586",
"0.54907227",
"0.5486779",
"0.5485538",
"0.5479436",
"0.5478619",
"0.54775846",
"0.5475571",
"0.54726267",
"0.5464948",
"0.5464948",
"0.54453796",
"0.54382324",
"0.54246217",
"0.5410824",
"0.53941905",
"0.5378622",
"0.5372777",
"0.53541917",
"0.53541243",
"0.5348643",
"0.5344446",
"0.534187",
"0.53308344",
"0.53141004",
"0.53111154",
"0.53111154",
"0.52988535",
"0.5298309",
"0.529665",
"0.5296642",
"0.5291162",
"0.5284918",
"0.52702",
"0.5269442",
"0.52560496",
"0.5243482",
"0.52366644",
"0.523194",
"0.5222652",
"0.5219007",
"0.5218479",
"0.5217324",
"0.5215274",
"0.52105933",
"0.52077746",
"0.52028954",
"0.52024466",
"0.5200351",
"0.519451",
"0.519022"
] | 0.61764705 | 16 |
POST /generations POST /generations.json | def create
@generation = Generation.new(generation_params)
respond_to do |format|
if @generation.save
format.html { redirect_to ['admin', @generation], notice: 'Generación Creada' }
format.json { render :show, status: :created, location: @generation }
else
format.html { render :new }
format.json { render json: @generation.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @generation = Generation.new(generation_params)\n\n respond_to do |format|\n if @generation.save\n format.html { redirect_to [:admin, @generation], notice: 'Generation was successfully created.' }\n format.json { render json: @generation, status: :created, location: @generation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @generation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @generator = Generator.new(generator_params)\n\n respond_to do |format|\n if @generator.save\n format.html { redirect_to @generator, notice: 'Generator was successfully created.' }\n format.json { render :show, status: :created, location: @generator }\n else\n format.html { render :new }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gen = Gen.new(params[:gen])\n\n respond_to do |format|\n if @gen.save\n format.html { redirect_to @gen, notice: 'Gen was successfully created.' }\n format.json { render json: @gen, status: :created, location: @gen }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_generations\n @generations.each do |g|\n create_generation(g) unless Generation.find_by(name: g['name'])\n end\n end",
"def create\n @generator = Generator.new(params[:generator])\n \n respond_to do |format|\n if @generator.save\n format.html { redirect_to admin_generator_path(@generator.id), notice: 'Generator was successfully created.' }\n format.json { render json: @generator, status: :created, location: @generator }\n else\n format.html { render action: \"new\" }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @genere = Genere.new(genere_params)\n\n respond_to do |format|\n if @genere.save\n format.html { redirect_to @genere, notice: 'Genere was successfully created.' }\n format.json { render :show, status: :created, location: @genere }\n else\n format.html { render :new }\n format.json { render json: @genere.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generation_params\n params.require(:generation).permit(:model_id, :name)\n end",
"def create\n authorize! :create, @manual\n @manual = new_manual\n respond_to do |format|\n if @manual.save\n format.html { redirect_to manuals_path, notice: \"#{t(:manual_transaction)} #{t(:was_successfully_created)}\" }\n # format.json { render action: 'show', status: :created, location: @manual }\n else\n init_collection\n gon.push batches: ActiveModel::Serializer::CollectionSerializer.new(@batches, each_serializer: BatchSerializer)\n format.html { render action: 'new' }\n # format.json { render json: @manual.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @small_generator = SmallGenerator.new(params[:small_generator])\n\n respond_to do |format|\n if @small_generator.save\n format.html { redirect_to @small_generator, notice: 'Small generator was successfully created.' }\n format.json { render json: @small_generator, status: :created, location: @small_generator }\n else\n format.html { render action: \"new\" }\n format.json { render json: @small_generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @generation = Generation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generation }\n end\n end",
"def index\n @generations = Generation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @generations }\n end\n end",
"def create\n @generator_info = GeneratorInfo.new(params[:generator_info])\n\n respond_to do |format|\n if @generator_info.save\n format.html { redirect_to @generator_info, notice: 'Generator info was successfully created.' }\n format.json { render json: @generator_info, status: :created, location: @generator_info }\n else\n format.html { render action: \"new\" }\n format.json { render json: @generator_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @generator = Generator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator }\n end\n end",
"def create\n @generator = Generator.new(generator_params)\n create_scaffold\n respond_to do |format|\n if @generator.save\n format.html { redirect_to @generator, notice: 'Generator was successfully created.' }\n format.json { render :show, status: :created, location: @generator }\n else\n format.html { render :new }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @generation = Generation.new(generation_params)\n @generation.user = current_user\n\n @generation.transaction do\n @generation.save!\n tasks_in_card = Nokogiri::HTML(@generation.question_card.question_card).css('.task')\n params.require(:number_variants).to_i.times do |i|\n variant = Variant.create!(number: i + 1, generation: @generation)\n tasks_in_card.each do |task|\n task_id = task[:task_id].to_i\n if task_id == 0\n tasks = TasksGroup.find(task[:tasks_group_id].to_i).tasks.ids\n generated_tasks = @generation.question_card.generated_tasks.map { |t| t.task.id }\n tasks -= generated_tasks if tasks.count > generated_tasks.count\n task_id = tasks.shuffle.first\n end\n generated_task = GeneratedTask.create!(variant: variant, task_in_card: task[:id].to_i, task_id: task_id)\n\n generated_task.task.variables.each do |v|\n rnd = Random.new\n res = rnd.rand(v.from .. v.to)\n res = res.round(v.round) unless v.round.nil?\n GeneratedVariable.create!(generated_task: generated_task, variable: v, value: res)\n end\n end\n end\n end\n\n respond_to do |format|\n if [email protected]?\n format.html { redirect_to @generation, notice: 'Generation was successfully created.' }\n format.json { render :show, status: :created, location: @generation }\n else\n format.html { render :new }\n format.json { render json: @generation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generator_params\n params.require(:generator).permit(:name)\n end",
"def generator_params\n params.require(:generator).permit(:name, :notes, attrs_attributes: [:id, :name, :type, :_destroy], \n refgenerators_ids: [], refgenerators_names: [])\n end",
"def genere_params\n params.require(:genere).permit(:genere_id, :name, :description)\n end",
"def new\n @gen = Gen.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gen }\n end\n end",
"def create\n @ocs_generada = OcsGenerada.new(ocs_generada_params)\n\n respond_to do |format|\n if @ocs_generada.save\n format.html { redirect_to @ocs_generada, notice: 'Ocs generada was successfully created.' }\n format.json { render :show, status: :created, location: @ocs_generada }\n else\n format.html { render :new }\n format.json { render json: @ocs_generada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @generations = Generation.all\n end",
"def create\n @opportunity_generator = OpportunityGenerator.new(params[:opportunity_generator])\n\n respond_to do |format|\n if @opportunity_generator.save\n flash_message('Opportunity generator', true)\n format.html { redirect_to @opportunity_generator}\n format.json { render json: @opportunity_generator, status: :created, location: @opportunity_generator }\n else\n flash_message('Opportunity generator', false)\n format.html { render action: \"new\" }\n format.json { render json: @opportunity_generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if handle_component && @generator.save\n format.html { redirect_to @generator, notice: 'Generator was successfully created.' }\n format.json { render action: 'show', status: :created, location: @generator }\n else\n format.html { render action: 'new' }\n format.json { render json: {status: :unprocessable_entity, errors: 'Could Not Create Generator'} }\n end\n end\n end",
"def destroy\n @generation.destroy\n respond_to do |format|\n format.html { redirect_to generations_my_url, notice: 'Сгенерированные варианты были успешно удалены.' }\n format.json { head :no_content }\n end\n end",
"def render_generals\n render json: GeneralsSerializer.new(@general_data).to_serialized_json\n end",
"def genero_params\n params.require(:genero).permit(:nome, :descricao)\n end",
"def new\n @small_generator = SmallGenerator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @small_generator }\n end\n end",
"def create\n @genotype = Genotype.new(params[:genotype])\n\n respond_to do |format|\n if @genotype.save\n format.html { redirect_to @genotype, notice: 'Genotype was successfully created.' }\n format.json { render json: @genotype, status: :created, location: @genotype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @genotype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def getgenerate\n request :getgenerate\n end",
"def create\n generate\n save\n end",
"def new\n @generator_info = GeneratorInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator_info }\n end\n end",
"def generate\n save\n end",
"def create\n p = params[:registration]\n training = Training.find_by_code(p[:training_code])\n owner = Student.find_by_wp_email(p[:owner_email])\n reg_type = p[:reg_type]\n if reg_type == 'single-self'\n registerable = owner\n elsif reg_type == 'single-other'\n registerable = Student.find_by_wp_email(p[:registrant_email])\n else \n registerable = Group.find_by_handle(p[:group_handle])\n end\n @registration = Registration.new(reg_type: reg_type)\n @registration.owner = owner\n @registration.registerable = registerable\n @registration.training = training\n\n # Fix this. We need to have a sequence in the database.\n @registration.code = 100000 + rand(900000)\n\n respond_to do |format|\n if @registration.save\n format.html { redirect_to @registration, notice: 'Registration was successfully created.' }\n format.json { render :show, status: :created, location: @registration }\n else\n format.html do\n @trainings = Training.all\n render :new\n end\n format.json { render json: @registration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @impgen = Impgen.new(params[:impgen])\n\n respond_to do |format|\n if @impgen.save\n format.html { redirect_to @impgen, notice: 'Impgen was successfully created.' }\n format.json { render json: @impgen, status: :created, location: @impgen }\n else\n format.html { render action: \"new\" }\n format.json { render json: @impgen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def getgenerate\n @api.request 'getgenerate'\n end",
"def start_generation\n Nanite.request(\"/nanny/generate\", self.id)\n end",
"def create\n @specific_gravity = SpecificGravity.new(specific_gravity_params)\n\n respond_to do |format|\n if @specific_gravity.save\n format.html { redirect_to @batch, notice: 'Specific gravity was successfully created.' }\n format.json { render :show, status: :created, location: @specific_gravity }\n else\n format.html { render :new }\n format.json { render json: @specific_gravity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generator_params\n params.require(:generator).permit(:userid, :guid, :csvfile, :csvcount, :processedcount, :status)\n end",
"def create\n #debugger\n @allergen = Allergen.new(allergen_params)\n #@allergen = Allergen.new\n\n respond_to do |format|\n if @allergen.save\n #format.html { redirect_to @allergen, notice: 'Allergen was successfully created.' }\n #format.json { render :show, status: :created, location: @allergen }\n #format.json { render :show, status: :created, location: @allergen } #sostituita poco tempo fa\n format.json { render json: @allergen, status: :created, location: @allergen }\n else\n #format.html { render :new }\n #format.json { render json: @allergen.errors, status: :unprocessable_entity }\n format.json { render json: @allergen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @generation = Generation.find(params[:id])\n @generation.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_generations_url }\n format.json { head :no_content }\n end\n end",
"def index\n @generator = Generator.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @generator }\n end\n end",
"def create\n @dj_profile = DjProfile.new(dj_params)\n @dj_profile.user = current_user\n @dj_profile.genres = [params[:dj_profile][:genres]]\n if @dj_profile.save\n redirect_to dj_profile_path(@dj_profile), notice: 'Your Dj profile has been created succesfully!'\n else\n render :new\n end\n end",
"def create\n @made_in_g = MadeInG.new(made_in_g_params)\n\n respond_to do |format|\n if @made_in_g.save\n format.html { redirect_to @made_in_g, notice: 'Made in g was successfully created.' }\n format.json { render :show, status: :created, location: @made_in_g }\n else\n format.html { render :new }\n format.json { render json: @made_in_g.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @aggrupation = Aggrupation.new(aggrupation_params)\n\n respond_to do |format|\n if @aggrupation.save\n format.html { redirect_to @aggrupation, notice: 'Aggrupation was successfully created.' }\n format.json { render :show, status: :created, location: @aggrupation }\n else\n format.html { render :new }\n format.json { render json: @aggrupation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n gig = Gig.new()\n respond_to do |format|\n if update_gig(gig)\n format.html { render json: gig, status: :created, location: gig }\n format.json { render json: gig, status: :created, location: gig }\n else\n format.html { render action: \"new\" }\n format.json { render json: gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @registration = Registration.new(registration_params)\n\n if @registration.save\n @registration.generate_invoices\n\n render :show, status: :created\n else\n render json: @registration.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def create\n @gig_request = GigRequest.new(params[:gig_request])\n\n respond_to do |format|\n if @gig_request.save\n format.html { redirect_to @gig_request, notice: 'Gig request was successfully created.' }\n format.json { render json: @gig_request, status: :created, location: @gig_request }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gig_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n tournament = Tournament.find(params[:tournament_id])\n @registration = Registration.new(tournament:tournament)\n tournament.draws.order('draws.is_single DESC, draws.title').each do |draw|\n @registration.draw_registrations.build(draw_id: draw.id)\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @registration }\n end\n end",
"def provision\n @order = Order.new\n 1.times {@order.order_details.build}\n respond_to do |format|\n format.html # provision.html.erb\n format.json { render json: @order }\n end\n end",
"def generate\n generations = 0\n loop do\n print\n sleep(0.5)\n newGeneration\n generations += 1\n p \"Number of generations: #{generations} [Ctrl-C to exit]\"\n end\n end",
"def create\n @creation_tag = CreationTag.new(creation_tag_params)\n\n respond_to do |format|\n if @creation_tag.save\n format.html { redirect_to @creation_tag, notice: 'Creation tag was successfully created.' }\n format.json { render :show, status: :created, location: @creation_tag }\n else\n format.html { render :new }\n format.json { render json: @creation_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @genero = Genero.new(genero_params)\n\n if params.has_key?(:usa_wiki)\n @genero.descricao = Utils::descricao_wiki(@genero.nome)\n if @genero.descricao.nil?\n flash.now[:danger] = \"Não foi possível buscar a descrição do Wikipédia\"\n render :new\n return\n end\n end\n\n respond_to do |format|\n if @genero.save\n flash[:success] = \"Gênero #{@genero.nome} foi criado com sucesso!\"\n format.html { redirect_to @genero }\n format.json { render :show, status: :created, location: @genero }\n else\n flash.now[:danger] = \"Gênero #{@genero.nome} não foi criado com sucesso!\"\n format.html { render :new }\n format.json { render json: @genero.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def create\n @gommi = Gommi.new(gommi_params)\n\n respond_to do |format|\n if @gommi.save\n format.html { redirect_to gommis_complete_path, notice: 'Gommi was successfully created.' }\n format.json { render :show, status: :created, location: @gommi }\n else\n format.html { render :new }\n format.json { render json: @gommi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generation\n @gapi[\"generation\"]\n end",
"def create\n @gig_set = GigSet.new(gig_set_params)\n @gig_set.number = (@gig_set.gig.gig_sets.map(&:number).compact.max || 0) + 1\n\n respond_to do |format|\n if @gig_set.save\n format.html { redirect_to edit_gig_path(@gig_set.gig) }\n format.json { redirect_to edit_gig_path(@gig_set.gig) }\n else\n format.html { redirect_to edit_gig_path(@gig_set.gig), error: \"Couldn't add a new set\" }\n format.json { redirect_to edit_gig_path(@gig_set.gig), status: :unprocessable_entity }\n end\n end\n end",
"def post_app_generate(application_id, type, opts={})\n # \n # default_options = {\n # \"name\" => \"\",\n # \"author\" => \"\",\n # \"description\" => \"\",\n # \"guid\" => \"\",\n # \"datasets\" => \"\",\n # \"env\" => \"prod\",\n # \"image_url\" => \"http://appresource.s3.amazonaws.com/apiappimages/missing_icard.jpg\",\n # \"runtime\" => \"\"\n # }\n # options = default_options.merge(opts)\n return post_response(\"app/#{application_id}/generate/#{type}\", opts,:json)\n end",
"def is_generations?(); @type == GRT_GENERATIONS; end",
"def create\n @gig_type = GigType.new(gig_type_params)\n\n respond_to do |format|\n if @gig_type.save\n format.html { redirect_to @gig_type, notice: 'Gig type was successfully created.' }\n format.json { render :show, status: :created, location: @gig_type }\n else\n format.html { render :new }\n format.json { render json: @gig_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @genre = current_profile.genres.build(genre_params)\n\n respond_to do |format|\n if @genre.save\n format.html { redirect_to @genre, notice: 'Genre was successfully created.' }\n format.json { render :show, status: :created, location: @genre }\n else\n format.html { render :new }\n format.json { render json: @genre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def setgenerate(generate, genproclimit)\n request :setgenerate, generate, genproclimit\n end",
"def create\n @gentre = Gentre.new(gentre_params)\n\n respond_to do |format|\n if @gentre.save\n format.json { render :show, status: :created, location: @gentre }\n else\n format.json { render json: @gentre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generate_tags\n uri = URI.parse(\"https://api.thomsonreuters.com/permid/calais\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n post_body = []\n post_body << \"<Document><Body>\"\n # stip html\n post_body << ActionView::Base.full_sanitizer.sanitize(params[:desc])\n # no strip\n # post_body << params[:desc]\n post_body << \"</Body></Document>\"\n request = Net::HTTP::Post.new(uri.request_uri)\n request.add_field(\"Content-Type\",\"text/xml\")\n request.add_field(\"outputFormat\",\"application/json\")\n #request.add_field(\"outputFormat\",\"text/n3\") \n request.add_field(\"x-ag-access-token\",\"fY7WUM3GGCXHm9ATOhtzhrvlWX8oPo5X\")\n request.body = post_body.join\n # request[\"Content-Type\"] = \"multipart/form-data, boundary=#{BOUNDARY}\"\n\n render :json => http.request(request).body\n end",
"def create\n @winding = Winding.new(winding_params)\n #Codigo para gerar gcode a 90 graus\n generate_gcode\n\n respond_to do |format|\n if @winding.save\n format.html { redirect_to @winding, notice: 'Winding was successfully created.' }\n format.json { render :show, status: :created, location: @winding }\n else\n format.html { render :new }\n format.json { render json: @winding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relatorio_gerals = RelatorioGeral.all\n authorize @relatorio_gerals\n\n @relatorio_geral = RelatorioGeral.new(relatorio_geral_params)\n\n respond_to do |format|\n if @relatorio_geral.save\n format.html { redirect_to @relatorio_geral, notice: 'Relatório geral criado com sucesso!' }\n format.json { render :show, status: :created, location: @relatorio_geral }\n else\n format.html { render :new }\n format.json { render json: @relatorio_geral.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_register\n creator = Creator.new(submits: 0, name: request.headers['name'],password: request.headers['password'],password_confirmation: request.headers['password'])\n if creator.save\n encode = encodeJWT(creator)\n selected_format({jwt: encode,creator_id: creator.id,name: creator.name,submits:creator.submits},:ok)\n else\n error = create_error_message\n error[:developerMessage] = creator.errors\n selected_format(error, :bad_request)\n end\n end",
"def genero_params\n params.fetch(:genero, {})\n end",
"def create\n\t\tauthorize! :create, DetalleRestriccion\n @detalle_restriccion = @restriccion.detalle_restricciones.new(detalle_restriccion_params)\n @concepto_gastos = ConceptoGasto.all\n respond_to do |format|\n if @detalle_restriccion.save\n format.html { redirect_to gestionar_restricciones_path}\n #format.html { redirect_to @detalle_restriccion, notice: 'Detalle restriccion fue creado satisfactoriamente.' }\n #format.json { render :show, status: :created, location: @detalle_restriccion }\n else\n format.html { render :new }\n format.json { render json: @detalle_restriccion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @program_genre = ProgramGenre.new(params[:program_genre])\n\n respond_to do |format|\n if @program_genre.save\n format.html { redirect_to @program_genre, notice: 'Program genre was successfully created.' }\n format.json { render json: @program_genre, status: :created, location: @program_genre }\n else\n format.html { render action: \"new\" }\n format.json { render json: @program_genre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @estimation = Estimation.new(estimation_params)\n #Estimation.generation_new_item(params[:estimation])\n respond_to do |format|\n if @estimation.save\n format.html { redirect_to estimations_url, notice: 'Estimation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @estimation }\n else\n format.html { render action: 'new' }\n format.json { render json: @estimation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generate\n \n length = 500\n if params[:length]\n length = params[:length].to_f\n if length > 10000 then length = 10000 end\n if length < 10 then length = 10 end\n end\n type = params[:type] ? params[:type] : 'L'\n words = ''\n case type\n when 'Lat'\n #35 is the shortest value for sentences which consistently gives at least the correct character count\n words = Faker::Lorem.sentences(length/35).join(' ')\n when 'Ran'\n while words.length < length do\n words += Faker::Internet.password(5, 20).to_s + \" \"\n end\n when 'Nam'\n while words.length < length do\n words += Faker::Name.name + \" \"\n end\n when 'Num'\n while words.length < length do\n words += (rand(10 ** rand(1..15))).to_s + \" \"\n puts 'Length ' + words.length.to_s\n end\n when 'Dat'\n while words.length < length do\n words += Faker::Date.between(10.years.ago, 10.years.from_now).to_s + \" \"\n end\n else \n render json:{text: \"Invalid type\"}\n end \n render json:{text: words[0..length-1]} \n end",
"def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n if params[\"allergens\"] != nil\n params[\"allergens\"].each do |a|\n if Ingredient.find_by_name(a) == nil\n @ingredient = Ingredient.create({:name => a})\n Useringredient.create({:user_id => @user.id, :allergen_id => @ingredient.id})\n else\n @ingredient = Ingredient.find_by_name(a)\n Useringredient.create({:user_id => @user.id, :allergen_id => @ingredient.id})\n end\n end\n end\n session[\"user_id\"] = @user.id\n format.html { redirect_to '/', notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gua = Gua.new(gua_params)\n\n respond_to do |format|\n if @gua.save\n format.html { redirect_to @gua, notice: 'Gua was successfully created.' }\n format.json { render :show, status: :created, location: @gua }\n else\n format.html { render :new }\n format.json { render json: @gua.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gen_attraction = GenPackage.find_by_name(params[:city]).gen_attractions.build(name: \"Test\")\n\n respond_to do |format|\n if @gen_attraction.save\n format.html { redirect_to gen_attractions_path, notice: 'Gen attraction was successfully created.' }\n format.json { render :show, status: :created, location: gen_attractions_path }\n else\n format.html { render :new }\n format.json { render json: gen_attractions_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generate_request\r\n end",
"def create\n @grupoassunto = Grupoassunto.new(grupoassunto_params)\n\n if @grupoassunto.save\n render json: @grupoassunto, status: :created, location: @grupoassunto\n else\n render json: @grupoassunto.errors, status: :unprocessable_entity\n end\n end",
"def create\n @galletum = Galletum.new(galletum_params)\n\n respond_to do |format|\n if @galletum.save\n format.html { redirect_to @galletum, notice: 'Galletum was successfully created.' }\n format.json { render :show, status: :created, location: @galletum }\n else\n format.html { render :new }\n format.json { render json: @galletum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @renter = Renter.new(params[:renter])\n @locals = User.where(:city => @buyer.city)\n @users = @locals.random(5)\n respond_to do |format|\n if @renter.save\n @users.each do |user|\n RenterMailer.registration_welcome(@renter, user).deliver\n Renter.increment_counter(\"times_forwarded\", @renter.id)\n end\n format.html { redirect_to :submitted_page, :notice => 'Seller was successfully created.' }\n format.json { render :json => @renter, :status => :created, :location => @renter }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @renter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @bench_test_photo_gen = BenchTest::PhotoGen.new(params[:bench_test_photo_gen])\n\n # create the album and photos which kicks off the work to generate thumbs\n mark_as_starting @bench_test_photo_gen\n\n respond_to do |format|\n if @bench_test_photo_gen.save\n format.html { redirect_to(@bench_test_photo_gen, :notice => 'Photo gen was successfully created.') }\n format.xml { render :xml => @bench_test_photo_gen, :status => :created, :location => @bench_test_photo_gen }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bench_test_photo_gen.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_pregunta = TipoPregunta.new(params[:tipo_pregunta])\n\n if @tipo_pregunta.save\n render json: @tipo_pregunta, status: :created, location: @tipo_pregunta\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @registration = Registration.new(registration_params)\n @registration.student_id = current_user.tec_id\n @registration.approved = false\n @registration.date = DateTime.current\n\n respond_to do |format|\n if @registration.save\n format.html { redirect_to completed_registration_path(@registration.id), notice: 'Registration was successfully created.' }\n format.json { render :completed, status: :created, location: @registration }\n else\n format.html { render :new }\n format.json { render json: @registration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gudang = Gudang.new(gudang_params)\n\n respond_to do |format|\n if @gudang.save\n format.html { redirect_to @gudang, notice: 'Gudang was successfully created.' }\n format.json { render :show, status: :created, location: @gudang }\n else\n format.html { render :new }\n format.json { render json: @gudang.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gram = current_user.grams.new(params[:gram])\n\n respond_to do |format|\n if @gram.save\n format.html { redirect_to @gram, notice: 'Gram was successfully created.' }\n format.json { render json: @gram, status: :created, location: @gram }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gram.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @opportunity_generator = OpportunityGenerator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @opportunity_generator }\n end\n end",
"def create\n @gang = Gang.new(gang_params)\n\n respond_to do |format|\n if @gang.save\n format.html { redirect_to @gang, notice: 'Gang was successfully created.' }\n format.json { render :show, status: :created, location: @gang }\n else\n format.html { render :new }\n format.json { render json: @gang.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @genrecreate = Genrecreate.new(genrecreate_params)\n\n respond_to do |format|\n if @genrecreate.save\n format.html { redirect_to @genrecreate, notice: 'Genrecreate was successfully created.' }\n format.json { render :show, status: :created, location: @genrecreate }\n else\n format.html { render :new }\n format.json { render json: @genrecreate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tauthorize! :create, DetalleGasto\n @detalle_gasto = @informe_gastos.detalle_gastos.new(detalle_gasto_params)\n @detalle_gasto.voluntario_id = current_usuario.id\n respond_to do |format|\n if @detalle_gasto.save\n sesion = Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n Transaccion.create!(descripcion: \"Creación del detalle gasto #{@detalle_gasto.titulo}, descripcion: #{@detalle_gasto.descripcion}, con monto #{@detalle_gasto.monto}, concepto_gasto: #{@detalle_gasto.concepto_gasto.titulo}, voluntario: #{@detalle_gasto.voluntario.nombre}, comprobante: #{@detalle_gasto.comprobante.numero}\",\n sesion_id: sesion.id, \n proyecto_id: @detalle_gasto.informe_gasto.proyecto.id)\n #format.html { redirect_to gestionar_informe_gastos_path(@detalle_gasto.informe_gasto)} #@detalle_gasto, notice: 'Detalle gasto fue creado satisfactoriamente.' }\n format.html { redirect_to new_comprobante_path(:detalle_gasto_id => @detalle_gasto.id)}\n #format.json { render :show, status: :created, location: @detalle_gasto }\n else\n format.html { render :new }\n format.json { render json: @detalle_gasto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jugador = Jugador.find_by(id: params[:pago][:jugador_id])\n @pago = @jugador.pagos.build(pago_params)\n #@pago.jugador_id = params[:jugador_id]\n\n respond_to do |format|\n if @pago.save\n format.html { redirect_to jugadores_path, notice: 'Se ha registrado exitosamente el pago.' }\n format.json { render :show, status: :created, location: @pago }\n else\n format.html { render :new }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @uasg = Uasg.new(uasg_params)\n\n respond_to do |format|\n if @uasg.save\n format.html { redirect_to @uasg, notice: 'Uasg was successfully created.' }\n format.json { render :show, status: :created, location: @uasg }\n else\n format.html { render :new }\n format.json { render json: @uasg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gran_unidad = GranUnidad.new(gran_unidad_params)\n\n respond_to do |format|\n if @gran_unidad.save\n format.html { redirect_to @gran_unidad, notice: 'Gran unidad was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gran_unidad }\n else\n format.html { render action: 'new' }\n format.json { render json: @gran_unidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n s = Spooge.new()\n create_status = s.save\n n = generate_random_name\n s.name = n\n s.email = \"#{n}@gmail.com\"\n s.touch_date = DateTime.now\n s.status = STATUS[rand(STATUS.length)]\n\n resp = {:create_status => create_status, :record => s}\n render :json => resp\n end",
"def new\n @genotype = Genotype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @genotype }\n end\n end",
"def generate\n end",
"def create\n @gram = Gram.new(gram_params)\n\n respond_to do |format|\n if @gram.save\n format.html { redirect_to @gram, notice: 'Gram was successfully created.' }\n format.json { render :show, status: :created, location: @gram }\n else\n format.html { render :new }\n format.json { render json: @gram.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bulk_generate\n\n end",
"def create\n @table = Table.new(params[:table].permit(:name, :notes, :x, :y, :table_type, :guest_ids => []))\n\n respond_to do |format|\n if @table.save\n format.html { redirect_to @table, notice: 'Table was successfully created.' }\n format.json { render 'tables/create', status: :created, location: @table }\n else\n format.html { render action: \"new\" }\n format.json { render json: @table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gdoc = Gdoc.new(gdoc_params)\n\n respond_to do |format|\n if @gdoc.save\n format.html { redirect_to @gdoc, notice: 'Gdoc was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gdoc }\n else\n format.html { render action: 'new' }\n format.json { render json: @gdoc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_generation\n @generation = Generation.find(params[:id])\n end",
"def destroy\n @gen = Gen.find(params[:id])\n @gen.destroy\n\n respond_to do |format|\n format.html { redirect_to gens_url }\n format.json { head :no_content }\n end\n end",
"def add_generation(word)\n\t\t@generations << word\n\t\t@modifications << nil\n\tend"
] | [
"0.685122",
"0.68067175",
"0.67470443",
"0.6706753",
"0.65785855",
"0.64659756",
"0.6319495",
"0.6313439",
"0.62647986",
"0.62048316",
"0.6186005",
"0.6130324",
"0.61227375",
"0.6090344",
"0.60627484",
"0.5976743",
"0.59718966",
"0.5924296",
"0.5880258",
"0.58572423",
"0.5835638",
"0.58275807",
"0.5814839",
"0.5708632",
"0.5700751",
"0.5694121",
"0.5679307",
"0.5670239",
"0.5664005",
"0.56577885",
"0.5640944",
"0.56353694",
"0.5611211",
"0.55785495",
"0.5528111",
"0.55145603",
"0.55076945",
"0.5506739",
"0.5503804",
"0.5501562",
"0.54910076",
"0.54758316",
"0.5448237",
"0.5442495",
"0.5441283",
"0.5438998",
"0.54328686",
"0.54236037",
"0.54034835",
"0.53991556",
"0.53892165",
"0.53810686",
"0.5377404",
"0.53736407",
"0.53594166",
"0.53526694",
"0.5331941",
"0.5322425",
"0.5314806",
"0.53090435",
"0.5301846",
"0.5298004",
"0.5297233",
"0.52892923",
"0.52820164",
"0.5280013",
"0.5276973",
"0.526177",
"0.52601403",
"0.5259309",
"0.52381295",
"0.5236879",
"0.5234994",
"0.52341527",
"0.5225313",
"0.52112144",
"0.520086",
"0.5200071",
"0.519448",
"0.5192312",
"0.51914626",
"0.51913846",
"0.51850724",
"0.5184906",
"0.5181537",
"0.5174933",
"0.5171248",
"0.51701957",
"0.51680964",
"0.5163341",
"0.5160796",
"0.51562",
"0.51527035",
"0.5150028",
"0.51409394",
"0.51388264",
"0.5136811",
"0.513551",
"0.51343054",
"0.5124887"
] | 0.6827705 | 1 |
PATCH/PUT /generations/1 PATCH/PUT /generations/1.json | def update
@generation=Generation.find(params[:id])
if @generation.update generation_params
redirect_to ['admin', @generation], notice: "Generación Actualizada"
else
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @generator.update(generator_params)\n format.html { redirect_to @generator, notice: 'Generator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gen = Gen.find(params[:id])\n\n respond_to do |format|\n if @gen.update_attributes(params[:gen])\n format.html { redirect_to @gen, notice: 'Gen was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @generator.update(generator_params)\n format.html { redirect_to @generator, notice: 'Generator was successfully updated.' }\n format.json { render :show, status: :ok, location: @generator }\n else\n format.html { render :edit }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @generator.update(generator_params)\n format.html { redirect_to @generator, notice: 'Generator was successfully updated.' }\n format.json { render :show, status: :ok, location: @generator }\n else\n format.html { render :edit }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @genere.update(genere_params)\n format.html { redirect_to @genere, notice: 'Genere was successfully updated.' }\n format.json { render :show, status: :ok, location: @genere }\n else\n format.html { render :edit }\n format.json { render json: @genere.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @generation = Generation.find(params[:id])\n\n respond_to do |format|\n if @generation.update_attributes(generation_params)\n format.html { redirect_to [:admin, @generation], notice: 'Generation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @generation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @generator = Generator.find(params[:id])\n\n respond_to do |format|\n if @generator.update_attributes(params[:generator])\n format.html { redirect_to admin_generator_path(@generator.id), notice: 'Generator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @small_generator = SmallGenerator.find(params[:id])\n\n respond_to do |format|\n if @small_generator.update_attributes(params[:small_generator])\n format.html { redirect_to @small_generator, notice: 'Small generator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @small_generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @genero.update(genero_params)\n flash[:success] = \"Gênero #{@genero.nome} foi editado com sucesso!\"\n format.html { redirect_to @genero }\n format.json { render :show, status: :ok, location: @genero }\n else\n flash.now[:danger] = \"Gênero #{@genero.nome} não foi editado com sucesso!\"\n format.html { render :edit }\n format.json { render json: @genero.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @generator_info = GeneratorInfo.find(params[:id])\n\n respond_to do |format|\n if @generator_info.update_attributes(params[:generator_info])\n format.html { redirect_to @generator_info, notice: 'Generator info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @generator_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_gen\n respond_to do |format|\n # En etiquetas pone usuario actual por omision\n if (!params[:caso][:caso_etiqueta_attributes].nil?)\n params[:caso][:caso_etiqueta_attributes].each do |k,v|\n if (v[:usuario_id].nil? || v[:usuario_id] == \"\")\n v[:usuario_id] = current_usuario.id\n end\n end\n end\n\n # En familiares si falta crear trelacion_persona para personas\n # autocompletadas los crea\n if caso_params[:victima_attributes]\n caso_params[:victima_attributes].each do |iv, v|\n if v[:persona_attributes] &&\n v[:persona_attributes][:persona_trelacion1_attributes]\n v[:persona_attributes][:persona_trelacion1_attributes].each do |it, t|\n if t && (!t[:id] || t[:id] == '') &&\n t[:personados_attributes] &&\n t[:personados_attributes][:id] &&\n t[:personados_attributes][:id].to_i > 0 &&\n Msip::Persona.where(\n id: t[:personados_attributes][:id].to_i).count == 1\n pt_e = Msip::PersonaTrelacion.where(\n persona1: v[:persona_attributes][:id],\n persona2: t[:personados_attributes][:id]\n )\n if !pt_e\n pt = Msip::PersonaTrelacion.create({\n persona1: v[:persona_attributes][:id],\n persona2: t[:personados_attributes][:id]\n })\n pt.save!(validate: false)\n params[:caso][:victima_attributes][iv][:persona_attributes][:persona_trelacion1_attributes][it][:id] = pt.id\n else\n params[:caso][:victima_attributes][iv][:persona_attributes][:persona_trelacion1_attributes][it][:id] = pt_e[0].id\n end\n end\n end\n end\n end\n end\n\n if params[:_msip_enviarautomatico] == \"1\"\n params_finales = caso_params.except(\n :caso_etiqueta_attributes,\n :caso_anexo_attributes,\n :caso_fuenteprensa_attributes,\n :caso_fotra_attributes,\n :caso_presponsable_attributes\n )\n else\n params_finales = caso_params\n end\n\n if @caso.update(params_finales)\n\n\n if registrar_en_bitacora\n Msip::Bitacora.agregar_actualizar(\n request, :caso, :bitacora_cambio, \n current_usuario.id, params, 'Sivel2Gen::Caso',\n @caso.id\n )\n end\n\n #if request.params[:enviarFichaCaso] == '1'\n # head :no_content\n # return\n #end\n\n notificacion = 'Caso actualizado.'\n if Sivel2Gen::Caso.count > MAX_CASOS_REFRESCA_AUTOMATICO\n notificacion += \" Por la cantidad de casos \"+\n \" debe Refrescar para notar \" +\n \" el cambio en el listado de casos\"\n end\n format.html {\n redirect_to @caso,\n notice: notificacion\n }\n format.json { head :no_content }\n format.js { head :no_content }\n else\n format.html {\n if session[:capturacaso_acordeon]\n render 'editv', layout: 'application'\n else\n render 'edit', layout: 'application'\n end\n }\n format.json { render json: @caso.errors,\n status: :unprocessable_entity }\n format.js { render json: @caso.errors,\n status: :unprocessable_entity }\n end\n end\n begin\n @conscasocount = Conscaso.count\n if @conscasocount <= MAX_CASOS_REFRESCA_AUTOMATICO\n puts Conscaso.refresca_conscaso\n end\n rescue\n puts Conscaso.refresca_conscaso\n @conscasocount = Conscaso.count\n end\n end",
"def update\n respond_to do |format|\n if @ocs_generada.update(ocs_generada_params)\n format.html { redirect_to @ocs_generada, notice: 'Ocs generada was successfully updated.' }\n format.json { render :show, status: :ok, location: @ocs_generada }\n else\n format.html { render :edit }\n format.json { render json: @ocs_generada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n #@gen_attraction = GenAttraction.create( gen_attraction_params )\n respond_to do |format|\n if @gen_attraction.update(gen_attraction_params)\n format.html { redirect_to :gen_attractions, notice: 'Gen attraction was successfully updated.' }\n format.json { respond_with_bip(@gen_attraction) }\n else\n format.html { render :edit }\n format.json { render json: @gen_attraction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @genotype = Genotype.find(params[:id])\n\n respond_to do |format|\n if @genotype.update_attributes(params[:genotype])\n format.html { redirect_to @genotype, notice: 'Genotype was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @genotype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @opportunity_generator = OpportunityGenerator.find(params[:id])\n\n respond_to do |format|\n if @opportunity_generator.update_attributes(params[:opportunity_generator])\n flash_message('Opportunity generator', true)\n format.html { redirect_to @opportunity_generator}\n format.json { head :no_content }\n else\n flash_message('Opportunity generator', false)\n format.html { render action: \"edit\" }\n format.json { render json: @opportunity_generator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_method\n :put_json\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def patch\n end",
"def update\n @gig_request = GigRequest.find(params[:id])\n\n respond_to do |format|\n if @gig_request.update_attributes(params[:gig_request])\n format.html { redirect_to @gig_request, notice: 'Gig request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gig_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def create_method\n :http_put\n end",
"def create_method\n :http_put\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update\n respond_to do |format|\n if @generic.update(generic_params)\n format.html { redirect_to @generic, notice: 'Combination dose was successfully updated.' }\n format.json { render :show, status: :ok, location: @generic }\n else\n format.html { render :edit }\n format.json { render json: @generic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gift_template = GiftTemplate.find(params[:id])\n\n respond_to do |format|\n if @gift_template.update_attributes(params[:gift_template])\n format.html { redirect_to gift_templates_path, notice: 'Gift template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gift_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n if update_gig(@gig)\n format.html { redirect_to @gig, notice: 'Gig was successfully updated.' }\n format.json { render json: @gig, status: :ok, location: @gig }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @impgen = Impgen.find(params[:id])\n\n respond_to do |format|\n if @impgen.update_attributes(params[:impgen])\n format.html { redirect_to @impgen, notice: 'Impgen was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @impgen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @routed_generic.update(routed_generic_params)\n format.html { redirect_to @routed_generic, notice: 'Combination dose was successfully updated.' }\n format.json { render :show, status: :ok, location: @routed_generic }\n else\n format.html { render :edit }\n format.json { render json: @routed_generic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n respond_to_update({thing: @author})\n end",
"def update\n respond_to do |format|\n if @specific_gravity.update(specific_gravity_params)\n format.html { redirect_to @batch, notice: 'Specific gravity was successfully updated.' }\n format.json { render :show, status: :ok, location: @specific_gravity }\n else\n format.html { render :edit }\n format.json { render json: @specific_gravity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n create\n end",
"def update\n create\n end",
"def put!\n request! :put\n end",
"def update\n respond_to do |format|\n if @made_in_g.update(made_in_g_params)\n format.html { redirect_to @made_in_g, notice: 'Made in g was successfully updated.' }\n format.json { render :show, status: :ok, location: @made_in_g }\n else\n format.html { render :edit }\n format.json { render json: @made_in_g.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n #respond_to do |format|\n if @allergen.update(allergen_params)\n #format.html { redirect_to @allergen, notice: 'Allergen was successfully updated.' }\n #format.json { render :show, status: :ok, location: @allergen }\n render :show, status: :ok, location: @allergen\n else\n #format.html { render :edit }\n #format.json { render json: @allergen.errors, status: :unprocessable_entity }\n render json: @allergen.errors, status: :unprocessable_entity\n end\n #end\n end",
"def update\n respond_to do |format|\n if @gig_request.update(gig_request_params)\n format.html { redirect_to @gig_request, notice: 'Gig request was successfully updated.' }\n format.json { render :show, status: :ok, location: @gig_request }\n else\n format.html { render :edit }\n format.json { render json: @gig_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generation_params\n params.require(:generation).permit(:model_id, :name)\n end",
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def update\n @gift_request = GiftRequest.find(params[:id])\n \n respond_to do |format|\n if @gift_request.update_attributes(params[:gift_request])\n format.html { redirect_to @gift_request, notice: 'Gift request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gift_request.errors.full_messages.to_sentence, status: :unprocessable_entity }\n end\n end\n end",
"def create\n gig = Gig.new()\n respond_to do |format|\n if update_gig(gig)\n format.html { render json: gig, status: :created, location: gig }\n format.json { render json: gig, status: :created, location: gig }\n else\n format.html { render action: \"new\" }\n format.json { render json: gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n \n #@template.creator = current_user.id\n if @template.update(template_params)\n @template.creator=current_user.id\n @template.save\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n save_relations\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient.recipe, notice: 'Ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @generation = Generation.find(params[:id])\n @generation.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_generations_url }\n format.json { head :no_content }\n end\n end",
"def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes(params[:treq])\n format.html { redirect_to @treq, notice: 'Treq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def set_genere\n @genere = Genere.find(params[:id])\n end",
"def generator_params\n params.require(:generator).permit(:name, :notes, attrs_attributes: [:id, :name, :type, :_destroy], \n refgenerators_ids: [], refgenerators_names: [])\n end",
"def set_genero\n @genero = Genero.find(params[:id])\n end",
"def set_genero\n @genero = Genero.find(params[:id])\n end",
"def update\n @specification = Specification.find(params[:id])\n\n respond_to do |format|\n if @specification.update_attributes(params[:specification])\n format.html { redirect_to @specification, notice: 'Specification was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n save_relations\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def genere_params\n params.require(:genere).permit(:genere_id, :name, :description)\n end",
"def update\n document = @document.revision.versions.new(document_params(true))\n if document.save\n send_emails_helper(document)\n render json: document.attributes_for_edit\n else\n render json: document.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @gig_set.update(gig_set_params)\n format.html { redirect_to edit_gig_path(@gig_set.gig) }\n format.json { redirect_to edit_gig_path(@gig_set.gig) }\n else\n format.html { redirect_to edit_gig_path(@gig_set.gig), error: \"Couldn't update set\" }\n format.json { redirect_to edit_gig_path(@gig_set.gig), status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @gig.update(gig_params)\n format.html { redirect_to @gig, notice: \"Gig was successfully updated.\" }\n format.json { render :show, status: :ok, location: @gig }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @request.assign_json_attributes(params) if @request.resume?\n respond_to do |format|\n if @request.update(request_params)\n format.html { redirect_to @request, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @request }\n else\n format.html { render :edit }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_plant\n @plant.deleted = false\n\n respond_to do |format|\n if set_attributes_from_filemaker(@plant)\n format.json do\n render status: :created,\n json: {\n id: @plant.id,\n botanical_name: @plant.botanical_name,\n alternative_names: @plant.alternative_names,\n updated_at: @plant.updated_at,\n visible: ([email protected]).to_s\n }\n end\n else\n format.json do\n render json: @plant.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def update\n if params[:resource][:document].present?\n @resource.document.purge\n @resource.document.attach(params[:resource][:document])\n end\n if params[:resource][:sample].present?\n @resource.sample.purge\n @resource.sample.attach(params[:resource][:sample])\n end\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @gato.update(gato_params)\n format.html { redirect_to @gato, notice: 'Gato was successfully updated.' }\n format.json { render :show, status: :ok, location: @gato }\n else\n format.html { render :edit }\n format.json { render json: @gato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bench_test_photo_gen = BenchTest::PhotoGen.find(params[:id])\n\n respond_to do |format|\n if @bench_test_photo_gen.update_attributes(params[:bench_test_photo_gen])\n format.html { redirect_to(@bench_test_photo_gen, :notice => 'Photo gen was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bench_test_photo_gen.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_generation\n @generation = Generation.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @gdoc.update(gdoc_params)\n format.html { redirect_to @gdoc, notice: 'Gdoc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gdoc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update\n @manifestation.assign_attributes(manifestation_params)\n\n respond_to do |format|\n if @manifestation.save\n set_creators\n\n format.html { redirect_to @manifestation, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation')) }\n format.json { head :no_content }\n else\n prepare_options\n format.html { render action: \"edit\" }\n format.json { render json: @manifestation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @taker = Taker.find(params[:id])\n\n respond_to do |format|\n if @taker.update_attributes(params[:taker])\n format.html { redirect_to @taker, notice: 'Taker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end",
"def update\n respond_to do |format|\n if @generic.update(generic_params)\n format.html { redirect_to @generic, notice: 'Generic was successfully updated.' }\n format.json { render :show, status: :ok, location: @generic }\n else\n format.html { render :edit }\n format.json { render json: @generic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:recipe][:ingredient_ids] ||= []\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_or_update_profile_configuration(args = {}) \n id = args['profileId']\n temp_path = \"/profiles.json/{profileId}/configuration\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"profileId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n @golfer = Golfer.find(params[:id])\n\n respond_to do |format|\n if @golfer.update_attributes(params[:golfer])\n format.html { redirect_to @golfer, notice: 'Golfer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @golfer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def from_merge_patch_json\n if request.patch?\n from_json\n else\n 415\n end\n end",
"def update\n concat_phone_numbers params[:guest]\n @tablet_guest = Tablet::Guest.find(params[:id])\n\n respond_to do |format|\n if @tablet_guest.update_attributes(params[:guest])\n format.json { render :json => @tablet_guest }\n else\n format.json { render :json => @tablet_guest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @descriptor_generico = DescriptorGenerico.find(params[:id])\n\n respond_to do |format|\n if @descriptor_generico.update_attributes(params[:descriptor_generico])\n flash[:notice] = 'Descriptor Generico se ha actualizado con exito.'\n format.html { redirect_to(admin_descriptor_genericos_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @descriptor_generico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @grm_grappt = GrmGrappt.find(params[:id])\n\n respond_to do |format|\n if @grm_grappt.update_attributes(params[:grm_grappt])\n format.html { redirect_to @grm_grappt, notice: 'Grooming appointment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @grm_grappt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @person = @profissional.person\n if @person.update(profissional_params[:person_attributes])\n if profissional_params[:specialization].present?\n @profissional.update_attributes(:specialization => profissional_params[:specialization])\n format.html { redirect_to @profissional, notice: 'Profissional was successfully updated.' }\n format.json { render :show, status: :ok, location: @profissional }\n else\n format.html { render :edit }\n format.json { render json: @profissional.errors, status: :unprocessable_entity }\n end\n\n end\n end\n end",
"def update\n create\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @allergens_ingredient.update(allergens_ingredient_params)\n format.html { redirect_to @allergens_ingredient, notice: 'Allergens ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @allergens_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @allergens_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @goody = Goody.find(params[:id])\n\n respond_to do |format|\n if @goody.update_attributes(params[:goody])\n format.html { redirect_to @goody, notice: 'Goody was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goody.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_with []\n end",
"def update\n respond_to do |format|\n if @gato.update(gato_params)\n format.html { redirect_to gatos_url, notice: 'Gato actualizado.' }\n format.json { render :show, status: :ok, location: @gato }\n else\n format.html { render :edit }\n format.json { render json: @gato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @gameroom.update(gameroom_params)\n format.html { redirect_to @gameroom, notice: 'Gameroom was successfully updated.' }\n format.json { render :show, status: :ok, location: @gameroom }\n else\n format.html { render :edit }\n format.json { render json: @gameroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pg_first.update(pg_first_params)\n format.html { redirect_to @pg_first, notice: 'Pg first was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pg_first.errors, status: :unprocessable_entity }\n end\n end\n end",
"def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def patch(path, **args); end",
"def update\n put :update\n end",
"def update\n @gasto = Gasto.find(params[:id])\n\n respond_to do |format|\n if @gasto.update_attributes(params[:gasto])\n format.html { redirect_to @gasto, notice: 'Gasto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gasto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n\n # Set the original profession ID attribute to match the profession id of\n # the recipe group.\n @original_profession_id = recipe_group.profession.id\n\n respond_with(recipe_group)\n\n end"
] | [
"0.6585978",
"0.6511767",
"0.6459439",
"0.6459439",
"0.6335657",
"0.6257809",
"0.6228514",
"0.61052334",
"0.6002895",
"0.59362787",
"0.5845462",
"0.5836802",
"0.57950205",
"0.57382905",
"0.56891745",
"0.56534123",
"0.56159323",
"0.5595707",
"0.55128634",
"0.54778814",
"0.54765713",
"0.5475961",
"0.5475961",
"0.54434097",
"0.5425601",
"0.5425601",
"0.53816247",
"0.53816247",
"0.5326213",
"0.5322869",
"0.5304926",
"0.52900034",
"0.527039",
"0.5265319",
"0.52506363",
"0.5244568",
"0.5237192",
"0.5237192",
"0.5235964",
"0.5233663",
"0.5226965",
"0.5226965",
"0.52216244",
"0.5219636",
"0.5205355",
"0.51993287",
"0.5194348",
"0.51730466",
"0.51565915",
"0.51564777",
"0.51512706",
"0.51505727",
"0.51495504",
"0.5147873",
"0.514611",
"0.51455003",
"0.51387644",
"0.5135348",
"0.5135348",
"0.51348287",
"0.5127018",
"0.5126687",
"0.5120567",
"0.5117961",
"0.5110634",
"0.5109996",
"0.51086044",
"0.5106069",
"0.5104412",
"0.51031506",
"0.5100822",
"0.5098472",
"0.5098078",
"0.5095173",
"0.5094493",
"0.5092006",
"0.5091323",
"0.50909865",
"0.50848424",
"0.5084077",
"0.5074022",
"0.5071583",
"0.5068414",
"0.5061489",
"0.5060942",
"0.50587505",
"0.5056072",
"0.50553674",
"0.5043589",
"0.5040414",
"0.50398386",
"0.50395024",
"0.5034477",
"0.50298464",
"0.5026951",
"0.5024265",
"0.50080407",
"0.4998875",
"0.49934268",
"0.49931222"
] | 0.54898703 | 19 |
DELETE /generations/1 DELETE /generations/1.json | def destroy
@generation = Generation.find(params[:id])
@generation.destroy
redirect_to admin_generations_path, notice: "Generación Eliminada"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n Generator.where(id: params[:id] ).first.destroy\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generation = Generation.find(params[:id])\n @generation.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_generations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gen = Gen.find(params[:id])\n @gen.destroy\n\n respond_to do |format|\n format.html { redirect_to gens_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generation.destroy\n respond_to do |format|\n format.html { redirect_to generations_my_url, notice: 'Сгенерированные варианты были успешно удалены.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @small_generator = SmallGenerator.find(params[:id])\n @small_generator.destroy\n\n respond_to do |format|\n format.html { redirect_to small_generators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generator.destroy\n respond_to do |format|\n format.html { redirect_to generators_url, notice: 'Generator was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generator.destroy\n respond_to do |format|\n format.html { redirect_to generators_url, notice: 'Generator was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generator_info = GeneratorInfo.find(params[:id])\n @generator_info.destroy\n\n respond_to do |format|\n format.html { redirect_to generator_infos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @genere.destroy\n respond_to do |format|\n format.html { redirect_to generes_url, notice: 'Genere was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generator = Generator.find(params[:id])\n\n respond_to do |format|\n if @generator.destroy\n flash[:success] = 'Generator was removed'\n format.html { redirect_to admin_generators_path }\n format.json { head :ok }\n else\n flash[:error] = @generator.errors.full_messages.join('')\n format.html { redirect_to admin_generator_path(@generator.id) }\n format.json { render json: @generator.errors.full_messages.join(''), status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @genotype = Genotype.find(params[:id])\n @genotype.destroy\n\n respond_to do |format|\n format.html { redirect_to genotypes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @genero.destroy\n respond_to do |format|\n flash[:success] = \"Gênero #{@genero.nome} foi excluido com sucesso!\"\n format.html { redirect_to generos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @gpath = Gpath.find(params[:id])\n @gpath.destroy\n\n respond_to do |format|\n format.html { redirect_to gpaths_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gen_attraction.destroy\n respond_to do |format|\n format.html { redirect_to gen_attractions_url, notice: 'Gen attraction was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n super \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n @general = General.find(params[:id])\n @general.destroy\n\n respond_to do |format|\n format.html { redirect_to generals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gig_request = GigRequest.find(params[:id])\n @gig_request.destroy\n\n respond_to do |format|\n format.html { redirect_to gig_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ocs_generada.destroy\n respond_to do |format|\n format.html { redirect_to ocs_generadas_url, notice: 'Ocs generada was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generic.destroy\n respond_to do |format|\n format.html { redirect_to generics_url, notice: 'Combination dose was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @routed_generic.destroy\n respond_to do |format|\n format.html { redirect_to routed_generics_url, notice: 'Combination dose was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @opportunity_generator = OpportunityGenerator.find(params[:id])\n @opportunity_generator.destroy\n flash_message('Opportunity generator', true)\n\n respond_to do |format|\n format.html { redirect_to opportunity_generators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @go = Go.find(params[:id])\n @go.destroy\n\n respond_to do |format|\n format.html { redirect_to manager_gos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generic.destroy\n respond_to do |format|\n format.html { redirect_to generics_url, notice: 'Generic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @gig_request.destroy\n respond_to do |format|\n format.html { redirect_to gig_requests_url, notice: 'Gig request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gentre.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @impgen = Impgen.find(params[:id])\n @impgen.destroy\n\n respond_to do |format|\n format.html { redirect_to impgens_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gig = Gig.find(params[:id])\n @gig.destroy\n\n respond_to do |format|\n format.html { redirect_to gigs_url }\n format.json { render json: nil, status: :ok }\n end\n end",
"def destroy\n @specific_gravity.destroy\n respond_to do |format|\n format.html { redirect_to @batch, notice: 'Specific gravity was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dis_routed_generic.destroy\n respond_to do |format|\n format.html { redirect_to dis_routed_generics_url, notice: 'Dis routed generic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @gasto = Gasto.find(params[:id])\n @gasto.destroy\n\n respond_to do |format|\n format.html { redirect_to gastos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gift_template = GiftTemplate.find(params[:id])\n @gift_template.destroy\n\n respond_to do |format|\n format.html { redirect_to gift_templates_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @genbank_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @gig_type.destroy\n respond_to do |format|\n format.html { redirect_to gig_types_url, notice: 'Gig type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @genu = Genu.find(params[:id])\n @genu.destroy\n\n respond_to do |format|\n format.html { redirect_to control_genus_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bench_test_photo_gen = BenchTest::PhotoGen.find(params[:id])\n @bench_test_photo_gen.destroy\n\n respond_to do |format|\n format.html { redirect_to(bench_test_photo_gens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gua.destroy\n respond_to do |format|\n format.html { redirect_to guas_url, notice: 'Gua was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gig.destroy\n respond_to do |format|\n format.html { redirect_to gigs_url, notice: 'Gig was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gatha.destroy\n respond_to do |format|\n format.html { redirect_to gathas_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @gig.destroy\n respond_to do |format|\n format.html { redirect_to gigs_url, notice: \"Gig was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gravity = Gravity.find(params[:id])\n @gravity.destroy\n\n respond_to do |format|\n format.html { redirect_to gravities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @made_in_g.destroy\n respond_to do |format|\n format.html { redirect_to made_in_gs_url, notice: 'Made in g was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @momsg = Momsg.find(params[:id])\n @momsg.destroy\n\n respond_to do |format|\n format.html { redirect_to momsgs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @descriptor_generico = DescriptorGenerico.find(params[:id])\n @descriptor_generico.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_descriptor_genericos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gig = Gig.find(params[:id])\n @gig.destroy\n\n respond_to do |format|\n format.html { redirect_to(gigs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gram.destroy\n respond_to do |format|\n format.html { redirect_to grams_url, notice: 'Gram was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gato.destroy\n respond_to do |format|\n format.html { redirect_to gatos_url, notice: 'Gato was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @tagg = Tagg.find(params[:id])\n @tagg.destroy\n\n respond_to do |format|\n format.html { redirect_to taggs_url }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete\n item = FormTemplate.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end",
"def destroy\n @sampling.destroy\n respond_to do |format|\n format.html { redirect_to samplings_url, notice: 'Sampling was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gene.destroy\n respond_to do |format|\n format.html { redirect_to genes_url, notice: 'Gene was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gato.destroy\n respond_to do |format|\n format.html { redirect_to gatos_url, notice: 'Gato eliminado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @galeria = Galeria.find(params[:id])\n @galeria.destroy\n\n respond_to do |format|\n format.html { redirect_to galerias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @allergen = Allergen.find(params[:id])\n @allergen.destroy\n\n respond_to do |format|\n format.html { redirect_to(allergens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @razmer_go = RazmerGo.find(params[:id])\n @razmer_go.destroy\n\n respond_to do |format|\n format.html { redirect_to razmer_gos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gravity.destroy\n respond_to do |format|\n format.html { redirect_to gravities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxirequest = Taxirequest.find(params[:id])\n @taxirequest.destroy\n\n respond_to do |format|\n format.html { redirect_to taxirequests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gang.destroy\n respond_to do |format|\n format.html { redirect_to gangs_url, notice: 'Gang was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataload_ga = DataloadGa.find(params[:id])\n @dataload_ga.destroy\n\n respond_to do |format|\n format.html { redirect_to dataload_gas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reserve_stat_has_manifestation.destroy\n\n respond_to do |format|\n format.html { redirect_to(reserve_stat_has_manifestations_url) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tipo_distribucion.destroy\n respond_to do |format|\n format.html { redirect_to tipos_distribuciones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @program_genre = ProgramGenre.find(params[:id])\n @program_genre.destroy\n\n respond_to do |format|\n format.html { redirect_to program_genres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @grm_grappt = GrmGrappt.find(params[:id])\n @grm_grappt.destroy\n\n respond_to do |format|\n format.html { redirect_to grm_grappts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @m_general = MGeneral.find(params[:id])\n @m_general.destroy\n\n respond_to do |format|\n format.html { redirect_to(m_generals_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gin.destroy\n respond_to do |format|\n format.html { redirect_to gins_url, notice: 'Gin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gakka.destroy\n respond_to do |format|\n format.html { redirect_to gakkas_url, notice: \"Gakka was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @g_file.destroy\n respond_to do |format|\n format.html { redirect_to g_files_url, notice: 'G file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pg_first.destroy\n respond_to do |format|\n format.html { redirect_to pg_firsts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gatineo.destroy\n respond_to do |format|\n format.html { redirect_to gatineos_url, notice: 'Gatineo apagado com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @grupa = Grupa.find(params[:id])\n @grupa.destroy\n\n respond_to do |format|\n format.html { redirect_to grupy_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gomi.destroy\n respond_to do |format|\n format.html { redirect_to gomis_url, notice: 'Gomi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @immigrant = Immigrant.find(params[:id])\n @immigrant.destroy\n\n respond_to do |format|\n format.html { redirect_to immigrants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n gig = @gig_set.gig\n @gig_set.destroy\n gig.gig_sets.each_with_index do |set, ix|\n set.number = ix + 1\n set.save!\n end\n\n respond_to do |format|\n format.html { redirect_to edit_gig_path(gig) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gommi.destroy\n respond_to do |format|\n format.html { redirect_to gommis_url, notice: 'Gommi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n @allergen.destroy\n respond_to do |format|\n #format.html { redirect_to allergens_url, notice: 'Allergen was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @gp40.destroy\n respond_to do |format|\n format.html { redirect_to gp40s_url, notice: 'Gp40 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @grooming.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Visit was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gudang.destroy\n respond_to do |format|\n format.html { redirect_to gudangs_url, notice: 'Gudang was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @ginasio = Ginasio.find(params[:id])\n @ginasio.destroy\n\n respond_to do |format|\n format.html { redirect_to ginasios_url, :flash => { :notice => 'Ginasio apagado.' } }\n format.json { head :ok }\n end\n end",
"def destroy\n @gene_name = GeneName.find(params[:id])\n @gene_name.destroy\n\n respond_to do |format|\n format.html { redirect_to gene_names_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gonzo.destroy\n respond_to do |format|\n format.html { redirect_to gonzos_url, notice: 'Gonzo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete!\n request! :delete\n end",
"def destroy\n @gizmo.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Gizmo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gift_request = GiftRequest.find(params[:id])\n @gift_request.destroy\n\n respond_to do |format|\n format.html { redirect_to gift_requests_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.76810807",
"0.7625209",
"0.7541312",
"0.7512504",
"0.73264915",
"0.73050326",
"0.73050326",
"0.7105164",
"0.7092853",
"0.7059248",
"0.6804798",
"0.6790985",
"0.6757595",
"0.67345625",
"0.6710581",
"0.66901994",
"0.664723",
"0.6640292",
"0.6623032",
"0.6612428",
"0.6608636",
"0.6561886",
"0.6538401",
"0.64985406",
"0.6494493",
"0.6483326",
"0.6478727",
"0.64725494",
"0.6468994",
"0.64549243",
"0.6430398",
"0.6423621",
"0.64181435",
"0.64117384",
"0.6389961",
"0.63870907",
"0.6372284",
"0.63683134",
"0.6365869",
"0.6350966",
"0.63446933",
"0.63439924",
"0.63400406",
"0.6336737",
"0.6334263",
"0.6333253",
"0.6331425",
"0.6322364",
"0.6307929",
"0.6306071",
"0.63051945",
"0.6283297",
"0.6281233",
"0.6278826",
"0.62765",
"0.62765",
"0.62765",
"0.62765",
"0.6275901",
"0.62748164",
"0.6272848",
"0.62706554",
"0.62701666",
"0.6269017",
"0.6261665",
"0.6244054",
"0.6237935",
"0.6232227",
"0.622677",
"0.6224904",
"0.62194574",
"0.6218746",
"0.6216136",
"0.6214853",
"0.621382",
"0.6209089",
"0.62070644",
"0.620645",
"0.6203719",
"0.62033087",
"0.6197279",
"0.61969763",
"0.61957335",
"0.6194797",
"0.61938465",
"0.6190727",
"0.61898404",
"0.61889625",
"0.61857504",
"0.61857504",
"0.61857384",
"0.6184923",
"0.617922",
"0.61746293",
"0.6172307",
"0.61722016",
"0.6171043",
"0.6170865",
"0.616524",
"0.6163913"
] | 0.71145606 | 7 |
GET /pop_elements GET /pop_elements.json | def index
@pop_elements = PopElement.all
@orders = Order.user_order(current_user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop\n raise 'No such element' if @elements.length == 0\n @elements.slice!(-1)\n end",
"def destroy\n @pop_element.destroy\n respond_to do |format|\n format.html { redirect_to pop_elements_url, notice: 'Pop element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def set_pop_element\n @pop_element = PopElement.find(params[:id])\n end",
"def pop(pops)\n view.update_many(\"$pop\" => collect_operations(pops))\n end",
"def using_pop(array)\n element = array.pop\n element\nend",
"def elements\n return @elements\n end",
"def elements; end",
"def elements; end",
"def elements; end",
"def each_pop #:yields: popped\n until empty?\n yield pop\n end\n nil\n end",
"def page_elements\n []\n end",
"def pop\n curr = items\n ret = curr.pop\n\n serialize(curr)\n\n ret.nil? ? nil : ret\n end",
"def pop\n end",
"def request_elements\n REQUEST_ELEMENTS\n end",
"def create\n @pop_element = PopElement.new(pop_element_params)\n\n respond_to do |format|\n if @pop_element.save\n format.html { redirect_to @pop_element, notice: 'Pop element was successfully created.' }\n format.json { render :show, status: :created, location: @pop_element }\n else\n format.html { render :new }\n format.json { render json: @pop_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def response_elements\n RESPONSE_ELEMENTS\n end",
"def sub_items\n elems\n end",
"def popd\n\t\t\tpush [:pop]\n\t\t\tdip\n\t\tend",
"def pop\n \[email protected]\n\trender :json => {:result => \"Error\", :message => \"Not implemented\"}\n end",
"def list_elements(path)\n return @element_list\n end",
"def elements\n begin\n if %w(tags posts).include?(@resource.to_s)\n return parsed_response[@resource.to_s][singular_r_name] || []\n elsif %w(bundles).include?(@resource.to_s)\n return parsed_response[@resource.to_s].empty? ? [] : parsed_response[@resource.to_s].map {|el| el[singular_r_name] } \n end\n rescue NoMethodError => e \n return parsed_response\n end\n end",
"def pop()\n \n end",
"def pop()\n \n end",
"def pop()\n \n end",
"def rest\n\t\t\tarray = pop\n\t\t\traise ArgumentError, \"REST: first element is not an Array.\" unless array.is_a? Array\n\t\t\traise ArgumentError, \"REST: empty array.\" if array.length == 0\n\t\t\tarray.delete_at 0\n\t\t\tpush array\n\t\tend",
"def elements\n # execute query\n ordered_objects.compact.uniq\n end",
"def elements(); @records.get(Elements); end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def \n \n using_pop(array)\n \n\n array.pop()\n \nend",
"def update\n respond_to do |format|\n if @pop_element.update(pop_element_params)\n format.html { redirect_to @pop_element, notice: 'Pop element was successfully updated.' }\n format.json { render :show, status: :ok, location: @pop_element }\n else\n format.html { render :edit }\n format.json { render json: @pop_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @pm_elements = PmElement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pm_elements }\n end\n end",
"def pop \r\n @data.pop\r\n end",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop()\nend",
"def using_pop(array)\n array.pop\nend",
"def index\n @elements = Element.all\n end",
"def pop()\n @data.pop\n end",
"def pop\r\n # What does array.pop do? It takes the last \r\n # item of a list. We want this method to return\r\n # the last item. So maybe we can do something like:\r\n # return @data.last\r\n end",
"def pop() end",
"def using_pop(arr)\n arr.pop\nend",
"def elements; @feature['elements'] ||= [] end",
"def destroy\n @element.destroy\n respond_with :elements\n end",
"def pop\r\n # IMPLEMENT ME\r\n end",
"def items\n (rest.elements || []).inject([first]) { |list, el| list << el.item }\n end",
"def each_pop\n loop do\n if head == nil\n break\n else\n yield(pop)\n end\n end\n end",
"def pop\n @collection.pop\n end",
"def element_set\n return []\n end",
"def pop_element_params\n params.require(:pop_element).permit(:name, :price, :master_type, :sub_type, :availability)\n end",
"def using_pop (array)\n return array.pop\nend",
"def pop\n list.pop\n end",
"def elements\n @resolver.elements\n end",
"def pop\n # IMPLEMENT ME\n end",
"def get_elements\n @current_page[:elements] = {}\n if @current_page[:page_data].user_data.has_key?('elements')\n @current_page[:page_data].user_data['elements'].each do |k, locator|\n @current_page[:elements][k] = @driver.find_element(locator).text\n end\n end \n end",
"def pop\n @read_later = ReadLater.pop!\n\n render json: @read_later\n end",
"def pop\n @obj.pop\n end",
"def feed_elements\n elements.named(definition['feed_elements'])\n end",
"def pop\n @events.pop\n end",
"def available_elements\n definition['elements'] || []\n end",
"def index\n @populations = Population.all\n end",
"def extra_element_params\n []\n end",
"def pop\n @a.pop\n end",
"def __elements\n @__elements ||= {}\n end",
"def get_elements(path)\n elements = self./(path)\n return nil unless elements\n elements = elements.map{|element| Element.new(element)}\n end",
"def pop\r\n @arr.shift\r\n end",
"def get_elements(path)\n elements = self./(path)\n return unless elements\n elements = elements.map{|element| Element.new(element)}\n end",
"def elements\n find_by_tag('*')\n end",
"def list_arrays_assigned_to_profile(args = {}) \n get(\"/profiles.json/#{args[:profileId]}/arrays\", args)\nend",
"def pop\n\t\t\[email protected]\n\t\tend",
"def using_pop(array)\n array = array.pop(1)\n array.pop\n\n\nend",
"def items\n res = []\n each_element('item') { |item|\n res << item\n }\n res\n end",
"def pop\n delete_at(0)\n end",
"def peek\n raise 'No such element' if @elements.length == 0\n @elements[-1]\n end",
"def friends\n #get friends page\n #get json from friends page\n #parse\n []\n end",
"def get_elements_array\n element_names\n end",
"def index\n @pe_exchange_products = PeExchangeProduct.all.page(params[:page]).per(params[:per_page])\n respond_to do |format|\n format.html\n format.json { render json:\n list_json(@pe_exchange_products, :include => [:pe_product])\n }\n end\n end",
"def index\n @user = User.find(current_user.id)\n @userpop = @user.userpop3s.all\n @usermails = @user.usermails.all\n end",
"def show\n @exitpop = Exitpop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exitpop }\n end\n end",
"def initialize\n @elements = []\n end",
"def index\n @elements = @account.elements\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @elements }\n format.json { render :json => @elements }\n end\n end",
"def element(id, params = {})\n get \"elements/#{id}\", {query: params}\n end",
"def get_items\n\t\t@arr\n\tend",
"def products\n request :public, :get, :products\n end",
"def show\n @profilepage = Profilepage.find(params[:id])\n @dataelements = @profilepage.dataelements.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profilepage }\n end\n end",
"def pop\n return nil if @elements.length == 0\n tmp = @elements.shift\n @elements.unshift @elements.pop\n heapify_down\n return tmp\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 items\n response[\"items\"]\n end",
"def index\n @event_elements = EventElement.all\n end"
] | [
"0.5957871",
"0.59574497",
"0.58689344",
"0.57009786",
"0.56459033",
"0.5609212",
"0.5464483",
"0.5464483",
"0.5464483",
"0.5452894",
"0.5425035",
"0.54077536",
"0.5375061",
"0.5355811",
"0.53151405",
"0.53111637",
"0.5288002",
"0.5250561",
"0.52495956",
"0.52224517",
"0.521917",
"0.5202704",
"0.5202704",
"0.5202704",
"0.5199788",
"0.51946557",
"0.5193849",
"0.51929283",
"0.51929283",
"0.51929283",
"0.51929283",
"0.51929283",
"0.5186328",
"0.5185101",
"0.5166425",
"0.5151998",
"0.514485",
"0.514485",
"0.514485",
"0.514485",
"0.514485",
"0.514485",
"0.514485",
"0.514485",
"0.514485",
"0.51443064",
"0.51247853",
"0.5122572",
"0.51104546",
"0.50963885",
"0.50935876",
"0.5089806",
"0.50722575",
"0.5069798",
"0.5065102",
"0.5064082",
"0.5003419",
"0.4997797",
"0.49851504",
"0.49820834",
"0.49800724",
"0.4980061",
"0.49728042",
"0.4972187",
"0.4945768",
"0.4929107",
"0.4919269",
"0.49023226",
"0.49002722",
"0.4899401",
"0.48953632",
"0.4867804",
"0.48550186",
"0.4852204",
"0.48444584",
"0.48433426",
"0.48371205",
"0.48265117",
"0.48148388",
"0.48071697",
"0.47908807",
"0.47845054",
"0.47838548",
"0.4766087",
"0.47543257",
"0.4747126",
"0.47469202",
"0.473103",
"0.47309133",
"0.4717387",
"0.4714718",
"0.47134066",
"0.47094986",
"0.47056705",
"0.4703832",
"0.4702077",
"0.4701074",
"0.4696416",
"0.469534",
"0.4682144"
] | 0.6736786 | 0 |
GET /pop_elements/1 GET /pop_elements/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pop_elements = PopElement.all\n @orders = Order.user_order(current_user)\n end",
"def set_pop_element\n @pop_element = PopElement.find(params[:id])\n end",
"def destroy\n @pop_element.destroy\n respond_to do |format|\n format.html { redirect_to pop_elements_url, notice: 'Pop element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @pop_element = PopElement.new(pop_element_params)\n\n respond_to do |format|\n if @pop_element.save\n format.html { redirect_to @pop_element, notice: 'Pop element was successfully created.' }\n format.json { render :show, status: :created, location: @pop_element }\n else\n format.html { render :new }\n format.json { render json: @pop_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pop_element.update(pop_element_params)\n format.html { redirect_to @pop_element, notice: 'Pop element was successfully updated.' }\n format.json { render :show, status: :ok, location: @pop_element }\n else\n format.html { render :edit }\n format.json { render json: @pop_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pop\n raise 'No such element' if @elements.length == 0\n @elements.slice!(-1)\n end",
"def show\n @exitpop = Exitpop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exitpop }\n end\n end",
"def using_pop(array)\n element = array.pop\n element\nend",
"def index\n @pm_elements = PmElement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pm_elements }\n end\n end",
"def element(id, params = {})\n get \"elements/#{id}\", {query: params}\n end",
"def request_elements\n REQUEST_ELEMENTS\n end",
"def getPopInfo(pop_id)\n AuthenticationHelper.loginGK()\n begin\n response = RestClient.get \"#{settings.gatekeeper}/admin/dc/#{pop_id}\", 'X-Auth-Token' => settings.gk_token, :content_type => :json\n rescue RestClient::ResourceNotFound\n halt 404, \"PoP not found.\"\n rescue => e\n logger.error e\n if (defined?(e.response)).nil?\n error = {:info => \"The PoP is not registered in Gatekeeper\"}\n halt 503, \"The PoP is not registered in Gatekeeper\"\n end\n end\n\n return response\n end",
"def pop\n \[email protected]\n\trender :json => {:result => \"Error\", :message => \"Not implemented\"}\n end",
"def pop_element_params\n params.require(:pop_element).permit(:name, :price, :master_type, :sub_type, :availability)\n end",
"def show\n @popularty = Popularty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @popularty }\n end\n end",
"def pop\n curr = items\n ret = curr.pop\n\n serialize(curr)\n\n ret.nil? ? nil : ret\n end",
"def show\n @profilepage = Profilepage.find(params[:id])\n @dataelements = @profilepage.dataelements.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profilepage }\n end\n end",
"def index\n @elements = Element.all\n end",
"def pop\n end",
"def pop(pops)\n view.update_many(\"$pop\" => collect_operations(pops))\n end",
"def response_elements\n RESPONSE_ELEMENTS\n end",
"def population\n @populations.first\n end",
"def peek\n raise 'No such element' if @elements.length == 0\n @elements[-1]\n end",
"def show\n @element = Element.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @element }\n end\n end",
"def elements\n return @elements\n end",
"def elements; end",
"def elements; end",
"def elements; end",
"def sub_items\n elems\n end",
"def rest\n\t\t\tarray = pop\n\t\t\traise ArgumentError, \"REST: first element is not an Array.\" unless array.is_a? Array\n\t\t\traise ArgumentError, \"REST: empty array.\" if array.length == 0\n\t\t\tarray.delete_at 0\n\t\t\tpush array\n\t\tend",
"def pop()\n \n end",
"def pop()\n \n end",
"def pop()\n \n end",
"def new\n @exitpop = Exitpop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exitpop }\n end\n end",
"def list_elements(path)\n return @element_list\n end",
"def elements(); @records.get(Elements); end",
"def popd\n\t\t\tpush [:pop]\n\t\t\tdip\n\t\tend",
"def pop\r\n # What does array.pop do? It takes the last \r\n # item of a list. We want this method to return\r\n # the last item. So maybe we can do something like:\r\n # return @data.last\r\n end",
"def getElement\n @element\n end",
"def index\n @elements = @account.elements\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @elements }\n format.json { render :json => @elements }\n end\n end",
"def index\n @pushups = current_user.pushups.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pushups }\n end\n end",
"def elements\n begin\n if %w(tags posts).include?(@resource.to_s)\n return parsed_response[@resource.to_s][singular_r_name] || []\n elsif %w(bundles).include?(@resource.to_s)\n return parsed_response[@resource.to_s].empty? ? [] : parsed_response[@resource.to_s].map {|el| el[singular_r_name] } \n end\n rescue NoMethodError => e \n return parsed_response\n end\n end",
"def index\n @populations = Population.all\n end",
"def pull_json( opts = {} )\n messages = store.pull( opts )\n if messages.empty?\n \"[]\"\n else\n messages_to_json( messages )\n end\n end",
"def destroy\n @element.destroy\n respond_with :elements\n end",
"def each_pop #:yields: popped\n until empty?\n yield pop\n end\n nil\n end",
"def friends\n #get friends page\n #get json from friends page\n #parse\n []\n end",
"def elements; @feature['elements'] ||= [] end",
"def element; end",
"def element; end",
"def element; end",
"def element; end",
"def index\n @neural_populations = NeuralPopulation.find(:all, :limit=>250)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @neural_populations }\n end\n end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def show\n @user = User.find(current_user.id)\n @userpop = @user.userpop3s.all\n @pop = @user.userpop3s.find_by(id: params[:userpop3_id])\n @usermails = @pop.usermails.all\n end",
"def index\n @pubs = Pub.all\n\n render json: @pubs\n end",
"def show\n @pushup = Pushup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pushup }\n end\n end",
"def page_elements\n []\n end",
"def new\n @element = Element.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @element }\n end\n end",
"def new\n @popularty = Popularty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @popularty }\n end\n end",
"def pop\r\n # IMPLEMENT ME\r\n end",
"def pop\n @read_later = ReadLater.pop!\n\n render json: @read_later\n end",
"def member_application_received\n @member = Member.find(params[:id])\n @page = Page.find_by_id(9)\n #@products = Product.membership.all\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @member }\n end\n end",
"def pop() end",
"def index\n @pe_exchange_products = PeExchangeProduct.all.page(params[:page]).per(params[:per_page])\n respond_to do |format|\n format.html\n format.json { render json:\n list_json(@pe_exchange_products, :include => [:pe_product])\n }\n end\n end",
"def items\n (rest.elements || []).inject([first]) { |list, el| list << el.item }\n end",
"def extra_element_params\n []\n end",
"def pop\n list.pop\n end",
"def get_elements\n @current_page[:elements] = {}\n if @current_page[:page_data].user_data.has_key?('elements')\n @current_page[:page_data].user_data['elements'].each do |k, locator|\n @current_page[:elements][k] = @driver.find_element(locator).text\n end\n end \n end",
"def index\n @user = User.find(current_user.id)\n @userpop = @user.userpop3s.all\n @usermails = @user.usermails.all\n end",
"def pop\n @collection.pop\n end",
"def \n \n using_pop(array)\n \n\n array.pop()\n \nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def list_arrays_assigned_to_profile(args = {}) \n get(\"/profiles.json/#{args[:profileId]}/arrays\", args)\nend",
"def get_element(path)\n elements = get_elements(path)\n elements[0] if elements\n end",
"def element\n @collection[index]\n end",
"def cmd_get argv\n setup argv\n e = @hash['element']\n response = @api.get(e)\n msg JSON.pretty_generate(response)\n return response\n end",
"def pop \r\n @data.pop\r\n end",
"def set_kpop\n @kpop = Kpop.find(params[:id])\n end",
"def getOpenPullRequests()\n jsonHash = getJson(@url_pullrequests + \"/?state=OPEN\")\n ids = []\n jsonHash[\"values\"].each { |pr| ids << pr[\"id\"].to_i }\n while jsonHash.has_key? \"next\"\n jsonHash = getJson(jsonHash[\"next\"])\n jsonHash[\"values\"].each { |pr| ids << pr[\"id\"].to_i }\n end\n return ids\n end",
"def member_application_received\n @member = Member.find(params[:id])\n @products = Product.membership.all\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @member }\n end\n end",
"def pop\n delete_at(0)\n end",
"def pop\n # IMPLEMENT ME\n end",
"def using_pop(array)\n array.pop\nend",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pushes }\n end\n end",
"def pop()\n @data.pop\n end",
"def using_pop(array)\n array.pop()\nend",
"def last_pop\n @api_adapter.last_pop_from_queue(self.name)\n end",
"def index\n @potluck_items = @event.potluck_items\n\n respond_to do |format|\n format.html { render :layout => false }# index.html.erb\n format.json { render json: @event.get_potluck_items_for_guests.to_json }\n end\n end"
] | [
"0.6431328",
"0.63912076",
"0.61080146",
"0.5964796",
"0.57741797",
"0.56562006",
"0.53761244",
"0.5345411",
"0.532197",
"0.5264794",
"0.52607346",
"0.5248459",
"0.5225622",
"0.52188843",
"0.5149898",
"0.51099485",
"0.51062495",
"0.50872844",
"0.50872016",
"0.50702053",
"0.5069965",
"0.5044465",
"0.5034404",
"0.5031004",
"0.50251734",
"0.501768",
"0.501768",
"0.501768",
"0.49989164",
"0.4991967",
"0.4983041",
"0.4983041",
"0.4983041",
"0.49460214",
"0.49409455",
"0.49377075",
"0.49220803",
"0.490979",
"0.48937684",
"0.4885254",
"0.4882197",
"0.48811603",
"0.48560432",
"0.4851581",
"0.48497242",
"0.48367897",
"0.48226893",
"0.48057166",
"0.48048404",
"0.48048404",
"0.48048404",
"0.48048404",
"0.4801956",
"0.48018396",
"0.48018396",
"0.48018396",
"0.48018396",
"0.48018396",
"0.47987765",
"0.47933078",
"0.47802463",
"0.47752148",
"0.47664922",
"0.4762543",
"0.4754253",
"0.4732074",
"0.4730552",
"0.47303727",
"0.4728884",
"0.47252798",
"0.4718973",
"0.47111535",
"0.47014067",
"0.46889225",
"0.4687162",
"0.46818176",
"0.46738118",
"0.46738118",
"0.46738118",
"0.46738118",
"0.46738118",
"0.46738118",
"0.46738118",
"0.46738118",
"0.46738118",
"0.46701393",
"0.46696347",
"0.46654302",
"0.4665332",
"0.46641704",
"0.4661377",
"0.46612337",
"0.46556172",
"0.46534187",
"0.46525237",
"0.4650159",
"0.46468937",
"0.46452838",
"0.4644759",
"0.46430677",
"0.46410534"
] | 0.0 | -1 |
POST /pop_elements POST /pop_elements.json | def create
@pop_element = PopElement.new(pop_element_params)
respond_to do |format|
if @pop_element.save
format.html { redirect_to @pop_element, notice: 'Pop element was successfully created.' }
format.json { render :show, status: :created, location: @pop_element }
else
format.html { render :new }
format.json { render json: @pop_element.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pop_element\n @pop_element = PopElement.find(params[:id])\n end",
"def destroy\n @pop_element.destroy\n respond_to do |format|\n format.html { redirect_to pop_elements_url, notice: 'Pop element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def pop_element_params\n params.require(:pop_element).permit(:name, :price, :master_type, :sub_type, :availability)\n end",
"def post_elements\n programme_id = params[:programme][:id]\n ProgrammeElement.destroy_all ['programme_id = ?', programme_id ]\n logger.info(\"programme=#{programme_id}\");\n logger.info(params.inspect);\n \n pelist = params[:programme_elements]\n # Add in the new items. From params return if OK. \n index=0;\n while ( pelist[index.to_s] )\n cn=pelist[index.to_s][:column_name]\n unless cn.blank?\n pe=ProgrammeElement.new( pelist[index.to_s] )\n pe.programme_id = programme_id\n pe.position = index\n # pe.column_name = cn # assigned in the new above !!\n pe.save!\n end\n index += 1;\n end\n redirect_to :action => 'show', :id => programme_id\n end",
"def pop(pops)\n view.update_many(\"$pop\" => collect_operations(pops))\n end",
"def index\n @pop_elements = PopElement.all\n @orders = Order.user_order(current_user)\n end",
"def update\n respond_to do |format|\n if @pop_element.update(pop_element_params)\n format.html { redirect_to @pop_element, notice: 'Pop element was successfully updated.' }\n format.json { render :show, status: :ok, location: @pop_element }\n else\n format.html { render :edit }\n format.json { render json: @pop_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n params[:elements].values.each do |elem|\n puts 'el', elem\n elem_to_save = Element.create (elem)\n @design.elements << elem_to_save\n end\n\n\n respond_to do |format|\n if @design.id\n format.html { redirect_to edit_design_path(@design), notice: 'Design was successfully created.' }\n format.json { render :json => @design}\n else\n format.html { render :new }\n format.json { render json: @design.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def pop\n raise 'No such element' if @elements.length == 0\n @elements.slice!(-1)\n end",
"def pop\n curr = items\n ret = curr.pop\n\n serialize(curr)\n\n ret.nil? ? nil : ret\n end",
"def using_pop(array)\n element = array.pop\n element\nend",
"def pop\n end",
"def popd\n\t\t\tpush [:pop]\n\t\t\tdip\n\t\tend",
"def extra_element_params\n []\n end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop()\n \n end",
"def pop()\n \n end",
"def pop()\n \n end",
"def push(element)\r\n # IMPLEMENTME!\r\n end",
"def pop \r\n @data.pop\r\n end",
"def elements; @feature['elements'] ||= [] end",
"def pop() end",
"def pop()\n @data.pop\n end",
"def update\n\n @design.elements.destroy_all\n\n params[:elements].values.each_with_index do |elem,i|\n puts elem\n # if @design = Design.find_or_create_by(id: @design_id, name: params[:name], user: @current_user)\n elem_to_save = Element.create (elem)\n @design.elements << elem_to_save\n end\n\n\n respond_to do |format|\n if @design.id\n format.html { redirect_to edit_design_path(@design), notice: 'Design was successfully created.' }\n format.json { render :json => @design}\n else\n format.html { render :new }\n format.json { render json: @design.errors, status: :unprocessable_entity }\n end\n end\n end",
"def push(element); end",
"def \n \n using_pop(array)\n \n\n array.pop()\n \nend",
"def destroy\n @element.destroy\n respond_with :elements\n end",
"def pop_inv(inv, size) \n\n items = Array.new;\n\n # Populate with size\n case size\n when :pocket\n @book = Item.new([\"book\", \"novel\"], \"1984\", \"An Orwellian Nightmare\")\n @pen = Item.new([\"pen\", \"biro\"], \"4-Pen\", \"A four pen with red, green, blue and black inks\")\n @phone = Item.new([\"phone\", \"cell\"], \"iPhone\", \"An iPhone 5\") \n items.push(@book, @pen, @phone)\n \n when :wallet\n @myki = Item.new([\"myki\", \"travelcard\"], \"Myki\", \"An consession myki card\")\n @idcard = Item.new([\"id\", \"card\"], \"ID card\", \"Swinny ID card\")\n @cash = Item.new([\"cash\", \"money\"], \"$20 banknote\", \"A 20 dollar banknote\") \n items.push(@myki, @idcard, @cash)\n end\n \n #put the items in\n items.each do |item|\n inv.put(item)\n end\nend",
"def each_pop #:yields: popped\n until empty?\n yield pop\n end\n nil\n end",
"def populate\n populator = Spree::OrderPopulator.new(current_order(true), current_currency)\n if populator.populate(params.slice(:products, :variants, :quantity))\n fire_event('spree.cart.add')\n fire_event('spree.order.contents_changed')\n respond_with(@order) do |format|\n format.html { redirect_to cart_path }\n format.js { @populator = populator; render }\n end\n else\n flash[:error] = populator.errors.full_messages.join(\" \")\n redirect_to :back\n end\n end",
"def massage_param_elements!(params)\n elements = params[:elements]\n params.delete(:elements)\n elements.each{|element|\n params[element.to_sym] = element\n }\n end",
"def push(element)\n # IMPLEMENT ME!\n end",
"def using_pop(array)\n array.pop()\nend",
"def pop\r\n # IMPLEMENT ME\r\n end",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def pop\n \[email protected]\n\trender :json => {:result => \"Error\", :message => \"Not implemented\"}\n end",
"def elementsToJSON(oldData, elemPubID, submitterEmail, metaHash, ark, feedFile)\n\n # eSchol ARK identifier (provisional ID minted previously for new items)\n data = oldData ? oldData.clone : {}\n data[:id] = ark\n\n # Identify the source system\n data[:sourceName] = 'elements'\n data[:sourceID] = elemPubID\n data[:sourceFeedLink] = \"#{$submitServer}/bitstreamTmp/#{feedFile}\"\n\n # Object type, flags, status, etc.\n elementsPubType = metaHash.delete('object.type') || raise(\"missing object.type\")\n elementsPubStatus = metaHash['publication-status'] || nil\n elementsIsReviewed = metaHash.delete('is-reviewed') || nil\n \n data[:isPeerReviewed] = getDefaultPeerReview(elementsIsReviewed, elementsPubType, elementsPubStatus)\n\n data[:type] = convertPubType(elementsPubType)\n data[:isPeerReviewed] = true # assume all Elements items are peer reviewed\n if (elementsPubType == 'preprint' ||\n (elementsPubType == 'journal-article' &&\n (elementsPubStatus == 'In preparation' ||\n elementsPubStatus == 'Submitted' ||\n elementsPubStatus == 'Unpublished') ) ) \n data[:isPeerReviewed] = false # assume preprints are not peer reviewed\n end \n data[:pubRelation] = convertPubStatus(metaHash.delete('publication-status'))\n data[:embargoExpires] = assignEmbargo(metaHash)\n\n # Author and editor metadata.\n metaHash['authors'] && data[:authors] = transformPeople(metaHash.delete('authors'), nil)\n if metaHash['editors'] || metaHash['advisors']\n contribs = []\n metaHash['editors'] and contribs += (transformPeople(metaHash.delete('editors'), 'EDITOR') || [])\n metaHash['advisors'] and contribs += (transformPeople(metaHash.delete('advisors'), 'ADVISOR') || [])\n !contribs.empty? and data[:contributors] = contribs\n end\n\n # Other top-level fields\n metaHash.key?('title') and data[:title] = sanitizeHTML(metaHash.delete('title')).gsub(/\\s+/, ' ').strip\n metaHash.key?('abstract') and data[:abstract] = sanitizeHTML(metaHash.delete('abstract'))\n data[:localIDs] = []\n metaHash.key?('doi') and data[:localIDs] << { id: metaHash.delete('doi'), scheme: 'DOI' }\n data[:localIDs] << {id: elemPubID, scheme: 'OA_PUB_ID'}\n metaHash.key?('fpage') and data[:fpage] = metaHash.delete('fpage')\n metaHash.key?('lpage') and data[:lpage] = metaHash.delete('lpage')\n metaHash.key?('keywords') and data[:keywords] = convertKeywords(metaHash.delete('keywords'))\n if metaHash.key?('requested-reuse-licence.short-name')\n if metaHash['requested-reuse-licence.short-name'] != \"No Licence\"\n ccCode = metaHash.delete('requested-reuse-licence.short-name')\n data[:rights] = \"https://creativecommons.org/licenses/#{ccCode.sub(\"CC \", \"\").downcase}/4.0/\"\n end\n end\n metaHash.key?('funder-name') and data[:grants] = convertFunding(metaHash)\n #metaHash.key?('funder-type-display-name')\n\n # Context\n assignSeries(data, getCompletionDate(data, metaHash), metaHash)\n lookupRepecID(elemPubID) and data[:localIDs] << { scheme: 'OTHER_ID', subScheme: 'repec', id: lookupRepecID(elemPubID) }\n metaHash.key?(\"report-number\") and data[:localIDs] << {\n scheme: 'OTHER_ID', subScheme: 'report', id: metaHash.delete('report-number')\n }\n metaHash.key?(\"issn\") and data[:issn] = metaHash.delete(\"issn\")\n metaHash.key?(\"isbn-13\") and data[:isbn] = metaHash.delete(\"isbn-13\") # for books and chapters\n metaHash.key?(\"journal\") and data[:journal] = metaHash.delete(\"journal\")\n metaHash.key?(\"proceedings\") and data[:proceedings] = metaHash.delete(\"proceedings\")\n metaHash.key?(\"volume\") and data[:volume] = metaHash.delete(\"volume\")\n metaHash.key?(\"issue\") and data[:issue] = metaHash.delete(\"issue\")\n metaHash.key?(\"parent-title\") and data[:bookTitle] = metaHash.delete(\"parent-title\") # for chapters \n metaHash.key?(\"oa-location-url\") and convertOALocation(ark, metaHash, data)\n data[:ucpmsPubType] = elementsPubType\n\n # History\n data[:published] = convertPubDate(metaHash.delete('publication-date'))\n data[:submitterEmail] = submitterEmail\n\n # Custom Citation Field\n metaHash.key?(\"custom-citation\") and data[:customCitation] = metaHash.delete(\"custom-citation\")\n\n # All done.\n return data\nend",
"def element_params\n params.require(:element).permit(:element_type, :post_id, :position)\n end",
"def create\n @exitpop = Exitpop.new(params[:exitpop])\n\n respond_to do |format|\n if @exitpop.save\n format.html { redirect_to @exitpop, notice: 'Exitpop was successfully created.' }\n format.json { render json: @exitpop, status: :created, location: @exitpop }\n else\n format.html { redirect_to action: \"new\" }\n format.json { render json: @exitpop.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def on_pop(node)\n child = node.children.first\n\n node.update(:expand, [\n child,\n AST::Node.new(:nop, [], node.metadata)\n ], nil)\n end",
"def expunge\n multi_data_response(\"EXPUNGE\").transform do |untagged_responses|\n untagged_responses.map(&:data)\n end\n end",
"def restore_pop\n\nend",
"def pop\n @instructions << Instruction.new(:pop)\n self\n end",
"def initialize\n @elements = []\n end",
"def using_pop(arr)\n arr.pop\nend",
"def element_params\n params.require(:element).permit(:tag, :process_order, :product_type_id, :drying_method_id, :previous_color, :ex_tag, :lot, :first_item, :last_item)\n end",
"def post\n frm.button(:name=>\"post\").click\n AssignmentsList.new(@browser)\n end",
"def pop\n list.pop\n end",
"def push(*elements)\n @buffer.push(*elements)\n @buffer = @buffer[-@size, @size] if(@buffer.size > @size)\n end",
"def rest\n\t\t\tarray = pop\n\t\t\traise ArgumentError, \"REST: first element is not an Array.\" unless array.is_a? Array\n\t\t\traise ArgumentError, \"REST: empty array.\" if array.length == 0\n\t\t\tarray.delete_at 0\n\t\t\tpush array\n\t\tend",
"def pop\n # IMPLEMENT ME\n end",
"def end_push\n ## empty\n return [[], []]\n end",
"def elements; end",
"def elements; end",
"def elements; end",
"def pop\n @events.pop\n end",
"def push_element\n return if @element_name.nil?\n\n # Add the class attribute if the element is a <p> element.\n @attrs[:class] = 'ppp' if :p == @element_name\n\n # Check @void_elements to determine how the element start would be\n # written. HTML includes void elements that are self closing so those\n # should be handled correctly.\n if VOID_ELEMENTS.include?(@element_name)\n @builder.void_element(@element_name, @attrs)\n else\n @builder.element(@element_name, @attrs)\n end\n # Reset the element name.\n @element_name = nil\n @attrs = {}\n end",
"def post\n frm.button(:value=>\"Post\").click\n AssignmentsList.new(@browser)\n end",
"def request_elements\n REQUEST_ELEMENTS\n end",
"def add_population\n @extractions_extraction_forms_projects_sections_type1.extractions_extraction_forms_projects_sections_type1_rows.each do |eefpst1r|\n eefpst1r.extractions_extraction_forms_projects_sections_type1_row_columns.create\n end\n\n redirect_to edit_populations_extractions_extraction_forms_projects_sections_type1(@extractions_extraction_forms_projects_sections_type1), notice: t('success')\n end",
"def pop\r\n # What does array.pop do? It takes the last \r\n # item of a list. We want this method to return\r\n # the last item. So maybe we can do something like:\r\n # return @data.last\r\n end",
"def pop\n @obj.pop\n end",
"def pop\n delete_at(0)\n end",
"def push(element)\n @data.push(element)\n end",
"def pop\n @stackList.delete_at (@stackList.length - 1)\n postPopListener\n end",
"def push(elt)\n @elements << elt\n end",
"def set_node_pop(node_city, pop)\n @nodes[node_city].pop = pop\n end",
"def push(*rest) end",
"def pop\n\t@new_tail = at((size) - 2)\n\t@new_tail.next_node = nil\n\n\t@tail = @new_tail\t\n\tend",
"def pop\n delete @data.keys.pop\n end",
"def remove_arrays_from_profile(args = {}) \n body_delete(\"/profiles.json/#{args[:profileId]}/arrays\", args[:array_of_ids])\nend",
"def pop\n @read_later = ReadLater.pop!\n\n render json: @read_later\n end",
"def pop\n @tape.pop()\n end",
"def pop\n @nodes.shift\n end",
"def push(pushes)\n view.update_many(\"$push\" => collect_operations(pushes))\n end",
"def push(element)\n @store << element #putting the element into the array, thereby putting it into the stack\n end",
"def save(element)\n elementHash = element.to_hash\n parameter = { basic_auth: @auth,\n body: elementHash.to_json,\n headers: { 'Content-Type' => 'application/json; charset=utf-8
' } }\n save_response = self.class.post('/elements', parameter)\n if save_response.success?\n Element.new(save_response.parsed_response)\n else\n puts \"Could not save element: #{save_response.headers['x-errordescription']}\"\n end\n end",
"def initialize\n @elements = []\n end",
"def initialize\n @elements = []\n end",
"def page_elements\n []\n end",
"def add_population\n authorize(@extractions_extraction_forms_projects_sections_type1)\n\n @extractions_extraction_forms_projects_sections_type1.extractions_extraction_forms_projects_sections_type1_rows.each do |eefpst1r|\n eefpst1r.extractions_extraction_forms_projects_sections_type1_row_columns.create\n end\n\n redirect_to(\n edit_populations_extractions_extraction_forms_projects_sections_type1(@extractions_extraction_forms_projects_sections_type1),\n notice: t('success'),\n status: 303\n )\n end",
"def test_pushing_and_popping_arrays\n array = [1,2]\n array.push(:last)\n\n assert_equal [1, 2, :last], array\n\n popped_value = array.pop\n assert_equal :last, popped_value\n assert_equal [1, 2], array\n end",
"def pop\r\n @arr.shift\r\n end",
"def pop\n\t\t\[email protected]\n\t\tend",
"def remove_last_child\n @elements.pop\n end",
"def each_pop\n loop do\n if head == nil\n break\n else\n yield(pop)\n end\n end\n end"
] | [
"0.5941232",
"0.59227943",
"0.5871767",
"0.58611125",
"0.5806829",
"0.54562044",
"0.54066193",
"0.5341756",
"0.5319789",
"0.52240765",
"0.5222521",
"0.518781",
"0.51378864",
"0.5075515",
"0.507208",
"0.507208",
"0.507208",
"0.507208",
"0.507208",
"0.5071094",
"0.5071094",
"0.5071094",
"0.50600636",
"0.5049759",
"0.501251",
"0.49959123",
"0.49812967",
"0.49562877",
"0.49424377",
"0.4920489",
"0.4865204",
"0.48520663",
"0.48435953",
"0.48415363",
"0.48198733",
"0.48174778",
"0.47785196",
"0.47744894",
"0.47626925",
"0.47626925",
"0.47626925",
"0.47626925",
"0.47626925",
"0.47626925",
"0.47626925",
"0.47626925",
"0.47626925",
"0.47623903",
"0.474185",
"0.47410423",
"0.47388232",
"0.47320664",
"0.47318968",
"0.4731644",
"0.4729056",
"0.4710499",
"0.4708375",
"0.46996737",
"0.46936238",
"0.46929172",
"0.46896124",
"0.4684471",
"0.46793756",
"0.46700445",
"0.46677315",
"0.46461016",
"0.46441478",
"0.46441478",
"0.46441478",
"0.46391743",
"0.46239695",
"0.460304",
"0.45979816",
"0.45969486",
"0.4583053",
"0.4582622",
"0.4580925",
"0.45758528",
"0.45665675",
"0.45634928",
"0.45547226",
"0.45345363",
"0.45338386",
"0.45310095",
"0.45272163",
"0.45233434",
"0.45219198",
"0.45173845",
"0.45080897",
"0.45030475",
"0.44964626",
"0.4495761",
"0.4495761",
"0.4492854",
"0.4492417",
"0.44882777",
"0.44870615",
"0.4486427",
"0.44851875",
"0.44733042"
] | 0.62175685 | 0 |
PATCH/PUT /pop_elements/1 PATCH/PUT /pop_elements/1.json | def update
respond_to do |format|
if @pop_element.update(pop_element_params)
format.html { redirect_to @pop_element, notice: 'Pop element was successfully updated.' }
format.json { render :show, status: :ok, location: @pop_element }
else
format.html { render :edit }
format.json { render json: @pop_element.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pop_element\n @pop_element = PopElement.find(params[:id])\n end",
"def update\n @element.update_attributes(element_params)\n respond_with @element\n end",
"def patch!\n request! :patch\n end",
"def update(element)\n elementHash = element.to_hash\n parameter = { basic_auth: @auth,\n body: elementHash.to_json,\n headers: { 'Content-Type' => 'application/json; charset=utf-8
' } }\n save_response = self.class.put(\"/elements/#{element.key}\", parameter)\n if save_response.success?\n Element.new(save_response.parsed_response)\n else\n puts \"Could not save element: #{save_response.headers['x-errordescription']}\"\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def cmd_modify argv\n setup argv\n json = @hash['json']\n e = @hash['element']\n response = @api.modify(json, e)\n msg response\n return response\n end",
"def update\n run_callbacks :update do\n connection.patch(element_path(prefix_options), encode, self.class.headers).tap do |response|\n load_attributes_from_response(response)\n end\n end\n end",
"def patch(payload)\n post_like payload, Net::HTTP::Patch.new(@uri.path)\n end",
"def update\n @popularty = Popularty.find(params[:id])\n\n respond_to do |format|\n if @popularty.update_attributes(params[:popularty])\n format.html { redirect_to @popularty, notice: 'Popularty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @popularty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @element = Element.find(params[:id])\n\n respond_to do |format|\n if @element.update_attributes(params[:element])\n format.html { redirect_to @element, notice: 'Element was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = [{ 'op' => operation, 'path' => path, 'value' => value }]\n patch_options = { 'If-Match' => @data['eTag'] }\n response = @client.rest_patch(@data['uri'], patch_options.merge('body' => body), @api_version)\n @client.response_handler(response)\n end",
"def update!(**args)\n @push_endpoint = args[:push_endpoint] unless args[:push_endpoint].nil?\n @attributes = args[:attributes] unless args[:attributes].nil?\n end",
"def update!(**args)\n @element = args[:element] if args.key?(:element)\n end",
"def update\n respond_to do |format|\n if @kpop.update(kpop_params)\n format.html { redirect_to @kpop, notice: 'Kpop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kpop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n run_callbacks :update do\n connection.put(element_path(prefix_options), encode_changes, self.class.headers).tap do |response|\n load_attributes_from_response(response)\n end\n end\n end",
"def update_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend",
"def update # PATCH\n raise NotImplementedError\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def pop_element_params\n params.require(:pop_element).permit(:name, :price, :master_type, :sub_type, :availability)\n end",
"def patch\n end",
"def patch(operation, path, value)\n response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])\n @client.response_handler(response)\n end",
"def update\n\n @design.elements.destroy_all\n\n params[:elements].values.each_with_index do |elem,i|\n puts elem\n # if @design = Design.find_or_create_by(id: @design_id, name: params[:name], user: @current_user)\n elem_to_save = Element.create (elem)\n @design.elements << elem_to_save\n end\n\n\n respond_to do |format|\n if @design.id\n format.html { redirect_to edit_design_path(@design), notice: 'Design was successfully created.' }\n format.json { render :json => @design}\n else\n format.html { render :new }\n format.json { render json: @design.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end",
"def update\n @exitpop = Exitpop.find(params[:id])\n\n respond_to do |format|\n if @exitpop.update_attributes(params[:exitpop])\n format.html { redirect_to @exitpop, notice: 'Exitpop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exitpop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_with []\n end",
"def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n respond_to do |format|\n if @pull.update(pull_params)\n format.html { redirect_to @pull, notice: 'Pull was successfully updated.' }\n format.json { render :show, status: :ok, location: @pull }\n else\n format.html { render :edit }\n format.json { render json: @pull.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @field_path_elements = args[:field_path_elements] if args.key?(:field_path_elements)\n end",
"def update\n @ipack = Ipack.find(params[:id])\n\n respond_to do |format|\n if @ipack.update_attributes(params[:ipack])\n format.html { redirect_to ipacks_url, notice: 'Collection successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ipack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pushed = Pushed.find(params[:id])\n\n respond_to do |format|\n if @pushed.update_attributes(params[:pushed])\n format.html { redirect_to(@pushed, :notice => 'Pushed was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pushed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch(operation, path, value)\n response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])\n @client.response_handler(response)\n end",
"def update\n @element = @account.elements.find(params[:id])\n\n respond_to do |format|\n if @element.update_attributes(params[:element])\n format.html { redirect_to(@element, :notice => 'Element was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n else\n logger.warn(\"UPDATING new element failed this these errors: #{@element.errors.full_messages.to_sentence}\")\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @element.errors, :status => :unprocessable_entity }\n format.json { render :json => @element.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize Element\n respond_to do |format|\n if @element.update(element_params)\n format.html { redirect_to @element, notice: 'Element je bil uspešno posodobljen.' }\n format.json { render :show, status: :ok, location: @element }\n else\n format.html { render :edit }\n format.json { render json: @element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(data, options={})\n @hal_client.patch(href, data, options).tap do\n reset\n end\n end",
"def create\n @pop_element = PopElement.new(pop_element_params)\n\n respond_to do |format|\n if @pop_element.save\n format.html { redirect_to @pop_element, notice: 'Pop element was successfully created.' }\n format.json { render :show, status: :created, location: @pop_element }\n else\n format.html { render :new }\n format.json { render json: @pop_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response|\n returning connection.put(element_path(prefix_options), to_ssj, self.class.headers) do |response|\n load_attributes_from_response(response)\n end\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 @element = Element.find(params[:id])\n\n respond_to do |format|\n if @element.update_attributes(params[:element])\n format.html { redirect_to(@element, :notice => 'Element was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @element.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @pushup = Pushup.find(params[:id])\n\n respond_to do |format|\n if @pushup.update_attributes(params[:pushup])\n format.html { redirect_to @pushup, notice: 'Pushup was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pushup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pm_element = PmElement.find(params[:id]) \n @pm_element.properties = OpenStruct.new params[:properties]\n render(:update){|page| \n\t if @pm_element.update_attributes(params[:pm_element])\n\t flash[:notice] = \"保存成功!<br>#{@pm_element.track_change_warning}\"\n\t if params[:from] == \"index\"\n\t \tpage.redirect_to :back\n \telse\n \t\tpage.redirect_to(@pm_element)\n \t\tend\t \n\t else\n\t page.replace \"pm_element_form\", :partial => \"show\" \n\t end \n }\n end",
"def update\n @gallery = Gallery.find(params[:id])\n \n #update order of elements\n if params[:gallery_weight]\n weights = params[:gallery_weight].split(\"&\").map{|s| s.gsub(\"element[]=\", \"\") }\n \n @gallery.elements.each do |element|\n element.weight = weights.index(element.id.to_s)\n element.save\n end\n end\n \n respond_to do |format|\n if @gallery.update_attributes(params[:gallery])\n format.html { redirect_to get_redirect_path, notice: 'Gallery was successfully updated.' }\n format.json { head :ok }\n else\n flash[:error] = \"Gallery cannot be created. Please correct form errors\"\n format.html { redirect_to get_redirect_path }\n format.json { render json: @gallery.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch_resource(payload)\n execute(resource_path, method: :patch, payload: payload.to_json)\n end",
"def update\n update_elements if elements_params.present?\n @template.update(name: template_params[:name]) if template_params[:name].present?\n\n if @template.errors.empty?\n render :show, status: :ok, location: @template\n else\n render json: @template.errors, status: :unprocessable_entity\n end\n end",
"def destroy\n @pop_element.destroy\n respond_to do |format|\n format.html { redirect_to pop_elements_url, notice: 'Pop element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def update\n params[:fundation][:population_ids] ||= [] \n @fundation = Fundation.find(params[:id])\n\n respond_to do |format|\n if @fundation.update_attributes(params[:fundation])\n format.html { redirect_to(@fundation, :notice => 'Fundation was successfully updated.') }\n format.xml { head :ok }\n format.json { render :json => {:resp => \"ok\"} }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fundation.errors, :status => :unprocessable_entity }\n format.json { render :json => {:resp => \"error\"} } \n end\n end\n end",
"def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end",
"def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end",
"def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end",
"def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end",
"def update\n connection.put(element_path, to_xml)\n end",
"def update\n respond_to do |format|\n if @config_element.update(config_element_params)\n format.html { redirect_to @config_element, notice: 'Config element was successfully updated.' }\n format.json { render :show, status: :ok, location: @config_element }\n else\n format.html { render :edit }\n format.json { render json: @config_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update\n respond_to do |format|\n if @event_element.update(event_element_params)\n format.html { redirect_to @event_element, notice: 'Event element was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_element }\n else\n format.html { render :edit }\n format.json { render json: @event_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n @pocket = Pocket.find(params[:id])\n\n respond_to do |format|\n if @pocket.update_attributes(params[:pocket])\n format.html { redirect_to @pocket, notice: 'Pocket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pocket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:presentation][:feedback_ids] ||= []\n respond_to do |format|\n if @presentation.update(presentation_params)\n format.html { redirect_to @presentation, notice: 'Presentation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @presentation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @dataelement = Dataelement.find(params[:id])\n\n respond_to do |format|\n if @dataelement.update_attributes(params[:dataelement])\n format.html { redirect_to @dataelement, notice: 'Dataelement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataelement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n Rentlinx.client.patch(self)\n end",
"def patch(path, **args); end",
"def update!(**args)\n @etag = args[:etag] if args.key?(:etag)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update\n new_params = paper_set_params\n if params[:paper_set][:paper_ids]\n new_params[:paper_ids] = params[:paper_set][:paper_ids].split(\",\")\n end\n respond_to do |format|\n if @paper_set.update(new_params)\n format.html { redirect_to paper_sets_path, notice: '成功編輯試卷包' }\n format.json { render :index, status: :ok, location: @paper_set }\n else\n format.html { render :edit }\n format.json { render json: @paper_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(args)\n builder.update_rest(type, ref, args, username, password)\n self.elements(true)\n end",
"def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(endpoint)\n respond_with(\n connection(endpoint).patch(prepare(endpoint.uri),\n endpoint.req_params.nil? ? nil : custom_dump(endpoint.req_params)),\n endpoint\n )\n end",
"def pop(pops)\n view.update_many(\"$pop\" => collect_operations(pops))\n end",
"def patch(action, **args); end",
"def update!(**args)\n @payloads = args[:payloads] if args.key?(:payloads)\n end",
"def update\n @content_group_element = ContentGroupElement.find(params[:id])\n\n respond_to do |format|\n if @content_group_element.update_attributes(params[:content_group_element])\n format.html { redirect_to @content_group_element, :notice => 'Content group element was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @content_group_element.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end",
"def update\n begin\n @element.update!(registered_element_params)\n rescue => e\n render partial: \"shared/validation_messages\",\n locals: { object: @element.errors.any? ? @element : e },\n status: :bad_request\n else\n toast!(title: \"Element updated\",\n message: \"The element \\\"#{@element.name}\\\" has been updated.\")\n render \"shared/reload\"\n end\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def patch; end",
"def patch; end",
"def update_popups\n @popups.each_value{|p| p.update}\n end",
"def update\n @element = Element.find(params[:id])\n respond_to do |format|\n element_params = params[:element]\n association_params = {}\n element_params.keys.select{|key| key.include? 'associations'}.each{|key| association_params[key] = element_params.delete(key)}\n if @element.update_attributes(element_params)\n association_params.each_pair do |association_key, associations_param|\n associations = @element.send(association_key)\n associated_category_ids = associations.collect(&:category_id)\n category_ids_to_be_associated = !associations_param.nil? && !associations_param[:category_ids].blank? ? associations_param[:category_ids].collect(&:to_i) : []\n root_id = !associations_param.nil? && !associations_param[:root_id].blank? ? associations_param[:root_id] : nil\n (associated_category_ids - category_ids_to_be_associated).each{|c_id| associations.all(:conditions => {:category_id => c_id}).each(&:destroy)}\n (category_ids_to_be_associated - associated_category_ids).each{|c_id| associations.create :category_id => c_id, :root_id => root_id.blank? ? Category.find(c_id).root.id : root_id}\n end\n flash[:notice] = 'Element was successfully updated.'\n format.html { redirect_to elements_url }\n format.xml { head :ok }\n else\n @root_category = Category.find(272)\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @element.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @feed_element = FeedElement.find(params[:id])\n\n respond_to do |format|\n if @feed_element.update_attributes(params[:feed_element])\n format.html { redirect_to @feed_element, :notice => 'Feed element was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @feed_element.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic_group = TopicGroup.find_by_id(params[:topic_group_id])\n @iteration = Iteration.find_by_id(params[:iteration_id]) \n params[:element][:edited_by] = current_user.id #JDavis: identifying the last user to edit this element\n if @element.update_attributes(params[:element])\n gflash :success => \"Item updated.\"\n redirect_to topic_group_iteration_url(@topic_group, @iteration)\n else \n respond_with(@element) \n end\n\n end",
"def prop_patch_node_update(path, prop_patch)\n # This should trigger a 404 if the node doesn't exist.\n node = @server.tree.node_for_path(path)\n\n node.prop_patch(prop_patch) if node.is_a?(IProperties)\n end",
"def update\n @home_element = HomeElement.find(params[:id])\n\n respond_to do |format|\n if @home_element.update_attributes(params[:home_element])\n format.html { redirect_to @home_element, notice: 'Home element was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @home_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n @etag = args[:etag] if args.key?(:etag)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update\n respond_to do |format|\n if @page_element.update(page_element_params)\n format.html { redirect_to council_page_page_elements_path(@council), notice: 'Elementet uppdaterades.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @elemento.update(elemento_params)\n format.html { redirect_to @elemento, notice: 'Elemento fue actualizado con exito.' }\n format.json { render :show, status: :ok, location: @elemento }\n else\n format.html { render :edit }\n format.json { render json: @elemento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @patch_deployments = args[:patch_deployments] if args.key?(:patch_deployments)\n end",
"def patch_params\n params.require(:patch).permit(:name)\n end",
"def update\n respond_to do |format|\n if @pushup_reminder.update_attributes(params[:pushup_reminder])\n format.html { redirect_to [@user, @pushup_reminder], notice: 'Pushup reminder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pushup_reminder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @popularty_line_item = PopulartyLineItem.find(params[:id])\n\n respond_to do |format|\n if @popularty_line_item.update_attributes(params[:popularty_line_item])\n format.html { redirect_to @popularty_line_item, notice: 'Popularty line item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @popularty_line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pem = Pem.find(params[:id])\n\n respond_to do |format|\n if @pem.update_attributes(params[:pem])\n format.html { redirect_to @pem, notice: 'Pem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @payload = args[:payload] if args.key?(:payload)\n @tag = args[:tag] if args.key?(:tag)\n end",
"def update!(**args)\n @payload = args[:payload] if args.key?(:payload)\n end"
] | [
"0.6089538",
"0.59587145",
"0.58091044",
"0.57889915",
"0.57531",
"0.5728098",
"0.57038134",
"0.56774074",
"0.5652095",
"0.5599764",
"0.5574666",
"0.556536",
"0.555922",
"0.55307627",
"0.5495266",
"0.5492134",
"0.5484089",
"0.54624957",
"0.5443202",
"0.5440393",
"0.5433492",
"0.5425168",
"0.5422506",
"0.5421512",
"0.54180807",
"0.54046935",
"0.53793555",
"0.53419423",
"0.53416574",
"0.5338273",
"0.5335778",
"0.5334781",
"0.53332365",
"0.53332365",
"0.53240556",
"0.5301875",
"0.5293398",
"0.5270419",
"0.5260437",
"0.52575624",
"0.5243343",
"0.5235818",
"0.5223822",
"0.521386",
"0.52105594",
"0.5207803",
"0.5207803",
"0.5187578",
"0.51674765",
"0.5155422",
"0.51469827",
"0.51421297",
"0.51421297",
"0.51421297",
"0.51421297",
"0.5136209",
"0.5133423",
"0.51309997",
"0.51257676",
"0.5115385",
"0.51055884",
"0.5102625",
"0.508958",
"0.5088962",
"0.50875026",
"0.5083427",
"0.50827783",
"0.5078788",
"0.5078124",
"0.5076996",
"0.50750184",
"0.50723934",
"0.5065531",
"0.50605834",
"0.50502855",
"0.50490516",
"0.5047636",
"0.50431466",
"0.503268",
"0.503268",
"0.50273085",
"0.50273085",
"0.5026332",
"0.5023987",
"0.5013263",
"0.5012675",
"0.50081134",
"0.5007528",
"0.5005279",
"0.5001596",
"0.4987993",
"0.49800456",
"0.49794084",
"0.49762088",
"0.49754468",
"0.49748778",
"0.49741754",
"0.49647787",
"0.4964637",
"0.4962981"
] | 0.7205981 | 0 |
DELETE /pop_elements/1 DELETE /pop_elements/1.json | def destroy
@pop_element.destroy
respond_to do |format|
format.html { redirect_to pop_elements_url, notice: 'Pop element was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to elements_url }\n format.json { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete element\n element.perform :delete\n end",
"def delete(element_key)\n parameter = { basic_auth: @auth }\n response = self.class.delete(\"/elements/#{element_key}\", parameter)\n unless response.success?\n puts \"Could not save element: #{response.headers['x-errordescription']}\"\n end\n response\n end",
"def delete(element); end",
"def destroy\n @kpop.destroy\n respond_to do |format|\n format.html { redirect_to kpops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exitpop = Exitpop.find(params[:id])\n @exitpop.destroy\n\n respond_to do |format|\n format.html { redirect_to exitpops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @element.destroy\n respond_with :elements\n end",
"def delete_element(element); end",
"def destroy\n @dataelement = Dataelement.find(params[:id])\n @dataelement.destroy\n\n respond_to do |format|\n format.html { redirect_to dataelements_url }\n format.json { head :no_content }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n @pushup = Pushup.find(params[:id])\n @pushup.destroy\n\n respond_to do |format|\n format.html { redirect_to pushups_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to(elements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to(elements_url) }\n format.xml { head :ok }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete(*rest) end",
"def destroy\n @element = @account.elements.find(params[:id])\n @element.destroy\n respond_to do |format|\n format.html { redirect_to(elements_url, :notice => 'Element was sucessfully destroyed.') }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end",
"def destroy\n @config_element.destroy\n respond_to do |format|\n format.html { redirect_to config_elements_url, notice: 'Config element was successfully destroyed.' }\n format.json { head :no_content }\n end\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 delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @stash_element.destroy\n respond_to do |format|\n format.html { redirect_to controller: 'post', action: 'new_post', notice: 'Stash element was successfully created.' }\n format.json { head :no_content }\n end\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 run_callbacks :destroy do\n connection.delete(element_path, encode, self.class.headers)\n end\n end",
"def destroy\n @push = Push.find(params[:id])\n @push.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_pushes_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n association.delete association[element.dataset[:index].to_i]\n end",
"def delete\n item = FormTemplate.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end",
"def destroy\n @pushed = Pushed.find(params[:id])\n @pushed.destroy\n\n respond_to do |format|\n format.html { redirect_to(pusheds_url) }\n format.xml { head :ok }\n end\n end",
"def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def destroy\n @list_element.destroy\n respond_to do |format|\n format.html { redirect_to list_elements_url, notice: 'List element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def delete\n delete_from_server single_url\n end",
"def destroy\n @pm_element = PmElement.find(params[:id])\n @pm_element.destroy\n redirect_to pm_element_path(@pm_element.parent)\n \n end",
"def delete(payload)\n post_like payload, Net::HTTP::Delete.new(@uri.path)\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end",
"def api_remove\n data_hash = make_hash\n delete_hash = { division: data_hash[:division][:value] }\n handler.remove(delete_hash, path, subscriber_id)\n end",
"def destroy\n @grep_multi.destroy\n respond_to do |format|\n format.html { redirect_to grep_multis_url, notice: 'Grep multi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove(*paths)\n json_op(:remove, self, *paths)\n end",
"def destroy\n @home_element = HomeElement.find(params[:id])\n @home_element.destroy\n\n respond_to do |format|\n format.html { redirect_to home_elements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed_element = FeedElement.find(params[:id])\n @feed_element.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_elements_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @popularty_line_item = PopulartyLineItem.find(params[:id])\n @popularty_line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to popularty_line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pushup_reminder.destroy\n\n respond_to do |format|\n format.html { redirect_to pushup_reminders_url }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @paper_item.destroy\n respond_to do |format|\n format.html { redirect_to paper_items_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 @unlimited.destroy\n respond_to do |format|\n format.html { redirect_to unlimiteds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n render status: 200, json: @request_item.destroy\n end",
"def remove\n\t\t\tself.make_request!({uri: self.to_uri, method: :delete})\n\t\tend",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete(*args)\n Request.delete(*args)\n end",
"def delete!(*rest) end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @pull.destroy\n respond_to do |format|\n format.html { redirect_to pulls_url, notice: 'Pull was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @neural_population = NeuralPopulation.find(params[:id])\n @neural_population.destroy\n\n respond_to do |format|\n format.html { redirect_to(neural_populations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @population.destroy\n respond_to do |format|\n format.html { redirect_to populations_url, notice: 'Population was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete_one(file)\n files_collection.find(:_id => file.id).delete_one\n chunks_collection.find(:files_id => file.id).delete_many\n end",
"def delete\n api_client.delete(url)\n end",
"def delete(_url)\n # do nothing since we can't find the key by url\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @event_element.destroy\n respond_to do |format|\n format.html { redirect_to event_elements_url, notice: 'Event element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def destroy\n Clenum.destroy params[:ids].split(',')\n\n respond_to do |format|\n format.html { redirect_to(clenums_url) }\n format.xml { head :ok }\n end\n end",
"def delete_json(url)\n JSON.parse(delete(url, :json, :json))\n end",
"def destroy\n @stage_population = StagePopulation.find(params[:id])\n @stage_population.destroy\n\n respond_to do |format|\n format.html { redirect_to stage_populations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @click_data.destroy\n\n head :no_content\n end",
"def delete_id(id)\n ids_in_doc = root.fetch(full_path, :single => true)\n raise TypeError, \"Expecting array\" unless ids_in_doc.kind_of? Array\n ids_in_doc.delete id\n root.save!\n ids.delete id\n save!\n end",
"def delete_array_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/arrays/#{args[:arrayId]}\", args)\nend",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def delete\n api(\"Delete\")\n end",
"def destroy\n @elemento.destroy\n respond_to do |format|\n format.html { redirect_to elementos_url, notice: 'Elemento fue eliminado con exito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collection.destroy\n\n render json: @collection, status: :ok#, location: @collection\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 delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end",
"def destroy\n @page_element.destroy\n respond_to do |format|\n format.html { redirect_to council_page_page_elements_path(@council) }\n format.json { head :no_content }\n end\n end",
"def destroy; delete end",
"def destroy\n @elemento = Elemento.find(params[:id])\n @elemento.destroy\n\n respond_to do |format|\n format.html { redirect_to(elementos_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete\n ruta = \"/actions/#{action_id}\"\n client.delete(ruta)\n end",
"def delete\n \n end",
"def remove(request) \n data = request.data \t \n\t id = data[@pk]\t \n # remove the item\n @model.destroy(id)\t \n response = DSResponse.new\n response.data = nil\n response.status = 0 \n return response \n end",
"def delete\n item = FormImage.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end",
"def destroy\n @ripple.destroy\n respond_to do |format|\n format.html { redirect_to ripples_url, notice: 'Ripple was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @one = One.find(params[:id])\n @one.destroy\n\n respond_to do |format|\n format.html { redirect_to ones_url }\n format.json { head :no_content }\n end\n end",
"def delete_file(file_name)\n fail 'No Structure ID defined for structure. Can\\'t delete file' if @structure.id.nil?\n\n data = Hashie::Mash.new\n data.structure_id = @structure.id\n data.file_name = file_name\n\n push_file('api/remove_file', MultiJson.dump(data))\n end",
"def destroy\n @exchange.destroy\n respond_to do |format|\n format.html { redirect_to exchanges_url, notice: 'La cotizacion de elemento se eliminó con exito.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.69420797",
"0.6347632",
"0.6322426",
"0.62980604",
"0.6294488",
"0.6269577",
"0.61933786",
"0.6171343",
"0.6145988",
"0.6143168",
"0.6142986",
"0.6117265",
"0.61075187",
"0.6084483",
"0.6084483",
"0.60462195",
"0.60415006",
"0.6030267",
"0.6029937",
"0.60239446",
"0.60211504",
"0.5980024",
"0.5963753",
"0.59605914",
"0.59523606",
"0.5940282",
"0.59259105",
"0.5915073",
"0.58914024",
"0.58912265",
"0.5891042",
"0.5880482",
"0.5875052",
"0.587395",
"0.58709896",
"0.58683944",
"0.58629495",
"0.58564097",
"0.58564097",
"0.58546185",
"0.58385855",
"0.58370924",
"0.5836807",
"0.58284855",
"0.58208025",
"0.5801953",
"0.57875",
"0.57859725",
"0.5784838",
"0.57825595",
"0.57824343",
"0.5781445",
"0.57800514",
"0.57730144",
"0.5765718",
"0.576011",
"0.5751575",
"0.5750172",
"0.57469267",
"0.5746046",
"0.57425874",
"0.573239",
"0.57114196",
"0.57102185",
"0.5709853",
"0.5709853",
"0.5709853",
"0.5709853",
"0.5699779",
"0.56955636",
"0.5692614",
"0.5689709",
"0.5683675",
"0.5681522",
"0.56814766",
"0.5678346",
"0.56723744",
"0.5669893",
"0.5669441",
"0.56693727",
"0.5668563",
"0.5666067",
"0.5663266",
"0.5660449",
"0.56598425",
"0.5656157",
"0.5656157",
"0.56526595",
"0.56519455",
"0.5650134",
"0.56466675",
"0.5645859",
"0.564554",
"0.56451267",
"0.5644467",
"0.5638781",
"0.5638745",
"0.5633381",
"0.5631051",
"0.5629254"
] | 0.7247742 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_pop_element
@pop_element = PopElement.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 pop_element_params
params.require(:pop_element).permit(:name, :price, :master_type, :sub_type, :availability)
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 |
List notification groups List all notification groups from the current user | def notification_groups_list(opts = {})
data, _status_code, _headers = notification_groups_list_with_http_info(opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_members\n Notification.where(group_owner_id: id)\n end",
"def index\n @groups = []\n for member in current_user.members\n @groups << member.group\n end\n end",
"def list_groups\n if @user.permission_level.value == PermissionLevel.order(\"value DESC\").first.value\n render :json => Group.find(:all).map{|g| g}\n else\n render :json => @user.groups.map{|g| g}\n end\n end",
"def groups_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def index\n @groups = Group.display_for_user(current_user)\n end",
"def index\n\t\t@groups = current_user.groups\n\tend",
"def index\n @groups = current_user.groups\n end",
"def index\n @user = User.find(current_user.id)\n @groups = @user.groups.all\n end",
"def index\n @groups = Group.where(:user_id => current_user)\n end",
"def groups\n Group.groups(user_name)\n end",
"def index\n if user_signed_in?\n @groups = current_user.groups\n else\n redirect_to new_user_session_path\n end\n end",
"def list_groups\n groups = CanvasSpaces.GroupCategory.groups.active.order(:name)\n # filter out non-public groups for non-admins\n groups = groups.where(join_level: 'parent_context_auto_join') unless @current_user.account.site_admin?\n groups_json = Api.paginate(groups, self, api_v1_canvas_spaces_groups_url).map do |g|\n include = @current_user.account.site_admin? || @current_user.id == g.leader_id ? ['users'] : []\n group_formatter(g, { include: include })\n end\n render :json => groups_json\n end",
"def group_users\n DiscussionGroupUser.where(\"discussion_group_id=? AND is_member=?\", self.id, true)\n end",
"def groups()\n id_list = SQLQuery.new.get('groups_handler', ['group_id']).where.if('user_id', @id).send\n groups_list = []\n id_list.each do |id|\n groups_list << Groupchat.get(id['group_id'])\n end\n return Sorter.last_interaction(groups_list)\n end",
"def list_groups\n BrickFTP::API::Group.all\n end",
"def list_groups\n BrickFTP::API::Group.all\n end",
"def groups\n UserGroups.new(:id => id).get.items\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def index\n @notify = current_user.invited_members;\n @groups = Group.all\n @group = Group.new\n\n end",
"def list_groups()\n response = HTTParty.get(\"https://graph.microsoft.com/v1.0/groups\", { \n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Host\" => 'graph.microsoft.com' \n }\n })\n return JSON.parse response.read_body\n end",
"def send_group_list\n I3.server.send_object(I3.directory.find_all_groups)\n end",
"def list\n @groups = Group.find(:all, :order => 'name')\n end",
"def get_user_groups\n user_groups.keys\n end",
"def index\n @groups = query(GROUP, :name)\n\n # restrict the groups to the groups of the current user\n # unless the current user is allowed to create groups\n # and need to see all\n unless allowed(:create)\n allowed_group_ids = current_user.groups.collect {|g| g.id }\n @groups.delete_if do |g|\n ! allowed_group_ids.member?(g.id)\n end\n end\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @groups }\n end\n end",
"def list_notifications # :norobots:\n @notifications = Notification.find_all_by_user_id(@user.id, order: :flavor)\n end",
"def show_by_user\n @groups = Group.where(user_id: current_user.id)\n \n end",
"def group_list(user_id, sort = \"my_activity\")\n data = request(\"/group/list\", id: user_id, sort: sort)\n Hashie::Mash.new(data[\"groups\"][\"list\"])\n end",
"def groups\n FfcrmMailchimp::Group.groups_for(id)\n end",
"def hc_group_list(id)\n org=Org.find(id)\n org.hc_groups.group_list\n end",
"def index\n @user_groups = current_user.users_groups.page(params[:page]).per(20)\n end",
"def index\n @os_groups_notices = OsGroupsNotice.all\n end",
"def index\n @groups = current_user.groups\n render json: @groups\n end",
"def hc_group_list_all(id)\n org=Org.find(id)\n org.hc_groups.all(:order=>'group_name')\n end",
"def watcher_groups_list(object)\n remove_allowed = User.current.allowed_to?(\"delete_#{object.class.name.underscore}_watchers\".to_sym, object.project)\n content = ''.html_safe\n \n lis = object.watcher_groups.collect do |group|\n s = ''.html_safe\n s << link_to_group(group, :class => 'group')\n if remove_allowed\n url = {:controller => 'watcher_groups',\n :action => 'destroy',\n :object_type => object.class.to_s.underscore,\n :object_id => object.id,\n :group_id => group}\n s << ' '\n s << link_to(image_tag('delete.png'), url,\n :remote => true, :method => 'post', :style => \"vertical-align: middle\", :class => \"delete\")\n end\n content << content_tag('li', s)\n end\n content.present? ? content_tag('ul', content) : content\n end",
"def get_device_group_list\n query_api('device-groups')\n end",
"def do_list_groups()\n I18n.t(\"sms.some_groups\") + \": \" + Group.primary_group_abbrevs\n end",
"def fNotificationListFrom (email)\n @users.notificationListFrom(email)\n end",
"def index\n # @groups = Group.all\n if current_user\n @groups = Group.where(user_id: current_user.id)\n else\n redirect_to '/users/sign_in'\n end\n end",
"def show\n @user = current_user\n @user_groups = @user.groups\n\n @active_groups = []\n @pending_groups = []\n @pending_memberships = []\n @user.memberships.each do |m|\n if (m.status == \"active\")\n group = Group.find(m.group_id)\n @active_groups.push(group)\n elsif (m.status == \"pending\")\n group = Group.find(m.group_id)\n @pending_groups.push(group)\n @pending_memberships.push(m)\n end\n end\n end",
"def index\n\t\t@user = User.find(session[:id])\n\t\t@groups = Group.all\n\tend",
"def index\n @groups = Group.all.includes(:user)\n end",
"def users\n Webmail::User.in(group_ids: id)\n end",
"def index\n @usergroups = Usergroup.all\n end",
"def index\n @member_groups = @user.groups_where_member\n @admin_groups = @user.groups_where_admin\n end",
"def find_user_groups\r\n user_group = Group.where(\"id IN (SELECT gu.group_id FROM groups_users gu WHERE gu.user_id = ?)\", User.current.id).all\r\n group_names = []\r\n user_group.each do |group|\r\n group_names << group.lastname\r\n end\r\n return group_names\r\n end",
"def get_all_usergroups\n response = get_siteinfo('usergroups')\n ret = {}\n response['query']['usergroups'].each do |g|\n ret[g['name']] = g['rights']\n end\n ret\n end",
"def index\n render json: current_user.membered_groups\n end",
"def list(response)\n requested_group = response.args[1]\n output = get_groups_list(response.args[1])\n if output.empty?\n response.reply(empty_state_for_list(requested_group))\n else\n response.reply(output.join(\"\\n\"))\n end\n end",
"def subscriber_groups(identifier)\n connection.get(\"subscribers/#{identifier}/groups\")\n end",
"def group_notifications\n @attributes[:group_notifications]\n end",
"def index\n @discussion_groups = @login_user.all_public_private_groups\n respond_to do |format|\n format.html # index.html.erb\n # format.xml { render :xml => @discussion_groups }\n end\n end",
"def membership_list_for_group(email)\n Gaps::DB::Cache.with_cache_key(\"mygroupinfos:#{email}\") do\n membership_list(email)\n end\n end",
"def get_all_groups\n grps = self.get_groups_recursively\n grps << self.home_group\n logged_in_group = Group.new(:name => \"logged in user\")\n logged_in_group.id = 0\n grps << logged_in_group\n anonymous_group = Group.new(:name => \"anonymous user\")\n anonymous_group.id = -1\n grps << anonymous_group\n return grps.compact.uniq\n end",
"def groups\n response[\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(client, group)}\n end",
"def groups\n config.redis_connection.smembers \"#{config.prefix}:groups\"\n end",
"def list_notifications\n BrickFTP::API::Notification.all\n end",
"def list_notifications\n BrickFTP::API::Notification.all\n end",
"def getUserGroups\n \t@group_meals=GroupMealsParticipant.find_all_by_user_id(current_user.id)\n \tif(current_user.alert)\n \t\tcurrent_user.alert=false\n \t\tcurrent_user.save\n \tend\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group_meal }\n end\n end",
"def get_notifications\n \t\n \t@notifs = []\n\n \tif current_user\n @notifs = Notification.where(:user_id => current_user.id, :seen => false)\n \tend\n end",
"def list(response)\n requested_group = response.args[1]\n output = get_groups_list(requested_group)\n if output.empty?\n if requested_group\n response.reply(\n \"There is no authorization group named #{requested_group}.\"\n )\n else\n response.reply(\"There are no authorization groups yet.\")\n end\n else\n response.reply(output.join(\"\\n\"))\n end\n end",
"def index\n @groups_all = current_user.groups.paginate(page: params[:page]).order('name ASC')\n\n @owner = current_user\n @users = User.where(\"owner_id = ?\", current_user).order('lastname ASC')\n\n respond_to do |format|\n format.html { render @groups }\n format.json { render json: @groups }\n end\n end",
"def index\n @menu_groups = MenuGroup.where(:user_id => current_user.id).order(id: :asc)\n end",
"def get_groups(params)\n send_get \"get_groups\", params\n end",
"def index\n @notifications = Notification.where(user: current_user)\n end",
"def index\n unless user_signed_in?\n redirect_to new_user_session_path\n else\n @group_id = UserDefaultGroup.find_by_user_id(current_user.id)\n @group_id = @group_id.group_id unless @group_id.nil?\n #@users = User.all\n @users = User.joins(\"Left Join (select user_id, group_id From group_memberships) fm ON fm.user_id = users.id\").where(\"fm.group_id = ?\", @group_id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end\n end",
"def index\n @group_messages = GroupMessage.all\n end",
"def list_users\n group_id_param = params[:group_id]\n\n if group_id_param.nil? || group_id_param.blank?\n render json: { error: 'group_id not specified.' }, status: :bad_request\n return\n end\n\n group = CanvasSpaces.GroupCategory.groups.find_by_id(group_id_param)\n if group.nil?\n render json: { error: 'No such group found.' }, status: :bad_request\n else\n if @current_user.account.site_admin? || group.leader_id == @current_user.id\n render json: { size: group.users.count, users: group.users.map { |user| user.as_json(only: [:id, :name], include_root: false) } }, status: :ok\n else\n # doesn't have access to the group\n render json: { error: \"Can't list users. Not owner.\" }, status: :forbidden\n end\n end\n end",
"def list(\n filter,\n *args,\n deadline: nil\n )\n return @remote_identity_groups.list(\n filter,\n *args,\n deadline: deadline,\n )\n end",
"def index\n @groups = @flr.groups.all\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n\t\t# si rol mayor a desarrollador, listar todos los grupos \n \tif has_role_with_hierarchy?(:administrador) \n\t\t\t@groups = Group.all\n\t\t# si rol es desarrollador, listar solo sus grupos\n\t\telse\n\t\t\t@groups = Group.all :conditions => { :user_id, current_user.id }\n\t\tend\n end",
"def groups\n return [] if self.group_list.nil?\n self.group_list\n end",
"def available_groups\n @available_groups ||= begin\n current_user.groups\n .sort_by { |g| g.description.downcase }\n .map { |g| { id: g.id, description: g.description, user_permissions: g.user_permissions(current_user.login) } }\n # :nocov:\n rescue StandardError\n []\n end\n # :nocov:\n end",
"def groups\r\n @groups ||= fetch_groups\r\n end",
"def show\n @group_members = GroupMember.where(group_id:params[:id])\n @users_in_group=[]\n @group_members.each do |f|\n @user = User.find(f[:user_id])\n @users_in_group.push(@user)\n end\n render json: @users_in_group\n end",
"def index\n @messages = current_user.messages_in.order('created_at ASC').group('sender_id')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def group_members\n members(\"Group\")\n end",
"def index\n\t#Once sessions are implemented, return all groups where the user has a priveledge\n\t#A table including all subgroups will be generated.\n\tGroup.rebuild! if nil.|Group.find(:first).rgt\n\n\t@groups = current_user.get_unique_group_branches\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def groups()\n\t\t\t\tuserlist = users()\n\n\t\t\t\tgrouplist = GroupList.new()\n\t\t\t\tFile.open('/etc/group', File::RDONLY) { |fp|\n\t\t\t\t\tregex = /^([a-zA-Z0-9-]+):[^:]+:([0-9]+):([^:]*)/\n\t\t\t\t\tfp.each_line() { |line|\n\t\t\t\t\t\tmatch = regex.match(line)\n\t\t\t\t\t\tif(match != nil)\n\t\t\t\t\t\t\tgroup = GroupInfo.new()\n\t\t\t\t\t\t\tgroup.groupname = match[1]\n\t\t\t\t\t\t\tgroup.gid = match[2].to_i()\n\t\t\t\t\t\t\tgroup.members = UserList.new()\n\t\t\t\t\t\t\tif(match[3] != nil)\n\t\t\t\t\t\t\t\tusers = match[3].split(/,/)\n\t\t\t\t\t\t\t\tusers.each() { |username|\n\t\t\t\t\t\t\t\t\tif(userlist.has_key?(username))\n\t\t\t\t\t\t\t\t\t\tgroup.members[username] = userlist[username]\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tgrouplist[group.groupname] = group\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn(grouplist)\n\t\t\tend",
"def notifications\n @other_user = @login_user\n @notifications = DiscussionGroupUser.where(['user_id =? AND is_member=?', @login_user.id, false])\n @disc_notifications = NonSiteUser.where([\"email=? AND invitable_type=? and invitation_type=?\",@login_user.email,\"Discussion\",\"Invited\"])\n respond_to do |format|\n format.html\n end\n end",
"def list_groups(options = {})\n request({\n 'Action' => 'ListGroups',\n :parser => Fog::Parsers::AWS::IAM::ListGroups.new\n }.merge!(options))\n end",
"def groups(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Groups\", params: params)\n end",
"def getGroups\n groups = $gm.get(\"/groups\", @token, \"per_page=100\")\n group_ids = Array.new\n\n groups['response'].each do |group|\n group_ids.push({\n 'name' => group['name'],\n 'group_id' => group['id'],\n 'image' => group['image_url']})\n end\n\n return group_ids\n end",
"def index\n @users = @group.users\n end",
"def groups\n find(:group).map { |g| g.content }\n end",
"def users\n GroupMembers.new(:id => id).get.items\n end",
"def admin_conversations_restrictAccess_listGroups(options = {})\n raise ArgumentError, 'Required arguments :channel_id missing' if options[:channel_id].nil?\n post('admin.conversations.restrictAccess.listGroups', options)\n end",
"def notification_groups_list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_list ...'\n end\n # resource path\n local_var_path = '/notification_groups'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?\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 header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Object>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end",
"def show\n @group = Group.find(params[:id])\n\n @event = Event.find(@group.event_id)\n @members = current_user.get_members(@group)\n\n @messages = []\n @members.each do |member|\n @messages.concat(member.get_messages_in(@event))\n end\n\n @messages = @messages.sort_by &:created_at\n @messages = @messages.reverse\n end",
"def index\n # Only get the messages for the user currently signed in\n if current_user.group.messages_released\n \t@messages = current_user.messages\n else\n \t@messages = {}\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { send_data @messages }\n end\n end",
"def index\n @groups_user = GroupsUser.find(params[:id])\n @groups_users = GroupsUser.all\n end",
"def ldap_groups\n User.walk_ldap_groups(User.ldap_member_of(user_key), []).sort\n end",
"def get_user_groups username_for, options = {}\n do_request 'get_user_groups', options.merge(username_for: username_for)\n end",
"def index\n # byebug \n @groups = current_user.groups\n @group_members=GroupMember.all\n # @[email protected]\n end",
"def index\r\n @receive_groups = ReceiveGroup.all\r\n end",
"def show\n @users = @group.users_del_grupo\n end",
"def index\n @groups = Group.paginate :page => (params[:page]||1), :order => 'name ASC', :per_page => 10\n \n @self_member_groups = Group.find(User.find(current_user).group_members.map(&:group_id)) \n @self_created_groups = User.find(current_user).groups\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def user_groups\n return @user_groups if @user_groups\n\n @user_groups = default_user_groups\n @user_groups |= current_user.groups if current_user and current_user.respond_to? :groups\n @user_groups |= ['registered'] if !current_user.new_record? && current_user.is_osu\n @user_groups\n end",
"def notify_groups_for_alert(alert)\n @alert = alert\n groups = Group.where(id: alert.groups_alerted)\n\n users = groups.inject([]) do |users, group|\n users += group.users\n end.uniq\n\n user_emails = users.map(&:email)\n\n mail bcc: user_emails, subject: \"Alerta de inventário de item\"\n end"
] | [
"0.730336",
"0.70379317",
"0.6966023",
"0.6914727",
"0.69081515",
"0.68440163",
"0.6807493",
"0.6733953",
"0.66246724",
"0.6614498",
"0.66074836",
"0.6607402",
"0.65997714",
"0.6574667",
"0.65604717",
"0.65604717",
"0.65504134",
"0.65265447",
"0.6526043",
"0.6525542",
"0.65183663",
"0.64909667",
"0.6454253",
"0.6439522",
"0.6423322",
"0.6412034",
"0.6334846",
"0.6331531",
"0.6307633",
"0.6305884",
"0.6288458",
"0.62676984",
"0.6259198",
"0.6247519",
"0.6245906",
"0.62239945",
"0.6213198",
"0.62126887",
"0.6186101",
"0.61847055",
"0.6176466",
"0.6173975",
"0.6162166",
"0.6151009",
"0.6143902",
"0.61356366",
"0.6123484",
"0.61213994",
"0.6111109",
"0.6107933",
"0.6106973",
"0.6104935",
"0.6075246",
"0.6073926",
"0.6068391",
"0.60598844",
"0.60598844",
"0.60590726",
"0.6041387",
"0.6027627",
"0.6023446",
"0.60079384",
"0.5999933",
"0.59960335",
"0.59791815",
"0.5966679",
"0.59663105",
"0.5965649",
"0.5960448",
"0.59510845",
"0.59510845",
"0.5945452",
"0.59399456",
"0.59391475",
"0.5936233",
"0.5922763",
"0.5920613",
"0.5918093",
"0.5916136",
"0.59084934",
"0.5888449",
"0.5885699",
"0.58843994",
"0.5879519",
"0.5875525",
"0.5871115",
"0.58616036",
"0.5859752",
"0.58553296",
"0.584985",
"0.58469164",
"0.58444315",
"0.58415323",
"0.58370876",
"0.5830579",
"0.5827411",
"0.5826673",
"0.5821302",
"0.5810587",
"0.5809125"
] | 0.73533 | 0 |
List notification groups List all notification groups from the current user | def notification_groups_list_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_list ...'
end
# resource path
local_var_path = '/notification_groups'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:body]
# return_type
return_type = opts[:return_type] || 'Array<Object>'
# auth_names
auth_names = opts[:auth_names] || ['Basic', 'Token']
new_options = opts.merge(
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: NotificationGroupsApi#notification_groups_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
response = ::Phrase::Response.new(data, headers)
return response, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notification_groups_list(opts = {})\n data, _status_code, _headers = notification_groups_list_with_http_info(opts)\n data\n end",
"def group_members\n Notification.where(group_owner_id: id)\n end",
"def index\n @groups = []\n for member in current_user.members\n @groups << member.group\n end\n end",
"def list_groups\n if @user.permission_level.value == PermissionLevel.order(\"value DESC\").first.value\n render :json => Group.find(:all).map{|g| g}\n else\n render :json => @user.groups.map{|g| g}\n end\n end",
"def groups_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def index\n @groups = Group.display_for_user(current_user)\n end",
"def index\n\t\t@groups = current_user.groups\n\tend",
"def index\n @groups = current_user.groups\n end",
"def index\n @user = User.find(current_user.id)\n @groups = @user.groups.all\n end",
"def index\n @groups = Group.where(:user_id => current_user)\n end",
"def groups\n Group.groups(user_name)\n end",
"def index\n if user_signed_in?\n @groups = current_user.groups\n else\n redirect_to new_user_session_path\n end\n end",
"def list_groups\n groups = CanvasSpaces.GroupCategory.groups.active.order(:name)\n # filter out non-public groups for non-admins\n groups = groups.where(join_level: 'parent_context_auto_join') unless @current_user.account.site_admin?\n groups_json = Api.paginate(groups, self, api_v1_canvas_spaces_groups_url).map do |g|\n include = @current_user.account.site_admin? || @current_user.id == g.leader_id ? ['users'] : []\n group_formatter(g, { include: include })\n end\n render :json => groups_json\n end",
"def group_users\n DiscussionGroupUser.where(\"discussion_group_id=? AND is_member=?\", self.id, true)\n end",
"def groups()\n id_list = SQLQuery.new.get('groups_handler', ['group_id']).where.if('user_id', @id).send\n groups_list = []\n id_list.each do |id|\n groups_list << Groupchat.get(id['group_id'])\n end\n return Sorter.last_interaction(groups_list)\n end",
"def list_groups\n BrickFTP::API::Group.all\n end",
"def list_groups\n BrickFTP::API::Group.all\n end",
"def groups\n UserGroups.new(:id => id).get.items\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def index\n @notify = current_user.invited_members;\n @groups = Group.all\n @group = Group.new\n\n end",
"def list_groups()\n response = HTTParty.get(\"https://graph.microsoft.com/v1.0/groups\", { \n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Host\" => 'graph.microsoft.com' \n }\n })\n return JSON.parse response.read_body\n end",
"def send_group_list\n I3.server.send_object(I3.directory.find_all_groups)\n end",
"def list\n @groups = Group.find(:all, :order => 'name')\n end",
"def get_user_groups\n user_groups.keys\n end",
"def index\n @groups = query(GROUP, :name)\n\n # restrict the groups to the groups of the current user\n # unless the current user is allowed to create groups\n # and need to see all\n unless allowed(:create)\n allowed_group_ids = current_user.groups.collect {|g| g.id }\n @groups.delete_if do |g|\n ! allowed_group_ids.member?(g.id)\n end\n end\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @groups }\n end\n end",
"def list_notifications # :norobots:\n @notifications = Notification.find_all_by_user_id(@user.id, order: :flavor)\n end",
"def show_by_user\n @groups = Group.where(user_id: current_user.id)\n \n end",
"def group_list(user_id, sort = \"my_activity\")\n data = request(\"/group/list\", id: user_id, sort: sort)\n Hashie::Mash.new(data[\"groups\"][\"list\"])\n end",
"def groups\n FfcrmMailchimp::Group.groups_for(id)\n end",
"def hc_group_list(id)\n org=Org.find(id)\n org.hc_groups.group_list\n end",
"def index\n @user_groups = current_user.users_groups.page(params[:page]).per(20)\n end",
"def index\n @os_groups_notices = OsGroupsNotice.all\n end",
"def index\n @groups = current_user.groups\n render json: @groups\n end",
"def hc_group_list_all(id)\n org=Org.find(id)\n org.hc_groups.all(:order=>'group_name')\n end",
"def watcher_groups_list(object)\n remove_allowed = User.current.allowed_to?(\"delete_#{object.class.name.underscore}_watchers\".to_sym, object.project)\n content = ''.html_safe\n \n lis = object.watcher_groups.collect do |group|\n s = ''.html_safe\n s << link_to_group(group, :class => 'group')\n if remove_allowed\n url = {:controller => 'watcher_groups',\n :action => 'destroy',\n :object_type => object.class.to_s.underscore,\n :object_id => object.id,\n :group_id => group}\n s << ' '\n s << link_to(image_tag('delete.png'), url,\n :remote => true, :method => 'post', :style => \"vertical-align: middle\", :class => \"delete\")\n end\n content << content_tag('li', s)\n end\n content.present? ? content_tag('ul', content) : content\n end",
"def get_device_group_list\n query_api('device-groups')\n end",
"def do_list_groups()\n I18n.t(\"sms.some_groups\") + \": \" + Group.primary_group_abbrevs\n end",
"def fNotificationListFrom (email)\n @users.notificationListFrom(email)\n end",
"def index\n # @groups = Group.all\n if current_user\n @groups = Group.where(user_id: current_user.id)\n else\n redirect_to '/users/sign_in'\n end\n end",
"def show\n @user = current_user\n @user_groups = @user.groups\n\n @active_groups = []\n @pending_groups = []\n @pending_memberships = []\n @user.memberships.each do |m|\n if (m.status == \"active\")\n group = Group.find(m.group_id)\n @active_groups.push(group)\n elsif (m.status == \"pending\")\n group = Group.find(m.group_id)\n @pending_groups.push(group)\n @pending_memberships.push(m)\n end\n end\n end",
"def index\n\t\t@user = User.find(session[:id])\n\t\t@groups = Group.all\n\tend",
"def index\n @groups = Group.all.includes(:user)\n end",
"def users\n Webmail::User.in(group_ids: id)\n end",
"def index\n @usergroups = Usergroup.all\n end",
"def index\n @member_groups = @user.groups_where_member\n @admin_groups = @user.groups_where_admin\n end",
"def find_user_groups\r\n user_group = Group.where(\"id IN (SELECT gu.group_id FROM groups_users gu WHERE gu.user_id = ?)\", User.current.id).all\r\n group_names = []\r\n user_group.each do |group|\r\n group_names << group.lastname\r\n end\r\n return group_names\r\n end",
"def get_all_usergroups\n response = get_siteinfo('usergroups')\n ret = {}\n response['query']['usergroups'].each do |g|\n ret[g['name']] = g['rights']\n end\n ret\n end",
"def index\n render json: current_user.membered_groups\n end",
"def list(response)\n requested_group = response.args[1]\n output = get_groups_list(response.args[1])\n if output.empty?\n response.reply(empty_state_for_list(requested_group))\n else\n response.reply(output.join(\"\\n\"))\n end\n end",
"def subscriber_groups(identifier)\n connection.get(\"subscribers/#{identifier}/groups\")\n end",
"def group_notifications\n @attributes[:group_notifications]\n end",
"def index\n @discussion_groups = @login_user.all_public_private_groups\n respond_to do |format|\n format.html # index.html.erb\n # format.xml { render :xml => @discussion_groups }\n end\n end",
"def membership_list_for_group(email)\n Gaps::DB::Cache.with_cache_key(\"mygroupinfos:#{email}\") do\n membership_list(email)\n end\n end",
"def get_all_groups\n grps = self.get_groups_recursively\n grps << self.home_group\n logged_in_group = Group.new(:name => \"logged in user\")\n logged_in_group.id = 0\n grps << logged_in_group\n anonymous_group = Group.new(:name => \"anonymous user\")\n anonymous_group.id = -1\n grps << anonymous_group\n return grps.compact.uniq\n end",
"def groups\n response[\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(client, group)}\n end",
"def groups\n config.redis_connection.smembers \"#{config.prefix}:groups\"\n end",
"def list_notifications\n BrickFTP::API::Notification.all\n end",
"def list_notifications\n BrickFTP::API::Notification.all\n end",
"def getUserGroups\n \t@group_meals=GroupMealsParticipant.find_all_by_user_id(current_user.id)\n \tif(current_user.alert)\n \t\tcurrent_user.alert=false\n \t\tcurrent_user.save\n \tend\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @group_meal }\n end\n end",
"def get_notifications\n \t\n \t@notifs = []\n\n \tif current_user\n @notifs = Notification.where(:user_id => current_user.id, :seen => false)\n \tend\n end",
"def list(response)\n requested_group = response.args[1]\n output = get_groups_list(requested_group)\n if output.empty?\n if requested_group\n response.reply(\n \"There is no authorization group named #{requested_group}.\"\n )\n else\n response.reply(\"There are no authorization groups yet.\")\n end\n else\n response.reply(output.join(\"\\n\"))\n end\n end",
"def index\n @groups_all = current_user.groups.paginate(page: params[:page]).order('name ASC')\n\n @owner = current_user\n @users = User.where(\"owner_id = ?\", current_user).order('lastname ASC')\n\n respond_to do |format|\n format.html { render @groups }\n format.json { render json: @groups }\n end\n end",
"def index\n @menu_groups = MenuGroup.where(:user_id => current_user.id).order(id: :asc)\n end",
"def get_groups(params)\n send_get \"get_groups\", params\n end",
"def index\n @notifications = Notification.where(user: current_user)\n end",
"def index\n unless user_signed_in?\n redirect_to new_user_session_path\n else\n @group_id = UserDefaultGroup.find_by_user_id(current_user.id)\n @group_id = @group_id.group_id unless @group_id.nil?\n #@users = User.all\n @users = User.joins(\"Left Join (select user_id, group_id From group_memberships) fm ON fm.user_id = users.id\").where(\"fm.group_id = ?\", @group_id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end\n end",
"def index\n @group_messages = GroupMessage.all\n end",
"def list_users\n group_id_param = params[:group_id]\n\n if group_id_param.nil? || group_id_param.blank?\n render json: { error: 'group_id not specified.' }, status: :bad_request\n return\n end\n\n group = CanvasSpaces.GroupCategory.groups.find_by_id(group_id_param)\n if group.nil?\n render json: { error: 'No such group found.' }, status: :bad_request\n else\n if @current_user.account.site_admin? || group.leader_id == @current_user.id\n render json: { size: group.users.count, users: group.users.map { |user| user.as_json(only: [:id, :name], include_root: false) } }, status: :ok\n else\n # doesn't have access to the group\n render json: { error: \"Can't list users. Not owner.\" }, status: :forbidden\n end\n end\n end",
"def list(\n filter,\n *args,\n deadline: nil\n )\n return @remote_identity_groups.list(\n filter,\n *args,\n deadline: deadline,\n )\n end",
"def index\n @groups = @flr.groups.all\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n\t\t# si rol mayor a desarrollador, listar todos los grupos \n \tif has_role_with_hierarchy?(:administrador) \n\t\t\t@groups = Group.all\n\t\t# si rol es desarrollador, listar solo sus grupos\n\t\telse\n\t\t\t@groups = Group.all :conditions => { :user_id, current_user.id }\n\t\tend\n end",
"def groups\n return [] if self.group_list.nil?\n self.group_list\n end",
"def available_groups\n @available_groups ||= begin\n current_user.groups\n .sort_by { |g| g.description.downcase }\n .map { |g| { id: g.id, description: g.description, user_permissions: g.user_permissions(current_user.login) } }\n # :nocov:\n rescue StandardError\n []\n end\n # :nocov:\n end",
"def groups\r\n @groups ||= fetch_groups\r\n end",
"def show\n @group_members = GroupMember.where(group_id:params[:id])\n @users_in_group=[]\n @group_members.each do |f|\n @user = User.find(f[:user_id])\n @users_in_group.push(@user)\n end\n render json: @users_in_group\n end",
"def index\n @messages = current_user.messages_in.order('created_at ASC').group('sender_id')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def group_members\n members(\"Group\")\n end",
"def index\n\t#Once sessions are implemented, return all groups where the user has a priveledge\n\t#A table including all subgroups will be generated.\n\tGroup.rebuild! if nil.|Group.find(:first).rgt\n\n\t@groups = current_user.get_unique_group_branches\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def groups()\n\t\t\t\tuserlist = users()\n\n\t\t\t\tgrouplist = GroupList.new()\n\t\t\t\tFile.open('/etc/group', File::RDONLY) { |fp|\n\t\t\t\t\tregex = /^([a-zA-Z0-9-]+):[^:]+:([0-9]+):([^:]*)/\n\t\t\t\t\tfp.each_line() { |line|\n\t\t\t\t\t\tmatch = regex.match(line)\n\t\t\t\t\t\tif(match != nil)\n\t\t\t\t\t\t\tgroup = GroupInfo.new()\n\t\t\t\t\t\t\tgroup.groupname = match[1]\n\t\t\t\t\t\t\tgroup.gid = match[2].to_i()\n\t\t\t\t\t\t\tgroup.members = UserList.new()\n\t\t\t\t\t\t\tif(match[3] != nil)\n\t\t\t\t\t\t\t\tusers = match[3].split(/,/)\n\t\t\t\t\t\t\t\tusers.each() { |username|\n\t\t\t\t\t\t\t\t\tif(userlist.has_key?(username))\n\t\t\t\t\t\t\t\t\t\tgroup.members[username] = userlist[username]\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tgrouplist[group.groupname] = group\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn(grouplist)\n\t\t\tend",
"def notifications\n @other_user = @login_user\n @notifications = DiscussionGroupUser.where(['user_id =? AND is_member=?', @login_user.id, false])\n @disc_notifications = NonSiteUser.where([\"email=? AND invitable_type=? and invitation_type=?\",@login_user.email,\"Discussion\",\"Invited\"])\n respond_to do |format|\n format.html\n end\n end",
"def list_groups(options = {})\n request({\n 'Action' => 'ListGroups',\n :parser => Fog::Parsers::AWS::IAM::ListGroups.new\n }.merge!(options))\n end",
"def groups(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Groups\", params: params)\n end",
"def getGroups\n groups = $gm.get(\"/groups\", @token, \"per_page=100\")\n group_ids = Array.new\n\n groups['response'].each do |group|\n group_ids.push({\n 'name' => group['name'],\n 'group_id' => group['id'],\n 'image' => group['image_url']})\n end\n\n return group_ids\n end",
"def index\n @users = @group.users\n end",
"def groups\n find(:group).map { |g| g.content }\n end",
"def users\n GroupMembers.new(:id => id).get.items\n end",
"def admin_conversations_restrictAccess_listGroups(options = {})\n raise ArgumentError, 'Required arguments :channel_id missing' if options[:channel_id].nil?\n post('admin.conversations.restrictAccess.listGroups', options)\n end",
"def show\n @group = Group.find(params[:id])\n\n @event = Event.find(@group.event_id)\n @members = current_user.get_members(@group)\n\n @messages = []\n @members.each do |member|\n @messages.concat(member.get_messages_in(@event))\n end\n\n @messages = @messages.sort_by &:created_at\n @messages = @messages.reverse\n end",
"def index\n # Only get the messages for the user currently signed in\n if current_user.group.messages_released\n \t@messages = current_user.messages\n else\n \t@messages = {}\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { send_data @messages }\n end\n end",
"def index\n @groups_user = GroupsUser.find(params[:id])\n @groups_users = GroupsUser.all\n end",
"def ldap_groups\n User.walk_ldap_groups(User.ldap_member_of(user_key), []).sort\n end",
"def get_user_groups username_for, options = {}\n do_request 'get_user_groups', options.merge(username_for: username_for)\n end",
"def index\n # byebug \n @groups = current_user.groups\n @group_members=GroupMember.all\n # @[email protected]\n end",
"def index\r\n @receive_groups = ReceiveGroup.all\r\n end",
"def show\n @users = @group.users_del_grupo\n end",
"def index\n @groups = Group.paginate :page => (params[:page]||1), :order => 'name ASC', :per_page => 10\n \n @self_member_groups = Group.find(User.find(current_user).group_members.map(&:group_id)) \n @self_created_groups = User.find(current_user).groups\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @groups }\n end\n end",
"def user_groups\n return @user_groups if @user_groups\n\n @user_groups = default_user_groups\n @user_groups |= current_user.groups if current_user and current_user.respond_to? :groups\n @user_groups |= ['registered'] if !current_user.new_record? && current_user.is_osu\n @user_groups\n end",
"def notify_groups_for_alert(alert)\n @alert = alert\n groups = Group.where(id: alert.groups_alerted)\n\n users = groups.inject([]) do |users, group|\n users += group.users\n end.uniq\n\n user_emails = users.map(&:email)\n\n mail bcc: user_emails, subject: \"Alerta de inventário de item\"\n end"
] | [
"0.73533",
"0.730336",
"0.70379317",
"0.6966023",
"0.6914727",
"0.69081515",
"0.68440163",
"0.6807493",
"0.6733953",
"0.66246724",
"0.6614498",
"0.66074836",
"0.6607402",
"0.65997714",
"0.6574667",
"0.65604717",
"0.65604717",
"0.65504134",
"0.65265447",
"0.6526043",
"0.6525542",
"0.65183663",
"0.64909667",
"0.6454253",
"0.6439522",
"0.6423322",
"0.6412034",
"0.6334846",
"0.6331531",
"0.6307633",
"0.6305884",
"0.6288458",
"0.62676984",
"0.6259198",
"0.6247519",
"0.6245906",
"0.62239945",
"0.6213198",
"0.62126887",
"0.6186101",
"0.61847055",
"0.6176466",
"0.6173975",
"0.6162166",
"0.6151009",
"0.6143902",
"0.61356366",
"0.6123484",
"0.61213994",
"0.6111109",
"0.6107933",
"0.6106973",
"0.6104935",
"0.6075246",
"0.6073926",
"0.6068391",
"0.60598844",
"0.60598844",
"0.60590726",
"0.6041387",
"0.6027627",
"0.6023446",
"0.60079384",
"0.5999933",
"0.59960335",
"0.59791815",
"0.5966679",
"0.59663105",
"0.5965649",
"0.5960448",
"0.59510845",
"0.59510845",
"0.5945452",
"0.59399456",
"0.59391475",
"0.5936233",
"0.5922763",
"0.5920613",
"0.5918093",
"0.5916136",
"0.59084934",
"0.5888449",
"0.5885699",
"0.58843994",
"0.5879519",
"0.5875525",
"0.5871115",
"0.58616036",
"0.5859752",
"0.584985",
"0.58469164",
"0.58444315",
"0.58415323",
"0.58370876",
"0.5830579",
"0.5827411",
"0.5826673",
"0.5821302",
"0.5810587",
"0.5809125"
] | 0.58553296 | 89 |
Mark all notification groups as read Mark all notification groups of the current user as read | def notification_groups_mark_all_as_read(opts = {})
data, _status_code, _headers = notification_groups_mark_all_as_read_with_http_info(opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_notifications_as_read!(user)\n self.notifications.where(read: false, user_id: user.id).update_all(read: true)\n end",
"def mark_notification_as_read!\n notification = User.find(@userid).notifications\n @received_msg.each do |notify|\n notification.update(notify['id'], :checked => true);\n end\n end",
"def mark_all_as_read\n @notifications = Notification.unread.for_user(current_api_v1_user)\n @notifications.update_all(read_at: Time.now) unless @notifications.blank?\n @notifications = Notification.where(recipient_id: current_api_v1_user.id)\n \n render json: @notifications\n end",
"def mark_notifications_read\n return if params[:notification_id].blank? or !user_signed_in?\n n = Notification.find(params[:notification_id])\n current_subject.mark_as_read n\n end",
"def mark_all_news_as_read\n where(:user_id => User.current_user_id).update_all(:read => 1)\n end",
"def mark_as_read\n @notifications = Notification.where(recipient: current_user).unread\n @notifications.update_all(read_at: Time.zone.now)\n render json: {success: true}\n end",
"def mark_as_read\n DeterLab.mark_notifications(current_user_id, [ params[:id] ], [ { isSet: true, tag: Notification::READ } ])\n render text: 'ok'\n end",
"def set_to_read\n\t\t#We find all the messages in the current conversation\n\t\t@conversation_messages = PersonalMessage.where(conversation_id: @conversation).all\n\t\t@conversation_messages.each do |message|\n\t\t\t# We mark as read the messages recieved by the current user \n\t\t\tif message.user_id != current_user.id\n\t\t\t\tmessage.update(read: true) unless message.read != false\n\t\t\tend\n\t\tend\n\tend",
"def mark_all_messages_as_read(options={})\n RecipientsFor::ReaderInfo.where(\n reciveable_type: options[:reciveable].class.name,\n reciveable_id: options[:reciveable].id,\n ).update_all(read: true)\n end",
"def mark_unread!\n update_is_read_status false\n end",
"def mark_as_unread()\n update_attribute('read', false)\n end",
"def set_user_read_all(user_id, did_read)\n self.messages.each {|m| m.set_user_read(user_id, did_read)}\n end",
"def mark_as_read\n\t\tunread_messages = current_user.received_messages.where(read: false).order('id desc').limit(10)\n\t\tunread_messages.each do |m|\n\t\t\tm.update_attribute(:read, true)\n\t\t\tm.save\n\t\tend\n\t\tredirect_to request.referer\n\tend",
"def read user_id\n messages.unread(user_id).each do |m|\n m.read = true\n m.save\n end\n end",
"def mark_as_unread\n update_attributes(is_read: false)\n end",
"def mark_as_unread\n Notifyer::Notification.all.each do |n|\n n.update(is_read: false)\n end\n redirect_to :back\n end",
"def notification_groups_mark_as_read(id, opts = {})\n data, _status_code, _headers = notification_groups_mark_as_read_with_http_info(id, opts)\n data\n end",
"def mark_as_read\n self.update(read: true)\n end",
"def mark_notifications_as_read(options = {})\n boolean_from_response :put, 'notifications', options\n end",
"def mark_as_unread\n update_attributes(:is_read => false)\n end",
"def mark_as_unread\n update_attributes(:is_read => false)\n end",
"def mark_read!\n update_is_read_status true\n end",
"def mark_as_read\n update_attributes(is_read: true)\n end",
"def mark_as_read\n if Notification.mark_as_read\n return_message(200, :ok)\n else\n return_message(200, :fail)\n end\n end",
"def mark_all_readed\n doctor.notifications.update_all unreaded: false\n send_json doctor.notifications, true\n end",
"def mark_all_entries_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :forced_read_state,\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def mark_all_read\r\n @channel.mark_messages_read_for current_user\r\n respond_to do |format|\r\n format.html { redirect_to channel_messages_url(@channel), notice: 'Nachrichten als gelesen markiert.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def mark_as_read\n payload = { \"chat\" => [id] }.to_json\n path = \"/#{api_prefix}/user/#{client.user.id}/rooms/#{room_id}/unreadItems\"\n\n client.post path, payload\n\n true\n end",
"def set_read_status\n\t\t\tNotificationReceiver.where(notification_id: params[:id], user_id: current_user.id).update_all(is_read: true)\n\n\t\t\trender json: {\n\t\t\t\tstatus: 0\n\t\t\t}\n\t\tend",
"def mark_as_read\n update_attributes(:is_read => true)\n end",
"def mark_as_read\n update_attributes(:is_read => true)\n end",
"def mark_as_read\n @client.post('/api/mod/conversations/read', conversationIds: [get_attribute(:id)])\n end",
"def mark_as_read!\n update_attributes(read: true)\n end",
"def mark_all_user_notifications_notified(user)\n user.notifications.each do |n|\n n.notified = true\n n.save\n end\n end",
"def mark_all_entries_as_unread_groups(group_id,topic_id,opts={})\n query_param_keys = [\n :forced_read_state\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end",
"def load_notifications\n # reload user data\n user = User.find current_user.id\n @notifications = user.notifications.order(\"updated_at DESC\")\n\n new_feeds = user.notification_readers.select {|feed| !feed.isRead?}\n new_feeds.each do |feed|\n feed.read_at = Time.zone.now\n feed.save!\n end\n end",
"def mark_as_read(options = {})\n default_options = {}\n add_mailbox_condition!(default_options, @type)\n return update_mail(\"mail_items.read = true\", default_options, options)\n end",
"def mark_notification_as_read(notification_id)\n request(:post, \"/api/notifications/mark_as_read/#{notification_id}/\")\n end",
"def mark_as_read_notification(notification_id)\n post(\"notifications/#{notification_id}/markAsRead\")\n end",
"def reset_unread_notification_count\n post('notifications/markAsRead')\n end",
"def set_read_groups(groups, eligible_groups)\n set_entities(:read, :group, groups, eligible_groups)\n end",
"def read_notifications\n # Update post notification\n post_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Post', @post.id)\n .first\n post_notification.update_attributes(read: true) unless post_notification.nil?\n\n # Update post's messages notifications\n @post.messages.each do |message|\n message_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Message', message.id)\n .first\n message_notification.update_attributes(read: true) unless message_notification.nil?\n end\n end",
"def mark_as_read()\n update_attribute('read', true)\n end",
"def mark_all_posts usr\n return false if usr.blank?\n @conv.posts.each do |post|\n post.mark_as_read! for: usr if post\n end\n end",
"def notification_groups_mark_all_as_read_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_all_as_read ...'\n end\n # resource path\n local_var_path = '/notification_groups/mark_all_as_read'\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 header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Object>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_mark_all_as_read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end",
"def mark_read_messages(conversation)\n time = Time.current\n conversation = Conversation.find(conversation) if conversation.is_a?(Integer)\n conversation_members.where(conversation_id: conversation).update_all(last_seen: time)\n Rails.cache.delete(conversation.get_unread_cache_key_for(id))\n Rails.cache.delete(\"user-unread_messages_count-#{id}\")\n PubSub::Publisher.new.publish_for(conversation.user_participants.where.not(id: id), 'read_messages', {id: conversation.id, seen_at: time.to_i, user_id: id}, {foreground: true})\n end",
"def mark_as_read(item)\n receipts_for_item(item).update_all(read: true)\n end",
"def read_groups=(groups)\n set_read_groups(groups, read_groups)\n end",
"def show\n @notifications = Notification.where(user: current_user).where(notification_obeject_id: params[:id]).where(read: false)\n @notifications.each do |note|\n note.read = true\n note.save\n end\n end",
"def mark_repo_notifications_as_read(repo, options = {})\n boolean_from_response :put, \"#{Repository.path repo}/notifications\", options\n end",
"def add_read_group\n return if expired?\n\n unless media_object.read_groups.include?(self.token)\n media_object.read_groups += [self.token]\n media_object.save!\n end\n end",
"def unread\n all(UNREAD)\n end",
"def mark_as_read(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_read if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_read(self)\n when Mailboxer::Conversation\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n end",
"def mark_as_read_by_updater\n mark_as_read! for: updater\n end",
"def unread\n @notifications = Notification.where(user_id: current_user.uid).where(is_read: false).page(params[:page]).order(created_at: :desc)\n end",
"def mark_as_read\n return @mark_as_read\n end",
"def mark_as_unread\n @client.post('/api/mod/conversations/unread', conversationIds: [get_attribute(:id)])\n end",
"def mark_as_read_by_creator\n mark_as_read! for: creator\n end",
"def users_that_can_read_group(users, group)\n DeclarativePolicy.subject_scope do\n users.select { |u| allowed?(u, :read_group, group) }\n end\n end",
"def set_notifications\n @notifications = current_user.my_notifications\n end",
"def mark_as_read!\n self.read_at = Time.now\n save!\n end",
"def unread!\n self.update_attribute(:status, UNREAD)\n end",
"def unread\n un_read(false, \"non lue\")\n end",
"def mark_all_as_read(opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n {}\n \n )\n\n # resource path\n path = path_replace(\"/v1/conversations/mark_all_as_read\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end",
"def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end",
"def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end",
"def show\n @message.mark_as_read(current_user)\n end",
"def read_groups\n read_group_field = Hydra.config[:permissions][:read][:group]\n rg = edit_groups | ((@permissions_solr_document == nil || @permissions_solr_document.fetch(read_group_field,nil) == nil) ? [] : @permissions_solr_document.fetch(read_group_field,nil))\n logger.debug(\"read_groups: #{rg.inspect}\")\n return rg\n end",
"def read_messages\n @useConversations = Message.where(\"user_id = (?)\", current_user.id).pluck(:conversation_id)\n if @useConversations.count > 0\n @useConversations = @useConversations.uniq # Unique\n @useConversations = @useConversations.map(&:inspect).join(', ')\n #@updatemsg = Message.where(\"user_id != (?) and conversation_id IN (?)\", current_user.id, @useConversations).update_all(:mark_as_read => true)\n @updatemsg = Message.where(\"user_id != #{current_user.id} and conversation_id in (#{@useConversations})\").update_all(:mark_as_read => true)\n session[:mark_messages] = 0 # Mark as read messages\n end\n end",
"def unread_messages\n @user_wise_unread_messages = current_user.user_messages\n .where(is_read: false)\n .joins(:message)\n .group('messages.user_id').count\n end",
"def read\n @activities = PublicActivity::Activity.where(recipient_id: current_user.id, read: false).order(created_at: :desc)\n @activities.each do |act|\n act.read = true;\n act.save\n end\n end",
"def mark_read id\n logged_in?\n post('/api/read_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end",
"def notification_groups_mark_as_read_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_as_read ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling NotificationGroupsApi.notification_groups_mark_as_read\"\n end\n # resource path\n local_var_path = '/notification_groups/{id}/mark_as_read'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\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 header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'NotificationGroupDetail' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_mark_as_read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end",
"def mark_as_unread\n post(\"/api/unread_message\", id: fullname)\n end",
"def set_rights_metadata\n self.edit_groups = ['Chronos-Pligtaflevering']\n self.read_groups = ['Chronos-Alle']\n self.discover_groups = ['Chronos-Alle']\n end",
"def mark_as_unread(options = {})\n update_receipts({ is_read: false }, options)\n end",
"def set_notifications\n\t\t@notifications = Notification.where(reciever_id: current_user).order(\"created_at DESC\")\n\tend",
"def mark_read!\n self.read_at = Time.now\n self.save!\n end",
"def update\n #read or unread\n end",
"def mark_as_unread(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_unread if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_unread(self)\n when Mailboxer::Conversation\n obj.mark_as_unread(self)\n when Array\n obj.map{ |sub_obj| mark_as_unread(sub_obj) }\n end\n end",
"def mark_as_read(participant)\n return unless participant\n self.receipts.recipient(participant).mark_as_read\n end",
"def remove_read_group\n if media_object && media_object.read_groups.include?(self.token)\n media_object.read_groups -= [self.token]\n media_object.save!\n end\n end",
"def reset_permissions_for(item)\n item.edit_groups = []\n item.edit_users = []\n item.read_groups = []\n item.read_users = []\n end",
"def tag_as_read(user)\n self.read = true\n self.save\n self.answers.each do |a|\n a.read = true unless a.user_id.eql? user.id #we don't to tag as read his answers\n a.save\n end\n end",
"def notify_user_acl_modified(user_ids)\n Cache::Album::Manager.shared.user_albums_acl_modified(user_ids)\n end",
"def set_unread_message_count\n self.unread_messages = 1\n end",
"def mark_as_read=(value)\n @mark_as_read = value\n end",
"def index\n\t\t@notifications = Notification.where(recipient_id: current_user.id).unread\n\tend",
"def public_write_was\n writer_group_ids == [UserGroup.all_users.id]\n end",
"def markMail(imap, folder)\n pp \"MARKED #{folder}..\"\n message_ids = imap.uid_search(\"ALL\")\n imap.uid_store(message_ids, \"+FLAGS\", [:Seen])\n imap.expunge\nend",
"def set_unread_state\n self.feed.users.reload.find_each do |user|\n if !EntryState.exists? user_id: user.id, entry_id: self.id\n entry_state = user.entry_states.create! entry_id: self.id, read: false\n end\n end\n end",
"def mark_as_read(participant)\n return unless participant\n receipts_for(participant).mark_as_read\n end",
"def mark_topic_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def mark_as_read(time=Time.now)\n unless read?\n self.recipient_read_at = time\n save!\n end\n end",
"def unread_unsent_notifications_for_group\n @unread_unsent_notifications_for_group ||= unread_unsent_notifications.where('notify_user_notifications.group_id = ?', notification.group_id)\n end",
"def mark_unread id\n logged_in?\n post('/api/unread_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end",
"def unread_messages\n current_user.messages_in.where(read: false).count\n end",
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n\n end",
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self, details)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj, details) }\n end\n\n end",
"def mark_topic_as_unread_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end"
] | [
"0.7631108",
"0.75232005",
"0.7271338",
"0.7209958",
"0.71136564",
"0.7043174",
"0.69399095",
"0.68428254",
"0.67394173",
"0.67244416",
"0.6717934",
"0.6698578",
"0.6649359",
"0.66276115",
"0.659942",
"0.6558207",
"0.6492215",
"0.64887977",
"0.6462056",
"0.64539206",
"0.64539206",
"0.6401944",
"0.6373204",
"0.63469636",
"0.63175434",
"0.63127595",
"0.63106525",
"0.63084453",
"0.62789935",
"0.6258232",
"0.6258232",
"0.6224523",
"0.6151769",
"0.6137738",
"0.61224985",
"0.61054647",
"0.60980797",
"0.60851055",
"0.60349005",
"0.6026549",
"0.60180044",
"0.6016407",
"0.60083556",
"0.60059756",
"0.5988537",
"0.59661615",
"0.59343606",
"0.59184676",
"0.5911188",
"0.5893361",
"0.58604324",
"0.5832743",
"0.5806275",
"0.57914823",
"0.57900816",
"0.57765114",
"0.573398",
"0.56856966",
"0.5680894",
"0.5649523",
"0.5634594",
"0.56229997",
"0.56102335",
"0.5608449",
"0.5589743",
"0.5589743",
"0.5583434",
"0.5564623",
"0.5553702",
"0.5551699",
"0.5535509",
"0.5527922",
"0.5522423",
"0.5506209",
"0.5497933",
"0.5490829",
"0.5485202",
"0.5452777",
"0.5437398",
"0.5428598",
"0.54270166",
"0.5416179",
"0.53893036",
"0.53888786",
"0.538697",
"0.5385525",
"0.53717417",
"0.5356177",
"0.53363764",
"0.5336115",
"0.53328794",
"0.53195024",
"0.5296557",
"0.5288112",
"0.5286896",
"0.5286434",
"0.52796686",
"0.52788",
"0.5278425",
"0.52748257"
] | 0.7305678 | 2 |
Mark all notification groups as read Mark all notification groups of the current user as read | def notification_groups_mark_all_as_read_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_all_as_read ...'
end
# resource path
local_var_path = '/notification_groups/mark_all_as_read'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:body]
# return_type
return_type = opts[:return_type] || 'Array<Object>'
# auth_names
auth_names = opts[:auth_names] || ['Basic', 'Token']
new_options = opts.merge(
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: NotificationGroupsApi#notification_groups_mark_all_as_read\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
response = ::Phrase::Response.new(data, headers)
return response, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_notifications_as_read!(user)\n self.notifications.where(read: false, user_id: user.id).update_all(read: true)\n end",
"def mark_notification_as_read!\n notification = User.find(@userid).notifications\n @received_msg.each do |notify|\n notification.update(notify['id'], :checked => true);\n end\n end",
"def notification_groups_mark_all_as_read(opts = {})\n data, _status_code, _headers = notification_groups_mark_all_as_read_with_http_info(opts)\n data\n end",
"def mark_all_as_read\n @notifications = Notification.unread.for_user(current_api_v1_user)\n @notifications.update_all(read_at: Time.now) unless @notifications.blank?\n @notifications = Notification.where(recipient_id: current_api_v1_user.id)\n \n render json: @notifications\n end",
"def mark_notifications_read\n return if params[:notification_id].blank? or !user_signed_in?\n n = Notification.find(params[:notification_id])\n current_subject.mark_as_read n\n end",
"def mark_all_news_as_read\n where(:user_id => User.current_user_id).update_all(:read => 1)\n end",
"def mark_as_read\n @notifications = Notification.where(recipient: current_user).unread\n @notifications.update_all(read_at: Time.zone.now)\n render json: {success: true}\n end",
"def mark_as_read\n DeterLab.mark_notifications(current_user_id, [ params[:id] ], [ { isSet: true, tag: Notification::READ } ])\n render text: 'ok'\n end",
"def set_to_read\n\t\t#We find all the messages in the current conversation\n\t\t@conversation_messages = PersonalMessage.where(conversation_id: @conversation).all\n\t\t@conversation_messages.each do |message|\n\t\t\t# We mark as read the messages recieved by the current user \n\t\t\tif message.user_id != current_user.id\n\t\t\t\tmessage.update(read: true) unless message.read != false\n\t\t\tend\n\t\tend\n\tend",
"def mark_all_messages_as_read(options={})\n RecipientsFor::ReaderInfo.where(\n reciveable_type: options[:reciveable].class.name,\n reciveable_id: options[:reciveable].id,\n ).update_all(read: true)\n end",
"def mark_unread!\n update_is_read_status false\n end",
"def mark_as_unread()\n update_attribute('read', false)\n end",
"def set_user_read_all(user_id, did_read)\n self.messages.each {|m| m.set_user_read(user_id, did_read)}\n end",
"def mark_as_read\n\t\tunread_messages = current_user.received_messages.where(read: false).order('id desc').limit(10)\n\t\tunread_messages.each do |m|\n\t\t\tm.update_attribute(:read, true)\n\t\t\tm.save\n\t\tend\n\t\tredirect_to request.referer\n\tend",
"def read user_id\n messages.unread(user_id).each do |m|\n m.read = true\n m.save\n end\n end",
"def mark_as_unread\n update_attributes(is_read: false)\n end",
"def mark_as_unread\n Notifyer::Notification.all.each do |n|\n n.update(is_read: false)\n end\n redirect_to :back\n end",
"def notification_groups_mark_as_read(id, opts = {})\n data, _status_code, _headers = notification_groups_mark_as_read_with_http_info(id, opts)\n data\n end",
"def mark_as_read\n self.update(read: true)\n end",
"def mark_notifications_as_read(options = {})\n boolean_from_response :put, 'notifications', options\n end",
"def mark_as_unread\n update_attributes(:is_read => false)\n end",
"def mark_as_unread\n update_attributes(:is_read => false)\n end",
"def mark_read!\n update_is_read_status true\n end",
"def mark_as_read\n update_attributes(is_read: true)\n end",
"def mark_as_read\n if Notification.mark_as_read\n return_message(200, :ok)\n else\n return_message(200, :fail)\n end\n end",
"def mark_all_readed\n doctor.notifications.update_all unreaded: false\n send_json doctor.notifications, true\n end",
"def mark_all_entries_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :forced_read_state,\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def mark_all_read\r\n @channel.mark_messages_read_for current_user\r\n respond_to do |format|\r\n format.html { redirect_to channel_messages_url(@channel), notice: 'Nachrichten als gelesen markiert.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def mark_as_read\n payload = { \"chat\" => [id] }.to_json\n path = \"/#{api_prefix}/user/#{client.user.id}/rooms/#{room_id}/unreadItems\"\n\n client.post path, payload\n\n true\n end",
"def set_read_status\n\t\t\tNotificationReceiver.where(notification_id: params[:id], user_id: current_user.id).update_all(is_read: true)\n\n\t\t\trender json: {\n\t\t\t\tstatus: 0\n\t\t\t}\n\t\tend",
"def mark_as_read\n update_attributes(:is_read => true)\n end",
"def mark_as_read\n update_attributes(:is_read => true)\n end",
"def mark_as_read\n @client.post('/api/mod/conversations/read', conversationIds: [get_attribute(:id)])\n end",
"def mark_as_read!\n update_attributes(read: true)\n end",
"def mark_all_user_notifications_notified(user)\n user.notifications.each do |n|\n n.notified = true\n n.save\n end\n end",
"def mark_all_entries_as_unread_groups(group_id,topic_id,opts={})\n query_param_keys = [\n :forced_read_state\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end",
"def load_notifications\n # reload user data\n user = User.find current_user.id\n @notifications = user.notifications.order(\"updated_at DESC\")\n\n new_feeds = user.notification_readers.select {|feed| !feed.isRead?}\n new_feeds.each do |feed|\n feed.read_at = Time.zone.now\n feed.save!\n end\n end",
"def mark_as_read(options = {})\n default_options = {}\n add_mailbox_condition!(default_options, @type)\n return update_mail(\"mail_items.read = true\", default_options, options)\n end",
"def mark_notification_as_read(notification_id)\n request(:post, \"/api/notifications/mark_as_read/#{notification_id}/\")\n end",
"def mark_as_read_notification(notification_id)\n post(\"notifications/#{notification_id}/markAsRead\")\n end",
"def reset_unread_notification_count\n post('notifications/markAsRead')\n end",
"def set_read_groups(groups, eligible_groups)\n set_entities(:read, :group, groups, eligible_groups)\n end",
"def read_notifications\n # Update post notification\n post_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Post', @post.id)\n .first\n post_notification.update_attributes(read: true) unless post_notification.nil?\n\n # Update post's messages notifications\n @post.messages.each do |message|\n message_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Message', message.id)\n .first\n message_notification.update_attributes(read: true) unless message_notification.nil?\n end\n end",
"def mark_as_read()\n update_attribute('read', true)\n end",
"def mark_all_posts usr\n return false if usr.blank?\n @conv.posts.each do |post|\n post.mark_as_read! for: usr if post\n end\n end",
"def mark_read_messages(conversation)\n time = Time.current\n conversation = Conversation.find(conversation) if conversation.is_a?(Integer)\n conversation_members.where(conversation_id: conversation).update_all(last_seen: time)\n Rails.cache.delete(conversation.get_unread_cache_key_for(id))\n Rails.cache.delete(\"user-unread_messages_count-#{id}\")\n PubSub::Publisher.new.publish_for(conversation.user_participants.where.not(id: id), 'read_messages', {id: conversation.id, seen_at: time.to_i, user_id: id}, {foreground: true})\n end",
"def mark_as_read(item)\n receipts_for_item(item).update_all(read: true)\n end",
"def read_groups=(groups)\n set_read_groups(groups, read_groups)\n end",
"def show\n @notifications = Notification.where(user: current_user).where(notification_obeject_id: params[:id]).where(read: false)\n @notifications.each do |note|\n note.read = true\n note.save\n end\n end",
"def mark_repo_notifications_as_read(repo, options = {})\n boolean_from_response :put, \"#{Repository.path repo}/notifications\", options\n end",
"def add_read_group\n return if expired?\n\n unless media_object.read_groups.include?(self.token)\n media_object.read_groups += [self.token]\n media_object.save!\n end\n end",
"def unread\n all(UNREAD)\n end",
"def mark_as_read(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_read if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_read(self)\n when Mailboxer::Conversation\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n end",
"def mark_as_read_by_updater\n mark_as_read! for: updater\n end",
"def unread\n @notifications = Notification.where(user_id: current_user.uid).where(is_read: false).page(params[:page]).order(created_at: :desc)\n end",
"def mark_as_read\n return @mark_as_read\n end",
"def mark_as_unread\n @client.post('/api/mod/conversations/unread', conversationIds: [get_attribute(:id)])\n end",
"def mark_as_read_by_creator\n mark_as_read! for: creator\n end",
"def users_that_can_read_group(users, group)\n DeclarativePolicy.subject_scope do\n users.select { |u| allowed?(u, :read_group, group) }\n end\n end",
"def set_notifications\n @notifications = current_user.my_notifications\n end",
"def mark_as_read!\n self.read_at = Time.now\n save!\n end",
"def unread!\n self.update_attribute(:status, UNREAD)\n end",
"def unread\n un_read(false, \"non lue\")\n end",
"def mark_all_as_read(opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n {}\n \n )\n\n # resource path\n path = path_replace(\"/v1/conversations/mark_all_as_read\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end",
"def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end",
"def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end",
"def show\n @message.mark_as_read(current_user)\n end",
"def read_groups\n read_group_field = Hydra.config[:permissions][:read][:group]\n rg = edit_groups | ((@permissions_solr_document == nil || @permissions_solr_document.fetch(read_group_field,nil) == nil) ? [] : @permissions_solr_document.fetch(read_group_field,nil))\n logger.debug(\"read_groups: #{rg.inspect}\")\n return rg\n end",
"def read_messages\n @useConversations = Message.where(\"user_id = (?)\", current_user.id).pluck(:conversation_id)\n if @useConversations.count > 0\n @useConversations = @useConversations.uniq # Unique\n @useConversations = @useConversations.map(&:inspect).join(', ')\n #@updatemsg = Message.where(\"user_id != (?) and conversation_id IN (?)\", current_user.id, @useConversations).update_all(:mark_as_read => true)\n @updatemsg = Message.where(\"user_id != #{current_user.id} and conversation_id in (#{@useConversations})\").update_all(:mark_as_read => true)\n session[:mark_messages] = 0 # Mark as read messages\n end\n end",
"def unread_messages\n @user_wise_unread_messages = current_user.user_messages\n .where(is_read: false)\n .joins(:message)\n .group('messages.user_id').count\n end",
"def read\n @activities = PublicActivity::Activity.where(recipient_id: current_user.id, read: false).order(created_at: :desc)\n @activities.each do |act|\n act.read = true;\n act.save\n end\n end",
"def mark_read id\n logged_in?\n post('/api/read_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end",
"def notification_groups_mark_as_read_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_as_read ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling NotificationGroupsApi.notification_groups_mark_as_read\"\n end\n # resource path\n local_var_path = '/notification_groups/{id}/mark_as_read'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\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 header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'NotificationGroupDetail' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_mark_as_read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end",
"def mark_as_unread\n post(\"/api/unread_message\", id: fullname)\n end",
"def set_rights_metadata\n self.edit_groups = ['Chronos-Pligtaflevering']\n self.read_groups = ['Chronos-Alle']\n self.discover_groups = ['Chronos-Alle']\n end",
"def mark_as_unread(options = {})\n update_receipts({ is_read: false }, options)\n end",
"def set_notifications\n\t\t@notifications = Notification.where(reciever_id: current_user).order(\"created_at DESC\")\n\tend",
"def mark_read!\n self.read_at = Time.now\n self.save!\n end",
"def update\n #read or unread\n end",
"def mark_as_unread(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_unread if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_unread(self)\n when Mailboxer::Conversation\n obj.mark_as_unread(self)\n when Array\n obj.map{ |sub_obj| mark_as_unread(sub_obj) }\n end\n end",
"def mark_as_read(participant)\n return unless participant\n self.receipts.recipient(participant).mark_as_read\n end",
"def remove_read_group\n if media_object && media_object.read_groups.include?(self.token)\n media_object.read_groups -= [self.token]\n media_object.save!\n end\n end",
"def reset_permissions_for(item)\n item.edit_groups = []\n item.edit_users = []\n item.read_groups = []\n item.read_users = []\n end",
"def tag_as_read(user)\n self.read = true\n self.save\n self.answers.each do |a|\n a.read = true unless a.user_id.eql? user.id #we don't to tag as read his answers\n a.save\n end\n end",
"def notify_user_acl_modified(user_ids)\n Cache::Album::Manager.shared.user_albums_acl_modified(user_ids)\n end",
"def set_unread_message_count\n self.unread_messages = 1\n end",
"def mark_as_read=(value)\n @mark_as_read = value\n end",
"def index\n\t\t@notifications = Notification.where(recipient_id: current_user.id).unread\n\tend",
"def public_write_was\n writer_group_ids == [UserGroup.all_users.id]\n end",
"def markMail(imap, folder)\n pp \"MARKED #{folder}..\"\n message_ids = imap.uid_search(\"ALL\")\n imap.uid_store(message_ids, \"+FLAGS\", [:Seen])\n imap.expunge\nend",
"def set_unread_state\n self.feed.users.reload.find_each do |user|\n if !EntryState.exists? user_id: user.id, entry_id: self.id\n entry_state = user.entry_states.create! entry_id: self.id, read: false\n end\n end\n end",
"def mark_as_read(participant)\n return unless participant\n receipts_for(participant).mark_as_read\n end",
"def mark_topic_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def mark_as_read(time=Time.now)\n unless read?\n self.recipient_read_at = time\n save!\n end\n end",
"def unread_unsent_notifications_for_group\n @unread_unsent_notifications_for_group ||= unread_unsent_notifications.where('notify_user_notifications.group_id = ?', notification.group_id)\n end",
"def mark_unread id\n logged_in?\n post('/api/unread_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end",
"def unread_messages\n current_user.messages_in.where(read: false).count\n end",
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n\n end",
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self, details)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj, details) }\n end\n\n end",
"def mark_topic_as_unread_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end"
] | [
"0.7631108",
"0.75232005",
"0.7305678",
"0.7271338",
"0.7209958",
"0.71136564",
"0.7043174",
"0.69399095",
"0.68428254",
"0.67394173",
"0.67244416",
"0.6717934",
"0.6698578",
"0.6649359",
"0.66276115",
"0.659942",
"0.6558207",
"0.6492215",
"0.64887977",
"0.6462056",
"0.64539206",
"0.64539206",
"0.6401944",
"0.6373204",
"0.63469636",
"0.63175434",
"0.63127595",
"0.63106525",
"0.63084453",
"0.62789935",
"0.6258232",
"0.6258232",
"0.6224523",
"0.6151769",
"0.6137738",
"0.61224985",
"0.61054647",
"0.60980797",
"0.60851055",
"0.60349005",
"0.6026549",
"0.60180044",
"0.6016407",
"0.60083556",
"0.60059756",
"0.59661615",
"0.59343606",
"0.59184676",
"0.5911188",
"0.5893361",
"0.58604324",
"0.5832743",
"0.5806275",
"0.57914823",
"0.57900816",
"0.57765114",
"0.573398",
"0.56856966",
"0.5680894",
"0.5649523",
"0.5634594",
"0.56229997",
"0.56102335",
"0.5608449",
"0.5589743",
"0.5589743",
"0.5583434",
"0.5564623",
"0.5553702",
"0.5551699",
"0.5535509",
"0.5527922",
"0.5522423",
"0.5506209",
"0.5497933",
"0.5490829",
"0.5485202",
"0.5452777",
"0.5437398",
"0.5428598",
"0.54270166",
"0.5416179",
"0.53893036",
"0.53888786",
"0.538697",
"0.5385525",
"0.53717417",
"0.5356177",
"0.53363764",
"0.5336115",
"0.53328794",
"0.53195024",
"0.5296557",
"0.5288112",
"0.5286896",
"0.5286434",
"0.52796686",
"0.52788",
"0.5278425",
"0.52748257"
] | 0.5988537 | 45 |
Mark a notification group as read Mark a notifications group of the current user as read | def notification_groups_mark_as_read(id, opts = {})
data, _status_code, _headers = notification_groups_mark_as_read_with_http_info(id, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_notifications_as_read!(user)\n self.notifications.where(read: false, user_id: user.id).update_all(read: true)\n end",
"def mark_as_read\n DeterLab.mark_notifications(current_user_id, [ params[:id] ], [ { isSet: true, tag: Notification::READ } ])\n render text: 'ok'\n end",
"def mark_notification_as_read!\n notification = User.find(@userid).notifications\n @received_msg.each do |notify|\n notification.update(notify['id'], :checked => true);\n end\n end",
"def mark_notifications_read\n return if params[:notification_id].blank? or !user_signed_in?\n n = Notification.find(params[:notification_id])\n current_subject.mark_as_read n\n end",
"def mark_notification_as_read(notification_id)\n request(:post, \"/api/notifications/mark_as_read/#{notification_id}/\")\n end",
"def mark_as_read\n self.update(read: true)\n end",
"def mark_read!\n update_is_read_status true\n end",
"def mark_as_read_notification(notification_id)\n post(\"notifications/#{notification_id}/markAsRead\")\n end",
"def mark_as_unread()\n update_attribute('read', false)\n end",
"def mark_as_read\n @notifications = Notification.where(recipient: current_user).unread\n @notifications.update_all(read_at: Time.zone.now)\n render json: {success: true}\n end",
"def mark_as_read\n if Notification.mark_as_read\n return_message(200, :ok)\n else\n return_message(200, :fail)\n end\n end",
"def read user_id\n messages.unread(user_id).each do |m|\n m.read = true\n m.save\n end\n end",
"def mark_unread!\n update_is_read_status false\n end",
"def mark_as_read\n update_attributes(is_read: true)\n end",
"def set_to_read\n\t\t#We find all the messages in the current conversation\n\t\t@conversation_messages = PersonalMessage.where(conversation_id: @conversation).all\n\t\t@conversation_messages.each do |message|\n\t\t\t# We mark as read the messages recieved by the current user \n\t\t\tif message.user_id != current_user.id\n\t\t\t\tmessage.update(read: true) unless message.read != false\n\t\t\tend\n\t\tend\n\tend",
"def mark_notifications_as_read(options = {})\n boolean_from_response :put, 'notifications', options\n end",
"def mark_as_unread\n update_attributes(is_read: false)\n end",
"def mark_as_read\n update_attributes(:is_read => true)\n end",
"def mark_as_read\n update_attributes(:is_read => true)\n end",
"def mark_as_unread\n update_attributes(:is_read => false)\n end",
"def mark_as_unread\n update_attributes(:is_read => false)\n end",
"def mark_all_news_as_read\n where(:user_id => User.current_user_id).update_all(:read => 1)\n end",
"def mark_as_read\n @client.post('/api/mod/conversations/read', conversationIds: [get_attribute(:id)])\n end",
"def mark_as_read()\n update_attribute('read', true)\n end",
"def mark_as_read\n\t\tunread_messages = current_user.received_messages.where(read: false).order('id desc').limit(10)\n\t\tunread_messages.each do |m|\n\t\t\tm.update_attribute(:read, true)\n\t\t\tm.save\n\t\tend\n\t\tredirect_to request.referer\n\tend",
"def mark_as_read\n payload = { \"chat\" => [id] }.to_json\n path = \"/#{api_prefix}/user/#{client.user.id}/rooms/#{room_id}/unreadItems\"\n\n client.post path, payload\n\n true\n end",
"def mark_as_read_by_creator\n mark_as_read! for: creator\n end",
"def mark_as_read(options = {})\n default_options = {}\n add_mailbox_condition!(default_options, @type)\n return update_mail(\"mail_items.read = true\", default_options, options)\n end",
"def mark_all_as_read\n @notifications = Notification.unread.for_user(current_api_v1_user)\n @notifications.update_all(read_at: Time.now) unless @notifications.blank?\n @notifications = Notification.where(recipient_id: current_api_v1_user.id)\n \n render json: @notifications\n end",
"def mark_as_read\n return @mark_as_read\n end",
"def set_read_status\n\t\t\tNotificationReceiver.where(notification_id: params[:id], user_id: current_user.id).update_all(is_read: true)\n\n\t\t\trender json: {\n\t\t\t\tstatus: 0\n\t\t\t}\n\t\tend",
"def mark_as_read=(value)\n @mark_as_read = value\n end",
"def mark_as_read!\n update_attributes(read: true)\n end",
"def mark(person, read)\n mr = MessageReceiver.find(:first, :conditions => [\"person_id = ? AND message_id = ?\", person.id, self.id])\n if mr == nil\n raise \"Attempting to set read status on a message and person that doesn't exist\"\n end\n mr.has_read_bool = read\n mr.save!\n end",
"def mark_all_messages_as_read(options={})\n RecipientsFor::ReaderInfo.where(\n reciveable_type: options[:reciveable].class.name,\n reciveable_id: options[:reciveable].id,\n ).update_all(read: true)\n end",
"def mark_as_read(item)\n receipts_for_item(item).update_all(read: true)\n end",
"def mark_as_read!\n self.read_at = Time.now\n save!\n end",
"def notification_groups_mark_all_as_read(opts = {})\n data, _status_code, _headers = notification_groups_mark_all_as_read_with_http_info(opts)\n data\n end",
"def mark_as_read(participant)\n return unless participant\n self.receipts.recipient(participant).mark_as_read\n end",
"def mark_read id\n logged_in?\n post('/api/read_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end",
"def mark_as_unread\n Notifyer::Notification.all.each do |n|\n n.update(is_read: false)\n end\n redirect_to :back\n end",
"def set_user_read_all(user_id, did_read)\n self.messages.each {|m| m.set_user_read(user_id, did_read)}\n end",
"def mark_as_read(participant)\n return unless participant\n receipts_for(participant).mark_as_read\n end",
"def mark_repo_notifications_as_read(repo, options = {})\n boolean_from_response :put, \"#{Repository.path repo}/notifications\", options\n end",
"def mark_as_read_by_updater\n mark_as_read! for: updater\n end",
"def show\n @message.mark_as_read(current_user)\n end",
"def mark_as_read(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_read if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_read(self)\n when Mailboxer::Conversation\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n end",
"def mark_read!\n self.read_at = Time.now\n self.save!\n end",
"def mark_as_read(participant)\n return if participant.nil?\n receipt_for(participant).mark_as_read\n end",
"def mark_as_read(time=Time.now)\n unless read?\n self.recipient_read_at = time\n save!\n end\n end",
"def mark_as_read(participant)\n return if participant.nil?\n return self.receipts_for(participant).mark_as_read\n end",
"def show\n @notifications = Notification.where(user: current_user).where(notification_obeject_id: params[:id]).where(read: false)\n @notifications.each do |note|\n note.read = true\n note.save\n end\n end",
"def mark_read_messages(conversation)\n time = Time.current\n conversation = Conversation.find(conversation) if conversation.is_a?(Integer)\n conversation_members.where(conversation_id: conversation).update_all(last_seen: time)\n Rails.cache.delete(conversation.get_unread_cache_key_for(id))\n Rails.cache.delete(\"user-unread_messages_count-#{id}\")\n PubSub::Publisher.new.publish_for(conversation.user_participants.where.not(id: id), 'read_messages', {id: conversation.id, seen_at: time.to_i, user_id: id}, {foreground: true})\n end",
"def update\n #read or unread\n end",
"def unread!\n self.update_attribute(:status, UNREAD)\n end",
"def notification_groups_mark_as_read_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_as_read ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling NotificationGroupsApi.notification_groups_mark_as_read\"\n end\n # resource path\n local_var_path = '/notification_groups/{id}/mark_as_read'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\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 header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'NotificationGroupDetail' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_mark_as_read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end",
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n\n end",
"def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end",
"def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end",
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self, details)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj, details) }\n end\n\n end",
"def tag_as_read(user)\n self.read = true\n self.save\n self.answers.each do |a|\n a.read = true unless a.user_id.eql? user.id #we don't to tag as read his answers\n a.save\n end\n end",
"def add_read_group\n return if expired?\n\n unless media_object.read_groups.include?(self.token)\n media_object.read_groups += [self.token]\n media_object.save!\n end\n end",
"def unread\n un_read(false, \"non lue\")\n end",
"def mark_as_unread\n post(\"/api/unread_message\", id: fullname)\n end",
"def reset_unread_notification_count\n post('notifications/markAsRead')\n end",
"def mark_as_unread(options = {})\n update_receipts({ is_read: false }, options)\n end",
"def mark_thread_as_read(thread_id, options = {})\n boolean_from_response :patch, \"notifications/threads/#{thread_id}\", options\n end",
"def read_notifications\n # Update post notification\n post_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Post', @post.id)\n .first\n post_notification.update_attributes(read: true) unless post_notification.nil?\n\n # Update post's messages notifications\n @post.messages.each do |message|\n message_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Message', message.id)\n .first\n message_notification.update_attributes(read: true) unless message_notification.nil?\n end\n end",
"def mark_as_unread\n @client.post('/api/mod/conversations/unread', conversationIds: [get_attribute(:id)])\n end",
"def mark_all_read\r\n @channel.mark_messages_read_for current_user\r\n respond_to do |format|\r\n format.html { redirect_to channel_messages_url(@channel), notice: 'Nachrichten als gelesen markiert.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def mark_unread id\n logged_in?\n post('/api/unread_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end",
"def read\n @activities = PublicActivity::Activity.where(recipient_id: current_user.id, read: false).order(created_at: :desc)\n @activities.each do |act|\n act.read = true;\n act.save\n end\n end",
"def mark_as_read_watchings(user_id)\n post(\"users/#{user_id}/watchings/markAsChecked\")\n end",
"def users_that_can_read_group(users, group)\n DeclarativePolicy.subject_scope do\n users.select { |u| allowed?(u, :read_group, group) }\n end\n end",
"def mark_as_read(safebox_guid)\n handle_error { sendsecure_connection.patch(\"api/v2/safeboxes/#{safebox_guid}/mark_as_read.json\") }\n end",
"def mark_all_entries_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :forced_read_state,\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def unread=(value)\n write_attribute(:unread, value)\n end",
"def unread\n @notifications = Notification.where(user_id: current_user.uid).where(is_read: false).page(params[:page]).order(created_at: :desc)\n end",
"def mark_as_read_watching(watching_id)\n post(\"watchings/#{watching_id}/markAsRead\")\n end",
"def set_read_groups(groups, eligible_groups)\n set_entities(:read, :group, groups, eligible_groups)\n end",
"def mark_topic_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def show\n @message = current_user.messages.find(params[:id])\n @message.mark_as_unread\n end",
"def mark_as_unread(participant)\n return unless participant\n receipts_for(participant).mark_as_unread\n end",
"def read_groups=(groups)\n set_read_groups(groups, read_groups)\n end",
"def mark_entry_as_read_groups(group_id,topic_id,entry_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :forced_read_state,\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n raise \"entry_id is required\" if entry_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id,\n :entry_id => entry_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/entries/{entry_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id,\n :entry_id => entry_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def mark_as_unread(participant)\n return if participant.nil?\n receipt_for(participant).mark_as_unread\n end",
"def set_last_message_read(group, time)\n cookies.permanent[create_last_message_key(current_user, group)] = time\n end",
"def mark_all_posts usr\n return false if usr.blank?\n @conv.posts.each do |post|\n post.mark_as_read! for: usr if post\n end\n end",
"def mark_all_user_notifications_notified(user)\n user.notifications.each do |n|\n n.notified = true\n n.save\n end\n end",
"def load_notifications\n # reload user data\n user = User.find current_user.id\n @notifications = user.notifications.order(\"updated_at DESC\")\n\n new_feeds = user.notification_readers.select {|feed| !feed.isRead?}\n new_feeds.each do |feed|\n feed.read_at = Time.zone.now\n feed.save!\n end\n end",
"def mark_as_unread(participant)\n return unless participant\n self.receipts.recipient(participant).mark_as_unread\n end",
"def unread\n all(UNREAD)\n end",
"def permitted_to_read?(user)\n user.is_admin? || (has_groupblog_permission?(user) || self.user == user || self.group.moderator == user || (self.group.can_user_see_eachother && group.participants.include?(user)))\n end",
"def notification_groups_mark_all_as_read_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_all_as_read ...'\n end\n # resource path\n local_var_path = '/notification_groups/mark_all_as_read'\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 header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Object>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_mark_all_as_read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end",
"def remove_read_group\n if media_object && media_object.read_groups.include?(self.token)\n media_object.read_groups -= [self.token]\n media_object.save!\n end\n end",
"def mark_all_entries_as_unread_groups(group_id,topic_id,opts={})\n query_param_keys = [\n :forced_read_state\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end",
"def mark_all_readed\n doctor.notifications.update_all unreaded: false\n send_json doctor.notifications, true\n end",
"def can_read=(value)\n if value\n set_privileges('r', value)\n else\n self.privileges = nil\n end\n end",
"def may_read_group?(group)\n\t\t\tmay_administrate? || is_group_reader?(group)\n\t\tend",
"def unread\n read_attribute(:unread)\n end"
] | [
"0.7862807",
"0.785672",
"0.77921647",
"0.7673758",
"0.71944684",
"0.7186961",
"0.71617806",
"0.7138312",
"0.7112343",
"0.70780116",
"0.70743436",
"0.70266604",
"0.70162874",
"0.69602764",
"0.695181",
"0.6930366",
"0.6929326",
"0.69209427",
"0.69209427",
"0.6866497",
"0.6866497",
"0.68357176",
"0.68149483",
"0.6763031",
"0.675444",
"0.6750867",
"0.6719726",
"0.6708937",
"0.6589165",
"0.6580399",
"0.6562452",
"0.65570056",
"0.6543537",
"0.65085",
"0.650392",
"0.6503192",
"0.64973336",
"0.64827085",
"0.6480248",
"0.6461653",
"0.6454631",
"0.6417882",
"0.6393227",
"0.6384532",
"0.6379874",
"0.63478917",
"0.6319372",
"0.63130724",
"0.62976927",
"0.6274803",
"0.6234362",
"0.60641146",
"0.6016501",
"0.60060465",
"0.60015196",
"0.5999688",
"0.5993755",
"0.59873885",
"0.59873885",
"0.5975676",
"0.59469134",
"0.592923",
"0.58976996",
"0.58949596",
"0.5892388",
"0.58719504",
"0.5865072",
"0.58522135",
"0.58347684",
"0.58291936",
"0.58047116",
"0.5770662",
"0.576837",
"0.57565",
"0.57377267",
"0.5727378",
"0.5683171",
"0.56675714",
"0.5665061",
"0.56595874",
"0.56554395",
"0.5652543",
"0.5646088",
"0.5634521",
"0.56300765",
"0.56063294",
"0.55938685",
"0.5593394",
"0.5556728",
"0.5543283",
"0.55347925",
"0.5534601",
"0.55295223",
"0.5510726",
"0.5508715",
"0.55004644",
"0.54886115",
"0.54881394",
"0.5485393",
"0.5471999"
] | 0.67752004 | 23 |
Mark a notification group as read Mark a notifications group of the current user as read | def notification_groups_mark_as_read_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_as_read ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling NotificationGroupsApi.notification_groups_mark_as_read"
end
# resource path
local_var_path = '/notification_groups/{id}/mark_as_read'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:body]
# return_type
return_type = opts[:return_type] || 'NotificationGroupDetail'
# auth_names
auth_names = opts[:auth_names] || ['Basic', 'Token']
new_options = opts.merge(
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: NotificationGroupsApi#notification_groups_mark_as_read\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
response = ::Phrase::Response.new(data, headers)
return response, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_notifications_as_read!(user)\n self.notifications.where(read: false, user_id: user.id).update_all(read: true)\n end",
"def mark_as_read\n DeterLab.mark_notifications(current_user_id, [ params[:id] ], [ { isSet: true, tag: Notification::READ } ])\n render text: 'ok'\n end",
"def mark_notification_as_read!\n notification = User.find(@userid).notifications\n @received_msg.each do |notify|\n notification.update(notify['id'], :checked => true);\n end\n end",
"def mark_notifications_read\n return if params[:notification_id].blank? or !user_signed_in?\n n = Notification.find(params[:notification_id])\n current_subject.mark_as_read n\n end",
"def mark_notification_as_read(notification_id)\n request(:post, \"/api/notifications/mark_as_read/#{notification_id}/\")\n end",
"def mark_as_read\n self.update(read: true)\n end",
"def mark_read!\n update_is_read_status true\n end",
"def mark_as_read_notification(notification_id)\n post(\"notifications/#{notification_id}/markAsRead\")\n end",
"def mark_as_unread()\n update_attribute('read', false)\n end",
"def mark_as_read\n @notifications = Notification.where(recipient: current_user).unread\n @notifications.update_all(read_at: Time.zone.now)\n render json: {success: true}\n end",
"def mark_as_read\n if Notification.mark_as_read\n return_message(200, :ok)\n else\n return_message(200, :fail)\n end\n end",
"def read user_id\n messages.unread(user_id).each do |m|\n m.read = true\n m.save\n end\n end",
"def mark_unread!\n update_is_read_status false\n end",
"def mark_as_read\n update_attributes(is_read: true)\n end",
"def set_to_read\n\t\t#We find all the messages in the current conversation\n\t\t@conversation_messages = PersonalMessage.where(conversation_id: @conversation).all\n\t\t@conversation_messages.each do |message|\n\t\t\t# We mark as read the messages recieved by the current user \n\t\t\tif message.user_id != current_user.id\n\t\t\t\tmessage.update(read: true) unless message.read != false\n\t\t\tend\n\t\tend\n\tend",
"def mark_notifications_as_read(options = {})\n boolean_from_response :put, 'notifications', options\n end",
"def mark_as_unread\n update_attributes(is_read: false)\n end",
"def mark_as_read\n update_attributes(:is_read => true)\n end",
"def mark_as_read\n update_attributes(:is_read => true)\n end",
"def mark_as_unread\n update_attributes(:is_read => false)\n end",
"def mark_as_unread\n update_attributes(:is_read => false)\n end",
"def mark_all_news_as_read\n where(:user_id => User.current_user_id).update_all(:read => 1)\n end",
"def mark_as_read\n @client.post('/api/mod/conversations/read', conversationIds: [get_attribute(:id)])\n end",
"def notification_groups_mark_as_read(id, opts = {})\n data, _status_code, _headers = notification_groups_mark_as_read_with_http_info(id, opts)\n data\n end",
"def mark_as_read()\n update_attribute('read', true)\n end",
"def mark_as_read\n\t\tunread_messages = current_user.received_messages.where(read: false).order('id desc').limit(10)\n\t\tunread_messages.each do |m|\n\t\t\tm.update_attribute(:read, true)\n\t\t\tm.save\n\t\tend\n\t\tredirect_to request.referer\n\tend",
"def mark_as_read\n payload = { \"chat\" => [id] }.to_json\n path = \"/#{api_prefix}/user/#{client.user.id}/rooms/#{room_id}/unreadItems\"\n\n client.post path, payload\n\n true\n end",
"def mark_as_read_by_creator\n mark_as_read! for: creator\n end",
"def mark_as_read(options = {})\n default_options = {}\n add_mailbox_condition!(default_options, @type)\n return update_mail(\"mail_items.read = true\", default_options, options)\n end",
"def mark_all_as_read\n @notifications = Notification.unread.for_user(current_api_v1_user)\n @notifications.update_all(read_at: Time.now) unless @notifications.blank?\n @notifications = Notification.where(recipient_id: current_api_v1_user.id)\n \n render json: @notifications\n end",
"def mark_as_read\n return @mark_as_read\n end",
"def set_read_status\n\t\t\tNotificationReceiver.where(notification_id: params[:id], user_id: current_user.id).update_all(is_read: true)\n\n\t\t\trender json: {\n\t\t\t\tstatus: 0\n\t\t\t}\n\t\tend",
"def mark_as_read=(value)\n @mark_as_read = value\n end",
"def mark_as_read!\n update_attributes(read: true)\n end",
"def mark(person, read)\n mr = MessageReceiver.find(:first, :conditions => [\"person_id = ? AND message_id = ?\", person.id, self.id])\n if mr == nil\n raise \"Attempting to set read status on a message and person that doesn't exist\"\n end\n mr.has_read_bool = read\n mr.save!\n end",
"def mark_all_messages_as_read(options={})\n RecipientsFor::ReaderInfo.where(\n reciveable_type: options[:reciveable].class.name,\n reciveable_id: options[:reciveable].id,\n ).update_all(read: true)\n end",
"def mark_as_read(item)\n receipts_for_item(item).update_all(read: true)\n end",
"def mark_as_read!\n self.read_at = Time.now\n save!\n end",
"def notification_groups_mark_all_as_read(opts = {})\n data, _status_code, _headers = notification_groups_mark_all_as_read_with_http_info(opts)\n data\n end",
"def mark_as_read(participant)\n return unless participant\n self.receipts.recipient(participant).mark_as_read\n end",
"def mark_read id\n logged_in?\n post('/api/read_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end",
"def mark_as_unread\n Notifyer::Notification.all.each do |n|\n n.update(is_read: false)\n end\n redirect_to :back\n end",
"def set_user_read_all(user_id, did_read)\n self.messages.each {|m| m.set_user_read(user_id, did_read)}\n end",
"def mark_as_read(participant)\n return unless participant\n receipts_for(participant).mark_as_read\n end",
"def mark_repo_notifications_as_read(repo, options = {})\n boolean_from_response :put, \"#{Repository.path repo}/notifications\", options\n end",
"def mark_as_read_by_updater\n mark_as_read! for: updater\n end",
"def show\n @message.mark_as_read(current_user)\n end",
"def mark_as_read(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_read if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_read(self)\n when Mailboxer::Conversation\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n end",
"def mark_read!\n self.read_at = Time.now\n self.save!\n end",
"def mark_as_read(participant)\n return if participant.nil?\n receipt_for(participant).mark_as_read\n end",
"def mark_as_read(time=Time.now)\n unless read?\n self.recipient_read_at = time\n save!\n end\n end",
"def mark_as_read(participant)\n return if participant.nil?\n return self.receipts_for(participant).mark_as_read\n end",
"def show\n @notifications = Notification.where(user: current_user).where(notification_obeject_id: params[:id]).where(read: false)\n @notifications.each do |note|\n note.read = true\n note.save\n end\n end",
"def mark_read_messages(conversation)\n time = Time.current\n conversation = Conversation.find(conversation) if conversation.is_a?(Integer)\n conversation_members.where(conversation_id: conversation).update_all(last_seen: time)\n Rails.cache.delete(conversation.get_unread_cache_key_for(id))\n Rails.cache.delete(\"user-unread_messages_count-#{id}\")\n PubSub::Publisher.new.publish_for(conversation.user_participants.where.not(id: id), 'read_messages', {id: conversation.id, seen_at: time.to_i, user_id: id}, {foreground: true})\n end",
"def update\n #read or unread\n end",
"def unread!\n self.update_attribute(:status, UNREAD)\n end",
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n\n end",
"def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end",
"def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end",
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self, details)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj, details) }\n end\n\n end",
"def tag_as_read(user)\n self.read = true\n self.save\n self.answers.each do |a|\n a.read = true unless a.user_id.eql? user.id #we don't to tag as read his answers\n a.save\n end\n end",
"def add_read_group\n return if expired?\n\n unless media_object.read_groups.include?(self.token)\n media_object.read_groups += [self.token]\n media_object.save!\n end\n end",
"def unread\n un_read(false, \"non lue\")\n end",
"def mark_as_unread\n post(\"/api/unread_message\", id: fullname)\n end",
"def reset_unread_notification_count\n post('notifications/markAsRead')\n end",
"def mark_as_unread(options = {})\n update_receipts({ is_read: false }, options)\n end",
"def mark_thread_as_read(thread_id, options = {})\n boolean_from_response :patch, \"notifications/threads/#{thread_id}\", options\n end",
"def read_notifications\n # Update post notification\n post_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Post', @post.id)\n .first\n post_notification.update_attributes(read: true) unless post_notification.nil?\n\n # Update post's messages notifications\n @post.messages.each do |message|\n message_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Message', message.id)\n .first\n message_notification.update_attributes(read: true) unless message_notification.nil?\n end\n end",
"def mark_as_unread\n @client.post('/api/mod/conversations/unread', conversationIds: [get_attribute(:id)])\n end",
"def mark_all_read\r\n @channel.mark_messages_read_for current_user\r\n respond_to do |format|\r\n format.html { redirect_to channel_messages_url(@channel), notice: 'Nachrichten als gelesen markiert.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def mark_unread id\n logged_in?\n post('/api/unread_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end",
"def read\n @activities = PublicActivity::Activity.where(recipient_id: current_user.id, read: false).order(created_at: :desc)\n @activities.each do |act|\n act.read = true;\n act.save\n end\n end",
"def mark_as_read_watchings(user_id)\n post(\"users/#{user_id}/watchings/markAsChecked\")\n end",
"def users_that_can_read_group(users, group)\n DeclarativePolicy.subject_scope do\n users.select { |u| allowed?(u, :read_group, group) }\n end\n end",
"def mark_as_read(safebox_guid)\n handle_error { sendsecure_connection.patch(\"api/v2/safeboxes/#{safebox_guid}/mark_as_read.json\") }\n end",
"def mark_all_entries_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :forced_read_state,\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def unread=(value)\n write_attribute(:unread, value)\n end",
"def unread\n @notifications = Notification.where(user_id: current_user.uid).where(is_read: false).page(params[:page]).order(created_at: :desc)\n end",
"def mark_as_read_watching(watching_id)\n post(\"watchings/#{watching_id}/markAsRead\")\n end",
"def set_read_groups(groups, eligible_groups)\n set_entities(:read, :group, groups, eligible_groups)\n end",
"def mark_topic_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def show\n @message = current_user.messages.find(params[:id])\n @message.mark_as_unread\n end",
"def mark_as_unread(participant)\n return unless participant\n receipts_for(participant).mark_as_unread\n end",
"def read_groups=(groups)\n set_read_groups(groups, read_groups)\n end",
"def mark_entry_as_read_groups(group_id,topic_id,entry_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :forced_read_state,\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n raise \"entry_id is required\" if entry_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id,\n :entry_id => entry_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/entries/{entry_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id,\n :entry_id => entry_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end",
"def mark_as_unread(participant)\n return if participant.nil?\n receipt_for(participant).mark_as_unread\n end",
"def set_last_message_read(group, time)\n cookies.permanent[create_last_message_key(current_user, group)] = time\n end",
"def mark_all_posts usr\n return false if usr.blank?\n @conv.posts.each do |post|\n post.mark_as_read! for: usr if post\n end\n end",
"def mark_all_user_notifications_notified(user)\n user.notifications.each do |n|\n n.notified = true\n n.save\n end\n end",
"def load_notifications\n # reload user data\n user = User.find current_user.id\n @notifications = user.notifications.order(\"updated_at DESC\")\n\n new_feeds = user.notification_readers.select {|feed| !feed.isRead?}\n new_feeds.each do |feed|\n feed.read_at = Time.zone.now\n feed.save!\n end\n end",
"def mark_as_unread(participant)\n return unless participant\n self.receipts.recipient(participant).mark_as_unread\n end",
"def unread\n all(UNREAD)\n end",
"def permitted_to_read?(user)\n user.is_admin? || (has_groupblog_permission?(user) || self.user == user || self.group.moderator == user || (self.group.can_user_see_eachother && group.participants.include?(user)))\n end",
"def notification_groups_mark_all_as_read_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_all_as_read ...'\n end\n # resource path\n local_var_path = '/notification_groups/mark_all_as_read'\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 header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Object>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_mark_all_as_read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end",
"def remove_read_group\n if media_object && media_object.read_groups.include?(self.token)\n media_object.read_groups -= [self.token]\n media_object.save!\n end\n end",
"def mark_all_entries_as_unread_groups(group_id,topic_id,opts={})\n query_param_keys = [\n :forced_read_state\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end",
"def mark_all_readed\n doctor.notifications.update_all unreaded: false\n send_json doctor.notifications, true\n end",
"def can_read=(value)\n if value\n set_privileges('r', value)\n else\n self.privileges = nil\n end\n end",
"def may_read_group?(group)\n\t\t\tmay_administrate? || is_group_reader?(group)\n\t\tend",
"def unread\n read_attribute(:unread)\n end"
] | [
"0.7862807",
"0.785672",
"0.77921647",
"0.7673758",
"0.71944684",
"0.7186961",
"0.71617806",
"0.7138312",
"0.7112343",
"0.70780116",
"0.70743436",
"0.70266604",
"0.70162874",
"0.69602764",
"0.695181",
"0.6930366",
"0.6929326",
"0.69209427",
"0.69209427",
"0.6866497",
"0.6866497",
"0.68357176",
"0.68149483",
"0.67752004",
"0.6763031",
"0.675444",
"0.6750867",
"0.6719726",
"0.6708937",
"0.6589165",
"0.6580399",
"0.6562452",
"0.65570056",
"0.6543537",
"0.65085",
"0.650392",
"0.6503192",
"0.64973336",
"0.64827085",
"0.6480248",
"0.6461653",
"0.6454631",
"0.6417882",
"0.6393227",
"0.6384532",
"0.6379874",
"0.63478917",
"0.6319372",
"0.63130724",
"0.62976927",
"0.6274803",
"0.6234362",
"0.60641146",
"0.6016501",
"0.60060465",
"0.60015196",
"0.5993755",
"0.59873885",
"0.59873885",
"0.5975676",
"0.59469134",
"0.592923",
"0.58976996",
"0.58949596",
"0.5892388",
"0.58719504",
"0.5865072",
"0.58522135",
"0.58347684",
"0.58291936",
"0.58047116",
"0.5770662",
"0.576837",
"0.57565",
"0.57377267",
"0.5727378",
"0.5683171",
"0.56675714",
"0.5665061",
"0.56595874",
"0.56554395",
"0.5652543",
"0.5646088",
"0.5634521",
"0.56300765",
"0.56063294",
"0.55938685",
"0.5593394",
"0.5556728",
"0.5543283",
"0.55347925",
"0.5534601",
"0.55295223",
"0.5510726",
"0.5508715",
"0.55004644",
"0.54886115",
"0.54881394",
"0.5485393",
"0.5471999"
] | 0.5999688 | 56 |
mail the user after signing up | def after_request_activation(user, transition)
UserMailer.deliver_activation_request(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_up(user)\n @user = user\n\n mail to: user.email\n end",
"def signed_up(user)\n @user = user\n mail to: @user.email\n end",
"def signed_up(user)\n @user = user\n \n mail to: @user.email, subject: 'Sign Up Confirmation.'\n end",
"def signup(new_user)\n mail(to: new_user.email, subject: \"Congratulations on Signing up!\")\n end",
"def signup(user_that_just_signed_up)\n mail to: user_that_just_signed_up.email,\n subject: \"You signed up for YardSale\"\n end",
"def signup_email(user)\n mail(\n to: \"[email protected]\",\n subject: 'Thanks for signing up'\n )\n end",
"def send_signup_email()\n\n\t# @user = user\n\tmail( :to => '[email protected]',\n\t\t :subject => '!Thanks for signing up')\n \nend",
"def signup_email(user)\n mail( :to => user.email, :subject => \"Thanks for signing up for Sublets at Penn!\" )\n end",
"def signup_email(user)\n mail( :to => user.email, :subject => \"Thanks for signing up\" )\n end",
"def signup_successful(user)\n @user = user\n mail to: \"#{user.full_name} <#{user.email}>\"\n end",
"def signup_email(user)\n mail( :to => user.email,\n :subject => 'Thanks for signing up' )\n end",
"def signup_email(user)\n mail( :to => user.email, :subject => \"Thanks for signing up!\" )\n end",
"def user_sign_up_notification(user)\n @user = user\n\n mail(to: \"<#{user.email}>\", subject: \"Success! You did it.\")\n end",
"def signup_email(user)\n @user = user\n mail(to: @user.email, subject: 'Thanks for signing up for our amazing app')\n end",
"def signup\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def new_signup(user, email)\n @greeting = \"Hi\"\n @user = user\n @email = email\n mail to: @email, subject: \"Your Account has been created on blogApp\"\n end",
"def signup_confirmation(user)\n @user= user\n debugger\n mail to: @user.email , subject: \"MovieBox Sign Up Confirmation\"\n \n end",
"def signup_email(user)\n @user = user\n mail to: @user.email, subject: 'Welcome to Open Door'\n end",
"def registration_succeed(user)\n @user = user\n\n mail to: user.email, :subject => 'Welcome to Real Thematics'\n end",
"def sign_up_notification\n # @greeting = \"Hi\"\n\n # mail to: \"[email protected]\"\n # @admin = User.where(is_admin: true).last\n @user = params[:user]\n mail(to: @user.email, subject: 'Sign Up successfull')\n end",
"def signup(email)\n \n @greeting = \"Hi\"\n\n mail to: email\n end",
"def signup_confirmation user\n @user = user\n mail to: user.email, subject: \"Welcome to the Clone\"\n end",
"def send_signup_email(doctor,passwrd)\n @user = doctor\n @pas = passwrd\n mail( :to => @user,\n :subject => 'signing up for our amazing app ' )\n end",
"def signup\n @greeting = \"Hi\"\n\n mail :to => \"[email protected]\"\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up with Linchpin' )\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => '[email protected]',\n :subject => 'Thanks for signing up for our amazing app' )\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to EY Time' )\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to EY Time' )\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up for Lend.io' )\n end",
"def send_signup_email(user)\n @user = user\n mail(to: @user.email, subject: 'Thanks for signing up!')\n end",
"def send_signup_email(user)\n @user = user\n mail(:from => self.moovi_email, :to => @user.email,:subject => 'Thanks for signing up to Moovi' )\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up to SCUDERIA.COM!' )\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thanks for signing up for our amazing app' )\n end",
"def send_signup_email(user)\n @user = user\n mail( to: @user.email,\n subject: 'Thanks for signing up for our amazing app' )\n end",
"def finish_signup_later(user)\n @user = user\n mail to: \"#{user.full_name} <#{user.email}>\"\n end",
"def welcome_signup_email(signup)\n @signup = signup\n mail(\n :subject => \"We will be coming to your school soon!\",\n :from => \"[email protected]\",\n :to => @signup.email\n )\n end",
"def send_signup_email(user)\n\t @user = user\n\t mail( :to => @user.email,\n\t :subject => 'New Ticket' )\n\t end",
"def notify_about_sign_up(user, admin)\n @user = user\n mail(:to => admin.email, :subject => \"New User | #{user.name}\", :reply_to => \"[email protected]\")\n end",
"def signup_confirmation(user_name, user_email)\n @user_name = user_name\n @user_email = user_email\n mail to: user_email, subject: \"Dum dum de dum... get started with Bridled!\"\n end",
"def send_signup_notification\n deliver_activation_email(:signup, :subject => (MaSA[:activation_subject] || \"Please Activate Your Account\") )\n end",
"def signup_activation(user)\n @user = user\n @url = 'http://localhost:3000/login'\n mail to: @user.email, subject: \"Match Point validate email\"\n end",
"def register(user) \n @user = user \n mail(:to => user.email, :subject => \"Welcome to the site\") \n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Muchas gracias por haberte registrado a Juego de Teorías!' )\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email ,\n :subject => '[Todo Manager] Welcome!' )\n end",
"def signup_confirmation(user)\n @user = user\n mail to: user.email, subject: \"Welcome\"\n end",
"def signup_email(user)\n @user = user\n @url = 'http://localhost:3000/signup'\n mail( :to => @user.email,\n :subject => 'Thanks for signing up for piazza!' )\n end",
"def send_signup_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Welcome To WeHaul' )\n end",
"def signup_email\n @greeting = \"Hi\"\n\n mail to: @user.email, subject: \"Welcome to CheeseBae! Please confim your email!\"\n end",
"def send_signup_email(user)\n @user = user\n mail( to: @user.email,\n subject: \"Thanks for signing up, #{@user.email}!\")\n end",
"def registration_confirmation(user)\n @account = user\n mail(:to => named_email(user), :subject => \"Outcircle - Welcome\")\n end",
"def signup \n @user = params[:user]\n @link = params[:link]\n Merb.logger.info \"Sending Signup to #{@user.email} with code #{@user.activation_code}\"\n render_mail :text => :signup, :layout => :core\n end",
"def send_signup_email(user)\n @user = user\n mail(\n to: @user.email,\n subject: 'Thanks for signing up for our amazing app'\n )\n end",
"def send_signup_email(@user)\n @user= user\n mail( :to @user.email,\n subject: 'Thanks for signing up for our amazing app',\n\t:from => '[email protected]'\n )\n end",
"def signup(email)\n @email = email\n \n mail :to => \"[email protected]\", :cc => KMCD_EMAIL, \n :subject => \"New signup for RailsDojo.com\"\n end",
"def signup_confirmation(user)\n @greeting = \"Hi\"\n @user = user\n\n mail to: user.email, subject: \"Sign up confirmation!\"\n end",
"def after_confirmation # Send welcome mail after user is successfully registered\n send_user_mail\n end",
"def signup_confirmation(user)\n @user = user\n\n mail to: user.email, subject: \"Sign Up Confirmation\"\n end",
"def signup_confirmation(user)\n @user = user\n mail to: user.email, subject: \"Signup confirmation from FreeLance\"\n end",
"def signup_notification(user)\n setup_email(user)\n @subject += I18n.t 'mailer.signup.subject'\n \n @body[:url] = \"http://www.dripplet.com/#{user.locale}/activate/#{user.activation_code}\"\n \n end",
"def signup_email\n MnoEnterprise::SystemNotificationMailer.registration_instructions(params.require(:user).require(:email)).deliver_later\n\n head :no_content\n end",
"def signup_confirmation(user, root_url)\n @user = user\n @url = root_url + 'login'\n mail(to: user.username, subject: 'Sign Up Confirmation')\n end",
"def send_signup_verify_email(email, user)\n @user = user\n mail( :to => email,\n :subject => 'Welcome to WatchIoT!!')\n end",
"def Registered(user)\n @user = user\n @greeting = \"Hi\"\n \n mail to: @user.email, subject: 'upartner会員登録完了'\n end",
"def sign_up(user)\n headers(:content_type => \"text/html\", :charset => \"UTF-8\")\n @user = user\n mail(to: user.email, subject: 'Credenciales del Usuario')\n end",
"def registration(user)\n @user = user\n\n mail to: @user.email_id, subject: \"Successful Registration\"\n end",
"def signup_successful\n user = User.first\n UserMailer.signup_successful(user)\n end",
"def send_signup_email(user)\n @user = user\n mail(to: @user.email, subject: \"Welcome to blah blah blah #{@user.first_name}\")\n end",
"def employee_signup_email(employee)\n @employee = employee\n mail( :to => @employee.email,\n :subject => 'Thanks for signing up for Shiift' )\n end",
"def signup_confirmation(user)\n @user = user\n mail to: user.email, subject: \"Sign Up Confirmation\"\n end",
"def send_signup_email\n mail( :to => '[email protected]',\n :subject => 'Thanks for signing up for our amazing app' ).deliver\n end",
"def registered(user)\n mail_to user, registered_subject\n end",
"def sign_up(new_user)\n @user = new_user\n @notify_subject = strip_tags \"NEW SIGN UP AT #{ENV['APPLICATION_CONFIG_name']}\"\n mail( :to => ENV['APPLICATION_CONFIG_admin_notification_address'], :subject => @notify_subject)\n end",
"def signup_notification(user)\n\t\tsetup_email(user)\n\t\t subject self.site_name+\" : \"+I18n.t('mailer.signup_notification.subject')\n\t\t body :url => self.daurl+\"/admin/activate/#{user.activation_code}\",\n\t\t\t:site => self.site_name,\n\t\t\t:user_login => user.login,\n\t\t\t:user_password => user.password\n end",
"def newsignup(email)\n @greeting = \"Hi\"\n @email = email['email']\n mail(to: @email, subject: \"You've signed up\")\n end",
"def signup_confirmation_advisee(user)\n @user = user\n mail to: @user.email, subject: \"Advisee new registration\"\n end",
"def welcome(user)\n @the_new_user_who_signed_up = user\n\n mail to: user.email, from: \"[email protected]\"\n end",
"def do_signup\n hobo_do_signup do\n if this.errors.blank?\n #flash[:notice] << \"You must activate your account before you can log in. Please check your email.\"\n flash[:notice] << \" Your account has been created.\"\n\n # FIXME: remove these two lines after you get email working reliably\n # and before your application leaves its sandbox...\n #secret_path = user_activate_path :id=>this.id, :key => this.lifecycle.key\n #flash[:notice] << \"The 'secret' link that was just emailed was: <a id='activation-link' href='#{secret_path}'>#{secret_path}</a>.\"\n else\n flash[:notice] = @this.errors.full_messages.join(\"<br/>\")\n logger.info \"error is \" + flash[:notice]\n end\n\n end\n end",
"def registration_confirmation(user)\n @user = user\n\n mail to: \"[email protected]\", subject: \"Success! You did it.\"\n end",
"def created(user)\n @user=user\n\n\n mail to: \"[email protected]\"\n end",
"def registration\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def registration_confirmation(user)\n \t@user = user\n \tmail(:to => \"#{user.name} #{user.last_name} <#{user.email}>\", :subject => \"(IMI-Map) Registered\")\n end",
"def admin_create_user_email(user)\n @user = user\n mail :to => \"#{user.name} <#{user.email}>\", :subject => \"An Account Has Been Created For You\"\n end",
"def signup_greeting(user, mode = :normal_signup)\n @user = user\n @need_password = (mode == :free_money_signup)\n swapidy_sendmail :to => @user.email, :subject => \"Welcome to Swapidy\"\n end",
"def send_signup_email(admin)\n @admin = admin\n mail( :to => @admin.email,:subject => 'Thanks for signing up ,you are welcome' )\n end",
"def new_user(user) \n @user = user\n if Rails.env.production?\n \tmail to: \"[email protected]\", subject: \"New User Signup!\"\n else\n \tmail to: \"[email protected]\", subject: \"(DEV) New User Signup!\"\n\t\tend\n end",
"def signup_confirmation(user)\n @user = user\n @greeting = \"Hi\"\n\n mail to: @user.email, subject: \"Hello new friend!\"\n end",
"def welcome_email(user)\n @user = user\n mail( to: user.email,\n subject: 'Thanks for signing up for Shiftable!',\n sent_on: Time.now )\n end",
"def new_account(user)\n @user = user\n @user_name = @user.full_name\n @user_email = @user.email\n\n mail(to: @user.email, subject: 'Welcome to the jungle')\n end",
"def new_user_signed_up _user, _request\n @user = _user\n @request_info = build_request_info(_request)\n @domain = Settings.fetch(:app,:hostname)\n mail(\n to: Settings.fetch(:app,:admin_notification_email),\n subject: \"New user created at #{@domain}\"\n )\n end",
"def send_signup_email(taxpayer)\n @taxpayer = taxpayer\n mail( :to => @taxpayer.email,\n :subject => 'Thanks for signing up for our amazing app' )\n end",
"def registration_confirmation(user)\n @user = user\n mail(to: \"#{user.name} #{user.last_name} <#{user.email}>\",\n subject: '(IMI-Map) Registered')\n end",
"def paid_signup(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Paid Signup Email')\n @user = user\n mail to: user.email, subject: \"You've Upgraded to our Business Pro plan!\"\n end",
"def transaction_created(user)\n @user = user\n mail to: user.email, subject: \"Sign Up Confirmation\"\n end",
"def welcome(user)\n\t\t@user = user\n\t\t@url = 'http://soul-space.heroku.com/sign-up'\n\t\tmail(to: @user.email, subject: 'Welcome to Soul Space: Sign-up Confirmation')\n\tend",
"def activation_success_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def sign_up_mail(user_id,school_id)\n # @greeting = \"Hi\"\n\n # mail to: \"[email protected]\"\n\n\n @user = HMMC.db.get_user(user_id)\n @school = HMMC.db.get_school(school_id)\n\n mail(\n from: \"[email protected]\",\n to: @user.email,\n subject: \"Thank you for registering with the Hundread millionaire mile club\"\n )\n end",
"def signup_confirmation(user_id)\n # Will make the newly registered user available to the view that will generate the email content\n @user = User.find(user_id)\n\n mail to: @user.email, subject: \"Sign up confirmation\"\n end",
"def new_email(user)\n @user = user\n \n mail to: @user.email, subject: \"Create your ParDIY credentials\"\n end",
"def send_signup_email(user)\n\t\tuser = user\n subject = \"Thank you for sign up on miniflix.\"\n merge_vars = {\n \"USER_NAME\" => user.name\n }\n body = mandrill_template(\"Paid-user-signup-mail\", merge_vars)\n\n send_mail(user.email, subject, body)\n\tend",
"def registration_confirmation(user) \n @user=user\n mail(:to => user.email, :subject => \"[给力百货]注册邮箱验证\")\n end",
"def registration_confirmation(user)\n @user = user\n mail :to => \"#{user.name} <#{user.email}>\", :subject => \"Thanks for Registering\"\n end"
] | [
"0.8328465",
"0.8240757",
"0.8168592",
"0.8064086",
"0.80555254",
"0.8003733",
"0.7993122",
"0.7984771",
"0.79757863",
"0.79600984",
"0.7957878",
"0.79577404",
"0.79267603",
"0.78966814",
"0.7887288",
"0.7880466",
"0.78695846",
"0.78671706",
"0.78385407",
"0.7788349",
"0.7788186",
"0.7761782",
"0.7759866",
"0.77529824",
"0.7738032",
"0.77013296",
"0.76888466",
"0.76888466",
"0.76808125",
"0.7673773",
"0.766506",
"0.7648037",
"0.76406956",
"0.76359963",
"0.7635309",
"0.7626261",
"0.76230377",
"0.7613559",
"0.76051396",
"0.7601337",
"0.75994736",
"0.75968915",
"0.7596883",
"0.75886637",
"0.758803",
"0.7585821",
"0.75786716",
"0.7572822",
"0.75582165",
"0.7552314",
"0.7548004",
"0.7545876",
"0.7545305",
"0.75355554",
"0.7535041",
"0.7534062",
"0.7518184",
"0.75102365",
"0.75090325",
"0.75035",
"0.7497974",
"0.7497798",
"0.7489677",
"0.7488219",
"0.7482892",
"0.7479014",
"0.7473885",
"0.74738157",
"0.74734294",
"0.7460833",
"0.74537826",
"0.7452848",
"0.74362725",
"0.74342114",
"0.7409225",
"0.7408606",
"0.7398509",
"0.73945886",
"0.7392229",
"0.73792756",
"0.7370777",
"0.7358543",
"0.735066",
"0.7346891",
"0.73450136",
"0.73383456",
"0.7323991",
"0.7313957",
"0.7313026",
"0.7312157",
"0.730847",
"0.7288649",
"0.728328",
"0.72774553",
"0.7277324",
"0.7275249",
"0.7275092",
"0.7266583",
"0.72634125",
"0.726023",
"0.7250779"
] | 0.0 | -1 |
mail the user to confirm activation | def after_activate(user, transition)
UserMailer.deliver_activation_confirmation(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activation_confirmation(user)\n @root_url = root_url\n mail(:subject => setup_subject(I18n.t('activation_complete')),\n :to => user.email)\n end",
"def activation_needed_email(user)\n @user = user\n @url = users_activate_path(id: user.activation_token)\n mail(to: user.email, subject: \"#{User.model_name.human}登録を完了しましょう!\")\n end",
"def account_activation(user)\n @user=user\n\n mail :to => @user.email, :from => \"[email protected]\", :subject => \"Account activation\"\n end",
"def send_activation_email\n ensure_activation_token_set\n UserMailer.account_activation(self, activation_token).deliver_later unless activated?\n end",
"def activation_success_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def activation_confirmation(user)\n user_login_link(user)\n\n @greeting = \"Thank you for choosing Contractor\"\n @name = user.name\n\n mail to: user.email\n end",
"def activation_needed_email(user)\n @user = user\n @account_activation_url = activate_user_url(user.activation_token)\n mail to: user.email, subject: \"ACTION NEEDED: Activate your VCDelta.org account\"\n end",
"def activation_success_email(user)\n @user = user\n @subject = \"[#{SITE_NAME}] Account activated\"\n mail(bcc: @user.email, subject: @subject)\n end",
"def send_activation_notification\n deliver_activation_email(:activation, :subject => (MaSA[:welcome_subject] || \"Welcome\" ))\n end",
"def send_activation_or_reset_mail\n end",
"def email_activation_confirmation(email)\n setup_email(email.user, email.address)\n @subject += 'A new email address has been activated'\n @body[:url] = \"#{SITE_URL}/\"\n end",
"def send_activation_email\n\t\tUserMailer.account_activation(self).deliver_now\n\tend",
"def activation_success_email(vendor)\n @vendor = vendor\n @url = \"http://127.0.0.1:3000/login\"\n mail(:to => vendor.email,\n :subject => \"Baitalhikma.co.jp - Your account is now activated\")\n end",
"def account_activation(user)\n @user = user\n\n mail to: user.email, subject: \"Account activation\"\n end",
"def admin_account_activation(member)\r\n @member = member\r\n mail(to: member.user_name, subject: \"Admin Account Activation\") \r\n end",
"def activation(user)\n setup_email(user)\n @subject += 'Your account has been activated!'\n @body[:url] = \"http://#{AppConfig.app_url}/\"\n end",
"def activation(user, email)\n setup_email(user, email)\n @subject += 'Your account has been activated!'\n @body[:url] = \"#{SITE_URL}/\"\n end",
"def account_activation(member) \r\n @member = member \r\n mail(to: member.user_name, subject: \"Account Activation\") \r\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n\t\tUserMailer.user_activation(self).deliver_now\n\tend",
"def send_activation\n if email_changed? and enable_mailer\n activated = false\n UserMailer.welcome_email(self, host).deliver\n end\n end",
"def send_activation_email\n UserMailer.account_activation(self, activation_token).deliver_later\n end",
"def activation\n StudentMailer.activation\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver\n end",
"def activation_success_email\n UserMailerMailer.activation_success_email\n end",
"def activation_success_email(user)\n @user = user\n @url = \"http://lvh.me:3000/login\"\n mail(:to => user.email,\n :subject => \"Your account at Stackclown is now activated\")\n end",
"def account_activation(user)\n @user = user\n mail to: user.email, subject: \"Account activation\"\n end",
"def account_activation(user)\n @user = user\n mail to: user.email, subject: \"Account activation\"\n end",
"def activation\n @greeting = \"Hi\"\n\n mail :to => \"[email protected]\"\n end",
"def activation_needed_email(user)\n @user = user\n @activation_url = activate_url(token: user.activation_token)\n mail to: user.email\n end",
"def send_activation_email\n DoctorMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n @user = User.find(params[:id])\n\n if @user.activated?\n flash[:fail] = \"Account already activated\"\n\n else\n begin\n @user.reset_activation_token!\n UserMailer.activation_email(@user).deliver!\n\n flash[:success] = \"Activation email sent\"\n rescue StandardError => e\n flash[:errors] = [\"Unable to send activation email\", e.message]\n end\n end\n\n if params[:flash]\n flash[:success] = params[:flash] + \". \" + flash[:success]\n end\n\n redirect_to user_url(@user)\n end",
"def activation_needed_email(user)\n @user = user\n @url = \"http://lvh.me:3000/users/#{user.activation_token}/activate\"\n mail(:to => user.email,\n :subject => \"Welcome to StackClown\")\n end",
"def email_activation(email)\n setup_email(email.user, email.address)\n @subject += 'Please verify your email address'\n @body[:url] = \"#{SITE_URL}/activate/#{email.activation_code}\"\n end",
"def activation_success_email(user)\n @user = user\n @url = \"#{get_domain}/login\"\n mail(to: user.email, subject: 'メールアドレスの認証が完了しました!')\n end",
"def activation_success_email(user)\n @user = user\n #@url = \"http://0.0.0.0:3000/login\"\n @url = \"http://kancrumer.herokuapp.com/login\"\n mail(:to => user.email, :subject => \"Your account is now activated\")\n end",
"def send_signup_notification\n deliver_activation_email(:signup, :subject => (MaSA[:activation_subject] || \"Please Activate Your Account\") )\n end",
"def activation_needed_email(user)\n @user = user\n @url = \"http://0.0.0.0:3000/users/#{user.activation_token}/activate\"\n\n mail to: @user.email, subject: \"[적어적어]마! 이메일 인증해라\"\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n save\n\n # send mail for activation\n UserMailer.dispatch_and_deliver( :activation_notification,\n { :from => User::EMAIL_FROM,\n :to => self.email,\n :subject => User::ACTIVATE_MAIL_SUBJECT },\n\n :user => self )\n\n end",
"def activation_needed_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def email_activation\n @user = Student.first\n @user.create_email_activation\n @email = '[email protected]'\n @option = 'student'\n UserMailer.email_activation @user, @email, @option\n end",
"def account_activation(user)\n @user = user\n mail to: user.email # => mail object\n # => app/views/user_mailer/account_activation.text.erb\n # => app/views/user_mailer/account_activation.html.erb \n # https://hogehoge.com/account_activations/:id/edit\n # :id <= @user.activation_token\n end",
"def activation_success_email\n UserMailer.activation_success_email(User.first)\n end",
"def send_account_notification\n @user = User.find_by_id(params[:id]) \n begin \n url = \"http://www.uncharted.net/account/activation/#{@user.activation_code}\" \n Emailer.deliver_admin_accountactivation(@user.email,url)\t\n end\n flash[:notice] = \"Email has been sent to #{@user.email} to active his account.\"\n redirect_to :action => 'index'\n end",
"def resend_activation\n current_user.send_activation!\n\n flash[:notice] = \"Activation email delivered successfully.\"\n redirect_to user_url\n end",
"def account_activation(user)\n @user = user\n mail to: user.email, subject: \"CRS Account Activation\"\n end",
"def account_activation(subscriber)\n @greeting = \"Hi\"\n @subscriber = subscriber\n\n mail to: subscriber.email, subject: \"Confirm subscription\"\n end",
"def account_activation(user)\n @user = user\n mail to: \"#{user.full_name} <#{user.email}>\"\n end",
"def activation_success_email user, application_id\n @user = User.find user\n @application = @user.used_applications.find application_id\n @url = application_url(@application)\n mail(:to => @user.email,\n :subject => \"You have been added to #{@application.application_name}\")\n end",
"def send_activation_email\n @admin = BusinessAdmin.find(params[:id])\n if @admin.active\n flash_error \"flash.error.admin.send_activation_mail_active\" \n else \n UserMailer.admin_activation_email(@admin).deliver\n flash_success \"flash.success.admin.send_activation_mail\",{}, {:email=>@admin.email} \n end\n \n end",
"def activation(account_request)\n @url = new_account_request_activation_url(account_request,\n :token => account_request.activation_token)\n\n mail(:to => account_request.email,\n :subject => 'Woods Charter School Lunch Online -- Account Activation')\n end",
"def activation_needed_email(vendor)\n @vendor = vendor\n @url = \"http://127.0.0.1:3000/vendors/#{vendor.activation_token}/activate\"\n mail(:to => vendor.email,\n :subject => \"Baitalhikma.co.jp - Please activate your vendor account\")\n end",
"def account_activation(ngo)\n @ngo = ngo\n mail(to: @ngo.email, subject: \"GYE Account Activation\")\n end",
"def send_activation_email\n unless notified?\n Notifier.email_activation(self).deliver\n self.update_attribute(:notified, true)\n end\n end",
"def activation\n @user = User.first\n UserMailer.activation(@user)\n end",
"def activated(user)\n mail_to user, activated_subject\n end",
"def account_activation(pengguna)\n @pengguna = pengguna\n mail to: pengguna.email, subject: \"Aktivasi akun Anda di Aplikasi Web Bimas Katolik\"\n end",
"def send_admin_activation_email\n MemberMailer.admin_account_activation(self).deliver_now\n end",
"def account_activation_request(user, new_user)\n @new_user = new_user\n @url = url_for(:controller => 'users', :action => 'index',\n :status => User::STATUS_REGISTERED,\n :sort_key => 'created_on', :sort_order => 'desc')\n mail :to => user,\n :subject => l(:mail_subject_account_activation_request, Setting.app_title)\n end",
"def confirm_email(user)\n @user = user\n @confirm_url = \"http://www.yscalumni.org/confirm/\" + user.confirmation_code\n mail(:to => user.email, :subject => \"Welcome to yscalumni.org! Please confirm your email!\")\n end",
"def account_activation\n user = User.first\n user.activation_sent_at = Time.current\n UserMailer.account_activation(user)\n end",
"def account_activation(band)\n @band = band\n mail to: band.email, subject: \"LiveJive: Identity Confirmation\"\n end",
"def resend_activation_email\n create_activation_digest\n save\n send_activation_email\n end",
"def account_activated(user)\n @user = user\n @login_url = url_for(:controller => 'account', :action => 'login')\n mail :to => user.mail,\n :subject => l(:mail_subject_register, Setting.app_title)\n end",
"def activate_account_email(user)\n @user = user\n @url = validate_account_url(@user.signup_token)\n mail(to: @user.email, subject: \"Welcome to Report It!\")\n end",
"def activation_welcome(pharmacist)\n @pharmacist = pharmacist\n\n mail to: @pharmacist.email_primary, subject: \"Your account has been activated\"\n end",
"def deliver_activation_confirmation!\n reset_perishable_token!\n Mailer.deliver_activation_confirmation(self)\n end",
"def account_confirmed(user)\n @notify_subject = strip_tags( \"USER CONFIRMED ACCOUNT AT #{ENV['APPLICATION_CONFIG_name']}\")\n @user = user\n mail( :to => ENV['APPLICATION_CONFIG_admin_notification_address'], :subject => @notify_subject)\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n update_attribute(:activation_sent_at, Time.zone.now)\n end",
"def activate(user)\n @activate_url = activate_user_url(user.key)\n mail to: user.email, subject: \"[Magic TV] メールアドレスの確認\"\n end",
"def email_confirm\n end",
"def signup_activation(user)\n @user = user\n @url = 'http://localhost:3000/login'\n mail to: @user.email, subject: \"Match Point validate email\"\n end",
"def confirm_email\n user = User.find_by_email_confirm_token(params[:confirm_token])\n if user\n user.email_activate\n flash[:success] = \"La tua email è stata confermata! Benvenuto!\"\n log_in user\n remember(user)\n redirect_to groups_path\n else\n flash[:error] = \"Siamo spiacenti, ma pare che l'utente non esista.\"\n redirect_to login_path\n end\n end",
"def email_verification_instructions(user)\n load_settings\n @user = user\n subject_suffix = \"Account Activation Instructions\"\n #@url = \"http://example.com/login\"\n mail(:to => user.email,\n :subject => \"[#{user.company_name}] #{subject_suffix}\",\n :template_path => 'notifications',\n :template_name => 'another',\n :activate_account_url => activate_accounts_url(:code => user.perishable_token,\n :subdomain => user.company.subdomain),\n :username => user.login,\n :token => user.perishable_token, :subdomain => user.company.subdomain)\n end",
"def account_activated(student)\n @student = student\n @url = 'http://clarionLibrary.com/login'\n mail(to: @student.email, subject: 'Congrat your account has been activated for Clarion library')\n end",
"def send_email_verification_email\n update_attribute(:activated, false)\n update_attribute(:activation_token, User.new_token)\n update_attribute(:activation_digest, User.digest(activation_token))\n save\n UserMailer.email_verification(self).deliver_now\n end",
"def do_pending\n make_activation_code\n # send the user an email with an activation code\n UserMailer.deliver_signup_notification(self)\n end",
"def confirmation_email(user)\n # email header info MUST be added here\n @recipients = user.email\n @from = \"#{Site.current.email}\"\n @subject = \"SIR Information:: Welcome to SIR\"\n\n # email body substitutions go here\n @body[\"name\"] = user.login\n @body[\"hash\"] = user.activation_code\n end",
"def activation_welcome\n PharmacistMailer.activation_welcome\n end",
"def do_pending \n make_activation_code\n ClaimingMailer.deliver_confirmation_request(self) if self.email && self.activation_code\n end",
"def send_email(user)\n\t UserMailer.activate_email(user).deliver\n\tend",
"def account_activation(request)\n @request = request\n @email = @request.clid + '@louisiana.edu'\n mail to: @email, subject: \"Room Request Confirmation\"\n end",
"def send_activation_request\n end",
"def confirmation(user)\n @user = user\n @user.generate_confirmation_code\n mail(to: @user.email, subject: \"Confirmation\") do |f|\n f.html\n end\n\n end",
"def confirm\r\n # Change user status to active\r\n update(status: :active)\r\n # Update all pending company_roles to active\r\n company_roles.update_all(status: 1)\r\n NotifyMailer.welcome_mail(self).deliver_later\r\n super\r\n end",
"def confirm\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def activate\n if params[:id]\n @user = User.find_by_confirmation_token(params[:id])\n if @user.present?\n @user.activate\n flash[:notice] = \"User activated successfully.\"\n Notifier.confirm_user(@user).deliver\n else\n flash[:notice] = \"User already activated.\"\n end\n else\n flash[:notice] = \"You do not have Activation Code.\"\n end\n redirect_to :action => \"home\"\n end",
"def acceptance_email ucr\n extract_variables ucr\n\n mail to: @user.email\n end"
] | [
"0.8492212",
"0.82157195",
"0.8210168",
"0.8205198",
"0.8194635",
"0.815073",
"0.8123249",
"0.8118494",
"0.81072223",
"0.8092254",
"0.8091004",
"0.8085906",
"0.80744064",
"0.80635005",
"0.8042117",
"0.8041977",
"0.80369604",
"0.8033361",
"0.80249697",
"0.801234",
"0.801234",
"0.80122924",
"0.80067044",
"0.7994439",
"0.79917866",
"0.7981943",
"0.7981943",
"0.7981943",
"0.7981943",
"0.7981943",
"0.7981943",
"0.7981943",
"0.7981943",
"0.7981943",
"0.7981943",
"0.7976885",
"0.79754823",
"0.79648054",
"0.79619414",
"0.79619414",
"0.7950875",
"0.79276943",
"0.79194784",
"0.79127544",
"0.78995645",
"0.78931797",
"0.78735703",
"0.78662384",
"0.7860328",
"0.78602254",
"0.7853487",
"0.7839836",
"0.78356785",
"0.7820796",
"0.78193885",
"0.78177476",
"0.7799118",
"0.77850395",
"0.7774845",
"0.7763903",
"0.77618587",
"0.7747092",
"0.7745981",
"0.7743729",
"0.77324927",
"0.7717792",
"0.7709975",
"0.76750624",
"0.766376",
"0.7657702",
"0.76367486",
"0.7625851",
"0.76040715",
"0.75980675",
"0.7585143",
"0.7584993",
"0.75707585",
"0.7561511",
"0.7549984",
"0.7547305",
"0.7526616",
"0.75204355",
"0.7506857",
"0.75040907",
"0.7496262",
"0.7496056",
"0.74881315",
"0.74679",
"0.74541616",
"0.7437376",
"0.7427435",
"0.7425155",
"0.7425048",
"0.7416605",
"0.74051404",
"0.74013186",
"0.73989934",
"0.7394294",
"0.7369188",
"0.7354577"
] | 0.7425051 | 92 |
mail the user to notify they have had their account suspended | def after_suspend(user, transition)
UserMailer.deliver_suspension_notice(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end",
"def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end",
"def trial_ending(user)\n mail to: user.email, subject: \"Only 72 Hours Left of Review Alerts!\"\n end",
"def suspended_mail(reservation, justification)\n @reservation = reservation\n @justification = justification\n\n mail to: @reservation.user.email, subject: \"[IMD- UFRN] Situação de reserva para sala #{@reservation.place.full_name}\"\n end",
"def is_suspended\n if is_suspended?\n flash[:danger] = \"Your account has been suspended.\"\n redirect_to root_path\n end\n end",
"def inactive_notification(user)\n setup_email(user)\n \n @subject += subject_from_sym :inactive_notification\n @body[:name] = user.full_name || 'Eternos user'\n @body[:link] = account_setup_url(:id => user.perishable_token)\n add_category_header \"Inactive Account Notice\"\n end",
"def account_expired(user) \n mail to: user.email, subject: \"Sorry to see you go the way of the Dodo...\"\n end",
"def unpaid_user_notification(user)\n mail(to: user.email, subject: I18n.t('user_mailer.unpaid_user_notification.subject'))\n end",
"def instauser_reject_email(user_id)\n @user = Instauser.find_by(id: user_id)\n mail(to: @user.email, subject: 'Thanks for joining Capish!')\n end",
"def send_admin_mail\n AdministratorMailer.new_user_waiting_for_approval(self).deliver_now\n end",
"def new_user_waiting_for_approval(faculty)\n @faculty = faculty\n\n mail(to: '[email protected]', subject: 'A new faculty member is awaiting approval!', body: 'A new faculty member is awaiting your approval!')\n end",
"def booked_not_confirmed\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_welcome_email\n #if Rails.env.production?\n if email.present?\n if followed_by >= 0\n # to send emails in delayed jobs use\n # UserMailer.instauser_welcome_email(id).delay.deliver!\n UserMailer.instauser_welcome_email(self.id).deliver\n else\n UserMailer.instauser_reject_email(self.id).deliver!\n end\n end\n #end\n end",
"def weekly_progress_report(user)\n @greeting = \"Hi\"\n \n user_email = @user.email\n\n mail to: user_email\n end",
"def in_progress\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def account_deactivated(student)\n @student = student\n mail(to: @student.email, subject: 'Your account has been De-activated from Clarion library')\n end",
"def notify\n ActionMailer::Base.mail(:from => \"[email protected]\", :to => \"[email protected]\", :cc => \"[email protected]\", :subject => \"DIL Upload permission request - \" + current_user.uid, :body => \"User \"+ current_user.uid + \" has requested to be added to the uploaders list. Is this approved?\\n\\n Their email address is: \" + current_user.email + \"\\n\\nThis email was generated by DIL.\").deliver\n flash[:notice] = \"Your inquiry has been submitted. Please come back and check later, you will be notified within a day as well.\"\n redirect_to \"/uploads\"\n end",
"def not_yet_approved profiles\n @profiles = profiles\n\n mail to: Rails.application.secrets.admins_emails\n end",
"def account_confirmed(user)\n @notify_subject = strip_tags( \"USER CONFIRMED ACCOUNT AT #{ENV['APPLICATION_CONFIG_name']}\")\n @user = user\n mail( :to => ENV['APPLICATION_CONFIG_admin_notification_address'], :subject => @notify_subject)\n end",
"def notify\n return if @user.email.blank?\n\n Notifier.user_event_analisys(@user, @user.events.future.analisys.first).deliver_now if @user.events.future.analisys.present?\n Notifier.user_event_visit(@user, @user.events.future.visits.first).deliver_now if @user.events.future.visits.present?\n end",
"def send_admin_email\n AdminMailer.new_user_waiting_for_approval.deliver\n end",
"def send_user_reminder_notice(user)\n return if user.email.nil?\n return if user.last_reminder.sent_at < one_week_ago\n EmailSender.send_notice_to(user.email)\nend",
"def tutor_reserved_notification\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def moved_up_event_waiting_user\n @user = @receiver\n @notification = @user.notifications.find_by(path: \"/events/#{@event.id}\")\n subject = \"[bootcamp] #{@event.title}で、補欠から参加に繰り上がりました。\"\n mail to: @user.email, subject: subject\n end",
"def disapprove(user)\n set_attachments\n\n @user = user\n\n mail(to: user.email, subject: \"Cuenta Desactivada @ Social Target - Its time to go social\")\n end",
"def send_activation_or_reset_mail\n end",
"def send_account_notification\n @user = User.find_by_id(params[:id]) \n begin \n url = \"http://www.uncharted.net/account/activation/#{@user.activation_code}\" \n Emailer.deliver_admin_accountactivation(@user.email,url)\t\n end\n flash[:notice] = \"Email has been sent to #{@user.email} to active his account.\"\n redirect_to :action => 'index'\n end",
"def send_reminder\r\n\t\tif Date.today == expiration_date - 1\r\n\t\t\tReminderMailer.food_reminder_msg(@user).deliver\r\n \t\tflash[:notice] = \"#{@user.username} has been notified by email.\" \r\n \tend\r\n end",
"def order_in_progress\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def account_activation(user)\n @user=user\n\n mail :to => @user.email, :from => \"[email protected]\", :subject => \"Account activation\"\n end",
"def check_schedule_unconfirmed\n\t\t# Picked a random 'check' user service and temporary set it's status to scheduled_unconfirmed\n\t\tuser_service \t\t= UserService.find_by(relationship_type: 'check')\n\t\tuser_service.date \t= Time.now\n\t\tuser_service.status = 'schedule_unconfirm'\n\t\tUserServicesMailer.check_updated(user_service)\n\tend",
"def suspend_user(user, row, disable_email = false)\n if row[:user_inactive_reason] == Constants::INACTIVE_MANUAL\n user.suspended_at = Time.now\n user.suspended_till = 200.years.from_now\n ban_reason = row[:ban_reason].blank? ? 'Account deactivated by administrator' : row[:ban_reason] # TODO i18n\n elsif row[:ban_start].present?\n user.suspended_at = Time.zone.at(row[:ban_start])\n user.suspended_till = row[:ban_end] > 0 ? Time.zone.at(row[:ban_end]) : 200.years.from_now\n ban_reason = row[:ban_reason]\n else\n return\n end\n\n if disable_email\n user_option = user.user_option\n user_option.email_digests = false\n user_option.email_level = UserOption.email_level_types[:never]\n user_option.email_messages_level = UserOption.email_level_types[:never]\n user_option.save!\n end\n\n if user.save\n StaffActionLogger.new(Discourse.system_user).log_user_suspend(user, ban_reason)\n else\n Rails.logger.error(\"Failed to suspend user #{user.username}. #{user.errors.try(:full_messages).try(:inspect)}\")\n end\n end",
"def profile_completion_thankyou(user_id)\n @user = User.find(user_id)\n\n mail :to => recipient(@user.email), :subject => \"25c Profile Completed!\"\n end",
"def profile_completion_reminder(user_id)\n @user = User.find(user_id)\n\n mail :to => recipient(@user.email), :subject => \"25c Profile Completion Reminder\"\n end",
"def confirm\r\n # Change user status to active\r\n update(status: :active)\r\n # Update all pending company_roles to active\r\n company_roles.update_all(status: 1)\r\n NotifyMailer.welcome_mail(self).deliver_later\r\n super\r\n end",
"def sent_verification_mail()\n @user= User.find(params[:id]);\n TweetsMailer.verification(@user).deliver_now;\n flash[:success]=\"Mail to #{@user.email} has been sended!\";\n redirect_to(verification_user_url(@user));\n end",
"def reminder_to_request_departmental_approval(name, email)\n @name = name\n\n mail(to: email, subject: 'Department approval may be needed')\n end",
"def activation_needed_email(user)\n @user = user\n @url = users_activate_path(id: user.activation_token)\n mail(to: user.email, subject: \"#{User.model_name.human}登録を完了しましょう!\")\n end",
"def admin_account_activation(member)\r\n @member = member\r\n mail(to: member.user_name, subject: \"Admin Account Activation\") \r\n end",
"def activated(user)\n mail_to user, activated_subject\n end",
"def activation_needed_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def paid_signup(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Paid Signup Email')\n @user = user\n mail to: user.email, subject: \"You've Upgraded to our Business Pro plan!\"\n end",
"def send_admin_mail\n admins = Admin.all\n\n admins.each do |admin|\n if admin.reminder\n AdminMailer.new_user_waiting_for_approval(admin.email).deliver_now\n end\n end\n end",
"def account_activated\n participant = Participant.first\n ParticipantMailer.account_activated(participant)\n end",
"def sendmail_confirm(user)\n @greeting = \"Hi\"\n @username = user.username\n @userid = user.userid\n\n mail to: \"[email protected]\", subject: \"登録完了通知\"\n end",
"def send_signup_notification\n deliver_activation_email(:signup, :subject => (MaSA[:activation_subject] || \"Please Activate Your Account\") )\n end",
"def weekly(user)\n @user = User.find(user)\n @points_away = Level.find(@user.level).points - @user.points\n mail(to: \"#{@user.name} <#{@user.email}>\", subject: \"Its Your Weekly Reminder to be Awesome\")\n end",
"def send_active_needs_approval_email\n Users::SendNeedsApprovalEmailJob.perform_later(user_id: self.id, active: true)\n end",
"def send_acceptance_email\n # UserMailer.delay.send_accepted_email(user_id)\n end",
"def deliver_unsent_mails\n task = MailTasks::Task.find(params[:id], :conditions => ['disabled = ?', false])\n # task.update_attribute(:disabled, true) unless task.disabled? # lock\n task_in_background('mail_tasks:deliver_unsent_mails', :task_id => task.id)\n flash[:notice] = \"Delivering #{task.mails.count} mails, refresh this page minutes later.\"\n redirect_to :back\n end",
"def email_user\n Mailer.deliver_nesstar_catalogs_processed(datasets, user_id, base_host) if EMAIL_ENABLED && User.find(user_id).person.send_notifications?\n end",
"def membership_notification(user)\n @greeting = \"Hi\"\n\n mail to: user.email, subject: \"Success! You did it.\"\n end",
"def activation_success_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def welcome_email(user)\n @user = user\n @subject = \"Welcome to Rays Cruiser, home of customized cruisers\"\n result = mail(:to => @user.email, :subject => @subject)\n # puts \"+++++++ Notification Email status: -> \" + result.to_s\n end",
"def send_activation_email\n ensure_activation_token_set\n UserMailer.account_activation(self, activation_token).deliver_later unless activated?\n end",
"def account_activation(member) \r\n @member = member \r\n mail(to: member.user_name, subject: \"Account Activation\") \r\n end",
"def check_user_status\n if current_user.is_a?(User) && (current_user.suspended? || current_user.banned?)\n if current_user.suspended? \n flash[:error] = t('suspension_notice', :default => \"Your account has been suspended. You may not add or edit content until your suspension has been resolved. Please contact us for more information.\")\n else\n flash[:error] = t('ban_notice', :default => \"Your account has been banned. You are not permitted to add or edit archive content. Please contact us for more information.\")\n end\n redirect_to current_user\n end\n end",
"def approval_needed(user)\n @user = user\n\n mail to: ENV['ADMIN_EMAIL'], subject: \"User wants approval for Thumbline Set List\"\n end",
"def activation_success_email user, application_id\n @user = User.find user\n @application = @user.used_applications.find application_id\n @url = application_url(@application)\n mail(:to => @user.email,\n :subject => \"You have been added to #{@application.application_name}\")\n end",
"def activation_needed_email(user)\n @user = user\n @url = \"http://lvh.me:3000/users/#{user.activation_token}/activate\"\n mail(:to => user.email,\n :subject => \"Welcome to StackClown\")\n end",
"def email_verification_instructions(user)\n load_settings\n @user = user\n subject_suffix = \"Account Activation Instructions\"\n #@url = \"http://example.com/login\"\n mail(:to => user.email,\n :subject => \"[#{user.company_name}] #{subject_suffix}\",\n :template_path => 'notifications',\n :template_name => 'another',\n :activate_account_url => activate_accounts_url(:code => user.perishable_token,\n :subdomain => user.company.subdomain),\n :username => user.login,\n :token => user.perishable_token, :subdomain => user.company.subdomain)\n end",
"def unconfirmed\n if current_user.generate_confirmation_token && current_user.save\n Delayed::Job.enqueue EmailResetMailer.new(current_user.id)\n flash[:notice] = t(\"profiles.update.confirmation_mail_sent\")\n else\n flash[:notice] = t(\"try_again\")\n end\n redirect_to edit_profile_path\n end",
"def polled_delivery( recipient_email , pending_deliveries )\n @recipient_email = recipient_email \n @user = User.find_by_email @recipient_email \n @pending_deliveries = pending_deliveries\n time = Time.now\n \n mail( :to => recipient_email, \n :subject => \"pilipoto | Updates (#{pending_deliveries.count}): #{time}\", \n :bcc => [\"[email protected]\"] )\n \n end",
"def invited_app_user(user)\n @user = user\n @subject = \"Invitation to Bunch\"\n @body = \"Bunch is a simple web dashboard that integrates with your teams’ calendars.\" \n mail(to: @user.email, subject: @subject)\n end",
"def activation_success_email(user)\n @user = user\n @url = \"http://lvh.me:3000/login\"\n mail(:to => user.email,\n :subject => \"Your account at Stackclown is now activated\")\n end",
"def notify\n ReminderMailer.notify\n end",
"def acceptance_email ucr\n extract_variables ucr\n\n mail to: @user.email\n end",
"def user_confirm_email(current_user)\n @current_user = current_user\n mail(to: current_user.email, subject: 'Confirm Email', from:\"PawBookings <[email protected]>\")\n end",
"def activation_needed_email(user)\n @user = user\n @account_activation_url = activate_user_url(user.activation_token)\n mail to: user.email, subject: \"ACTION NEEDED: Activate your VCDelta.org account\"\n end",
"def check_mail_confirmation\n return if current_user.client?\n\n unless current_user.confirmed?\n flash[:danger] = tf('common.flash.unconfirmed_mail')\n redirect_to :root\n end\n end",
"def activate_account_email(user)\n @user = user\n @url = validate_account_url(@user.signup_token)\n mail(to: @user.email, subject: \"Welcome to Report It!\")\n end",
"def notify_changed_request_status(request)\n @request=request\n mail(to: request.user.email,\n subject: \"#{request.user.name} your request has been #{I18n.t \"request_status.#{request.status}\"}\")\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def do_notify_disabled(transition)\n if user && Rails.application.settings.enforce_rules\n UserMailer.access_revoked(user, self).deliver_later\n end\n end",
"def send_activation_notification\n deliver_activation_email(:activation, :subject => (MaSA[:welcome_subject] || \"Welcome\" ))\n end",
"def user_welcome_notice(user)\n @user = user\n mail(:to => @user.email, :subject => \"Welcome to SocialStreet\") unless @user.email.blank?\n end",
"def resend_activation_emails\n User.where.not(person: nil).where.not(activation_code: nil).each do |user|\n if user.person\n logs = user.person.activation_email_logs\n if logs.count < MAX_ACTIVATION_EMAILS && (logs.empty? || logs.last.created_at < RESEND_ACTIVATION_EMAIL_DELAY.ago)\n Mailer.activation_request(user).deliver_later\n MessageLog.log_activation_email(user.person)\n end\n else\n Rails.logger.info(\"User with invalid person - #{user.id}\")\n end \n end\n end",
"def account_activation(user)\n @user = user\n\n mail to: user.email, subject: \"Account activation\"\n end",
"def activation_success_email(user)\n @user = user\n @subject = \"[#{SITE_NAME}] Account activated\"\n mail(bcc: @user.email, subject: @subject)\n end",
"def email_status_change_notices\n return if previously_published?\n\n case status\n when 'published', 'embargoed'\n StashEngine::UserMailer.status_change(resource, status).deliver_now\n StashEngine::UserMailer.journal_published_notice(resource, status).deliver_now\n when 'peer_review'\n StashEngine::UserMailer.status_change(resource, status).deliver_now\n StashEngine::UserMailer.journal_review_notice(resource, status).deliver_now\n when 'submitted'\n\n # Don't send multiple emails for the same resource, or for submission made by curator\n return if previously_submitted?\n\n StashEngine::UserMailer.status_change(resource, status).deliver_now\n when 'withdrawn'\n return if note.include?('final action required reminder') # this has already gotten a special withdrawal email\n\n if user_id == 0\n StashEngine::UserMailer.user_journal_withdrawn(resource, status).deliver_now\n else\n StashEngine::UserMailer.status_change(resource, status).deliver_now\n end\n end\n end",
"def deactivation(user)\n @user = user\n mail(to: @user.email, subject: \"Your CASA volunteer account has been deactivated\")\n end",
"def show_reminder\n mail to: @guest.email, subject: \"Reminder: \"[email protected]+\" house show\"\n end",
"def send_activation_email\n @admin = BusinessAdmin.find(params[:id])\n if @admin.active\n flash_error \"flash.error.admin.send_activation_mail_active\" \n else \n UserMailer.admin_activation_email(@admin).deliver\n flash_success \"flash.success.admin.send_activation_mail\",{}, {:email=>@admin.email} \n end\n \n end",
"def do_pending \n make_activation_code\n ClaimingMailer.deliver_confirmation_request(self) if self.email && self.activation_code\n end",
"def admin_notify\n UserMailer.signup_notification(self).deliver_later!(wait: 1.minute)\n end",
"def booking_confirmed\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def splash_page_confirmation(useremail)\n @useremail = useremail\n @greeting = \"Hi\"\n\n mail(:to => useremail, :bcc => [\"[email protected], [email protected]\"], :subject => \"SpectaFresh - New Splash Page User\")\n end",
"def send_activation\n if email_changed? and enable_mailer\n activated = false\n UserMailer.welcome_email(self, host).deliver\n end\n end",
"def approve\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def welcome_email\n UserMailer.with(user: @user).welcome_email.deliver_later\n end",
"def reject_email(email)\n @greeting = \"Hi\"\n\n mail to: email, subject: \"Your ASES Application Decision\"\n end",
"def activation\n @greeting = \"Hi\"\n\n mail :to => \"[email protected]\"\n end",
"def resend_confirmation\n return unless request.post?\n if current_user.activated_at\n flash.now[:error] = \"Your account has already been activated.\"\n else\n UserNotifier.deliver_signup_notification(current_user)\n flash.now[:notice] = \"Your confirmation email has been re-sent\"\n render :action => 'index'\n end\n end",
"def check_if_needs_approval\r\n self.suspended_at = Time.now if Setting.user_signup == :needs_approval && !self.admin\r\n end",
"def do_pending\n make_activation_code\n # send the user an email with an activation code\n UserMailer.deliver_signup_notification(self)\n end",
"def sendmail_confirm(user)\n @user = user\n mail(to: user.email,\n subject: \"会計よりお知らせ\")\n end",
"def account_activation(user)\n @user = user\n mail to: user.email, subject: \"Account activation\"\n end",
"def account_activation(user)\n @user = user\n mail to: user.email, subject: \"Account activation\"\n end",
"def rejected_notification\n @user = params[:user]\n mail(to: @user.email, subject: 'Library Card Request Rejected')\n end"
] | [
"0.7561353",
"0.7561353",
"0.70071226",
"0.70059025",
"0.6854304",
"0.68167055",
"0.6814337",
"0.6727689",
"0.66945815",
"0.6685348",
"0.66592884",
"0.66494024",
"0.66096187",
"0.6603581",
"0.658231",
"0.6521331",
"0.6508501",
"0.650128",
"0.64746267",
"0.6450896",
"0.6450631",
"0.64267546",
"0.64178205",
"0.6414562",
"0.64107937",
"0.64075744",
"0.6402727",
"0.6389453",
"0.6387303",
"0.6381493",
"0.63805795",
"0.6378649",
"0.6377291",
"0.6373251",
"0.6366223",
"0.6342124",
"0.63311464",
"0.6317173",
"0.6295832",
"0.62894523",
"0.6289024",
"0.628152",
"0.62766695",
"0.6268005",
"0.62564695",
"0.62418795",
"0.62404907",
"0.62353253",
"0.6231164",
"0.6229888",
"0.62283534",
"0.62189066",
"0.621081",
"0.6207155",
"0.62021667",
"0.619618",
"0.6196145",
"0.61960715",
"0.61939675",
"0.61934936",
"0.61934894",
"0.61884713",
"0.6187624",
"0.618332",
"0.6168237",
"0.61653477",
"0.6164036",
"0.616376",
"0.6163692",
"0.6162857",
"0.61627686",
"0.61622083",
"0.61620843",
"0.61620843",
"0.61589915",
"0.61571217",
"0.61530596",
"0.6142934",
"0.6136185",
"0.6135851",
"0.6133213",
"0.6129469",
"0.6129239",
"0.6127957",
"0.612576",
"0.61256546",
"0.6124724",
"0.612266",
"0.6114078",
"0.6096839",
"0.6092324",
"0.60844874",
"0.60808235",
"0.6077263",
"0.60766774",
"0.6076266",
"0.60727465",
"0.60701007",
"0.60701007",
"0.6068736"
] | 0.69546735 | 4 |
default location in ./lib | def ft
FancifyTable.new([[1,2],[3,4]])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lib_path; end",
"def lib_path; end",
"def lib_path; end",
"def lib\n File.join root, 'lib'\n end",
"def default_loadpath\n ['lib']\n end",
"def lib\n File.join(@root, 'lib')\n end",
"def lib\n File.join root, 'lib'\n end",
"def lib\n File.join root, 'lib'\n end",
"def lib_path=(_arg0); end",
"def lib_path=(_arg0); end",
"def lib_path=(_arg0); end",
"def lib_dir\n LIB_DIR\n end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def base_dir; end",
"def lib\n\tDir.mkdir('lib')\nend",
"def location\n opts = get_options\n opts['lib']\n end",
"def lib_root\n File.expand_path(\"../..\", \"#{__FILE__}/lib\")\n end",
"def lib_root\n File.expand_path(\"../..\", \"#{__FILE__}/lib\")\n end",
"def lib_dir\n File.join(root, 'lib')\n end",
"def lib_path\n File.join( solr_home, 'lib' )\n end",
"def default_path\n Gem.default_path + [@home]\n end",
"def additional_folders\n ['lib']\n end",
"def library; end",
"def library; end",
"def _lib_dir\n File.join(get_pref(\"sketchbook.path\"), \"libraries\")\n end",
"def libdir()\n LIBDIR\n end",
"def basepath; end",
"def base_dir\n raise NotImplementedError\n end",
"def default_directories\n [Texas.contents_subdir_name, \"lib/\", Texas.texas_dir]\n end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def mklib(path, home_path = true)\n \n if (home_path)\n lib = path + \"/lib\"\n else\n lib = path\n end\n \n $LOAD_PATH << lib\n \nend",
"def puppet_repl_lib_dir\n File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib'))\n end",
"def path\n @backend.lib_dir + name_on_disk\n end",
"def libs; end",
"def library_for(uri); end",
"def source_library_dir(lib)\n File.join base_dir, lib\n end",
"def app_library_dir\n base_dir = app_sandbox_dir\n if base_dir.nil?\n nil\n else\n File.join(base_dir, 'Library')\n end\n end",
"def default_paths\n [ '.' ]\n end",
"def directory; end",
"def directory; end",
"def solr_home_dir\n File.expand_path(File.join(solr_dist_dir, 'example', 'solr'))\nend",
"def lib(droplet)\n candidate = manifest_lib_dir(droplet)\n return candidate if candidate&.exist?\n\n candidate = boot_inf_lib_dir(droplet)\n return candidate if candidate&.exist?\n\n candidate = web_inf_lib_dir(droplet)\n return candidate if candidate&.exist?\n\n candidate = lib_dir(droplet)\n return candidate if candidate&.exist?\n\n raise 'No lib directory found'\n end",
"def default_var_path\n monit_name_path('/var/lib/%{name}')\n end",
"def core_root; end",
"def library_path\n @library_path ||= nil\n end",
"def work_dir; end",
"def default_search_directory\n Figgy.config[\"default_search_directory\"]\n end",
"def libfile\n Pathname.new(resource[:lib]).absolute? ? resource[:lib] : \"modules/#{resource[:lib]}\"\n end",
"def set_default_location\n self.location = Rails.application.config.classifeds_default_location;\n end",
"def libfile\n libfile = Pathname.new(resource[:lib]).absolute? ? resource[:lib] : \"modules/#{resource[:lib]}\"\n end",
"def default_files; end",
"def whereami() [__FILE__] end",
"def rr(lib)\n require_relative lib.to_s\n end",
"def framework_root() @framework_root ||= File.dirname(__FILE__) end",
"def default_path; end",
"def dir_base\n File.expand_path(File.dirname(__FILE__)+\"/../..\")\n end",
"def document_root\n end",
"def dir_alias()\n #This is a stub, used for indexing\n end",
"def autoproj_gem_home; @private_autoproj || Gem.user_dir end",
"def gem_dir # :nodoc:\n super\n end",
"def dependent_library_dir(lib)\n File.join LIB_DIR, lib\n end",
"def class_dir\n nil\n end",
"def relative_directory; end",
"def root_dir=(_arg0); end",
"def lib\n @obj['lib']\n end",
"def root\n \"#{File.dirname(__FILE__)}/..\"\nend",
"def load_libs; end",
"def initial_paths; end",
"def library_path\n datastore['DLL']\n end",
"def base_dir\n return Gem.dir unless loaded_from\n @base_dir ||= if default_gem? then\n File.dirname File.dirname File.dirname loaded_from\n else\n File.dirname File.dirname loaded_from\n end\n end",
"def base_directory\n @base_directory\n end",
"def application_root; end",
"def gems_dir\n raise NotImplementedError\n end",
"def base_dir_for_path_parameters; end",
"def project_root; end",
"def project_root; end",
"def root; Pathname(__dir__).parent; end",
"def root\n File.expand_path(File.dirname(__dir__))\n end",
"def install_dir(lib)\n if fr = ENV['FAKEROOT']\n return File.join(fr, lib)\n end\n\n lib\nend",
"def puppet_lib\n File.expand_path('./lib/puppet')\n end",
"def initialize\n @relative_location = '.'\n end",
"def enclosed_directory\n \".\"\nend",
"def add_gem_paths; end",
"def reference_directory\n @reference_directory ||= set_reference_directory\n end",
"def library\n @library ||= Boson.library(@lib)\n end",
"def my_dir\n File.dirname(__FILE__)\nend",
"def default_location(path)\n @default_location = File.expand_path(path)\n end",
"def definition_file_paths; end",
"def root_file_path; end"
] | [
"0.78100336",
"0.78100336",
"0.78100336",
"0.7459476",
"0.7364248",
"0.73402137",
"0.73262787",
"0.73262787",
"0.71357423",
"0.71357423",
"0.71357423",
"0.70296407",
"0.7027694",
"0.7027694",
"0.7027694",
"0.7027694",
"0.7027694",
"0.7027694",
"0.7027694",
"0.70157915",
"0.69745684",
"0.6961996",
"0.6961996",
"0.68445045",
"0.67620426",
"0.6636388",
"0.656509",
"0.65479445",
"0.65479445",
"0.6536548",
"0.6495424",
"0.648414",
"0.646936",
"0.6453888",
"0.6406186",
"0.6406186",
"0.6406186",
"0.6406186",
"0.6406186",
"0.6406186",
"0.6406186",
"0.6406186",
"0.623568",
"0.62352335",
"0.6214802",
"0.6214184",
"0.6189329",
"0.6181802",
"0.61740535",
"0.6164742",
"0.615962",
"0.615962",
"0.61502916",
"0.61443186",
"0.6133803",
"0.6117929",
"0.6117416",
"0.60766214",
"0.60676837",
"0.60517895",
"0.60493314",
"0.6020706",
"0.6016805",
"0.5971747",
"0.5965862",
"0.59596366",
"0.595037",
"0.5948612",
"0.59350365",
"0.5927462",
"0.5923804",
"0.5923774",
"0.59105945",
"0.59103775",
"0.59033114",
"0.58968866",
"0.5892467",
"0.5890809",
"0.588946",
"0.5871114",
"0.5866793",
"0.5865712",
"0.5853137",
"0.5846382",
"0.5831953",
"0.5829476",
"0.58266854",
"0.58266854",
"0.5819",
"0.5815343",
"0.5807148",
"0.5799518",
"0.5784139",
"0.5777694",
"0.577623",
"0.57692987",
"0.57690555",
"0.5765615",
"0.5763",
"0.57585096",
"0.57545614"
] | 0.0 | -1 |
GET /users GET /users.json | def index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end",
"def list_users\n self.class.get('/users')\n end",
"def users\n get('get_users')\n end",
"def index\n users = User.all\n json_response(users)\n end",
"def show\n @users = User.all\n json_response(@users)\n end",
"def list\r\n users = User.all\r\n render json: users\r\n end",
"def show\n @users = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users }\n end\n end",
"def get \n render :json => User.find(params[:id])\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n users = User.all\n render json: { users: users }, status: :ok\n end",
"def index\r\n users = User.all\r\n render json: users\r\n end",
"def users(params = {})\n params.merge!(key: 'users')\n objects_from_response(Code42::User, :get, 'user', params)\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def users(params = {})\n make_get_request('/account/users', params)\n end",
"def index\n users = User.all\n render json: users \n end",
"def index\n users = User.all\n\n render json: users, each_serializer: Api::V1::UsersSerializer\n end",
"def index\n user= User.all\n render json: {users:user}\n end",
"def index\n @users = User.all\n render json: @users, status: :ok\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n json_response(User.all) \n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end",
"def index\n users = User.all \n render json: users \n end",
"def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend",
"def index\n\t\t@users = User.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @users.map(&:as_json) }\n\t\tend\n\tend",
"def list\n render json: User.all\n end",
"def index\n @users = User.all\n render json: @users, status: :ok\n end",
"def user\n render :json=> User.find(params[:id])\n end",
"def index\n\n users = User.all \n render json: users\n\n end",
"def show\n render json: Users.find(params[\"id\"])\n end",
"def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html\n format.json { render json: @users }\n end\n end",
"def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end",
"def index\n \t@users = User.all\n\n respond_to do |format| \n format.json { render json: @users }\n end\n end",
"def list\n get('users')['users']\n end",
"def index\n render ActiveModelSerializers::SerializableResource.new(@users,\n each_serializer: UserSerializer\n ).to_json, status: 200\n end",
"def index\n @users = User.all \n render json: @users, status: :ok \n end",
"def index\n @users = User.all\n logger.debug(\"user index\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n render json: User.all\n end",
"def index\n @users = User.order_by(last_name: :desc)\n if @users\n render json: Oj.dump(json_for(@users, include: ['phones', 'cards'], meta: meta), mode: :compat)\n else\n return head :unauthorized\n end\n end",
"def users(params = {})\n response = get('users/lookup.json', params)\n response.map {|user| Croudia::Object::User.new(user) }\n end",
"def index\n render json: User.all\n end",
"def index\n render json: User.all\n end",
"def show\n user = User.find(params[:id])\n render json: @user\nend",
"def list_users(user_id)\n self.class.get(\"/users/#{user_id}\")\n end",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def index\n\t\t@users = User.all\n\n\t\trespond_to do |format|\n\t\t format.html # index.html.erb\n\t\t format.json { render json: @users }\n\t\tend\n\tend",
"def index\n @users = User.all(limit: 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users.as_json(user: current_user) }\n end\n end",
"def get_users\r\n # Prepare query url.\r\n _path_url = '/users'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n decoded.map { |element| User.from_hash(element) }\r\n end",
"def show\n # When a http GET request to '/users/1' is received, have it show,\n # in json format, user 1's information.\n @id = params[:id]\n @user = User.find(@id)\n render json: @user\n end",
"def show\n user = User.find(params[:id])\n\n render json: user\n end",
"def index \n render json: User.all\n end",
"def index\n @myusers = Myuser.all\n\n render json: @myusers\n end",
"def index\n\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def query_users(options={}) path = \"/api/v2/users\"\n get(path, options, AvaTax::VERSION) end",
"def list\n response = @client.get(\"/users\")\n response[\"users\"].map {|u| User.new(@client, u) }\n end",
"def users\n\t\trespond_with User.all\n\tend",
"def index\n @users = User.all\n\n respond_with do |format|\n format.json do\n render json: @users,\n each_serializer: Api::UserSerializer,\n root: 'users'\n end\n end\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end"
] | [
"0.82109934",
"0.7873764",
"0.7860689",
"0.78108346",
"0.78067017",
"0.7678852",
"0.76586664",
"0.76318866",
"0.7582366",
"0.75291824",
"0.7487637",
"0.74485743",
"0.7439024",
"0.7437192",
"0.7427442",
"0.73978853",
"0.73978853",
"0.73978853",
"0.73978853",
"0.7377353",
"0.7372414",
"0.736885",
"0.7368531",
"0.7367068",
"0.7358582",
"0.7358582",
"0.7358582",
"0.7358582",
"0.7358582",
"0.7358582",
"0.7358582",
"0.7358582",
"0.7358582",
"0.7358582",
"0.7351495",
"0.7350187",
"0.7350187",
"0.7350187",
"0.7350187",
"0.7350187",
"0.7350187",
"0.73463756",
"0.73426867",
"0.7331111",
"0.73231107",
"0.73227614",
"0.73126787",
"0.7295692",
"0.7274169",
"0.7265484",
"0.72624177",
"0.72607577",
"0.722517",
"0.72189873",
"0.71941674",
"0.71883225",
"0.7187108",
"0.71815044",
"0.717089",
"0.71695215",
"0.7156781",
"0.71546155",
"0.71546155",
"0.7140691",
"0.7135879",
"0.7134857",
"0.71316093",
"0.71315825",
"0.712011",
"0.7114429",
"0.7112858",
"0.7107888",
"0.7098051",
"0.70957917",
"0.70957917",
"0.7093039",
"0.70904744",
"0.70890427",
"0.70889443",
"0.7085115",
"0.7085115",
"0.7085115",
"0.7085115",
"0.7085115",
"0.7085115",
"0.7085115",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685",
"0.7081685"
] | 0.0 | -1 |
get the user's name. TODO : can this be fixed in druby so i ca access Username directly? def getName | def name=(user)
@name=user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name\n userName\n end",
"def get_username\n @user_name ||= self.user.username\n end",
"def name\n\t\tn = names\n\t\treturn n[:fullname] if n[:fullname]\n\t\treturn n[:username] if n[:username]\n\t\treturn I18n.translate(\"user.name.unknown\")\n\tend",
"def user_name\n return User.find(user_id).name\n end",
"def user_name\n return User.find(user_id).name\n end",
"def username\n name\n end",
"def name\n\t self.username\n end",
"def user_name(uid)\n deter_lab.get_profile(uid).try(:[], \"name\")\n end",
"def user_name\n User.find(self.user_id).name\n end",
"def get_user_name(user_id)\n User.find(user_id).name rescue nil\n end",
"def get_name(user_info)\n return user_info[\"name\"]\n end",
"def getUsername\n return @username\n end",
"def user_name\n @user_name ||= SlackUtils::SingletonClient.instance.find_user_name(@user_id)\n end",
"def name\r\n\t\t@usr_name\r\n\tend",
"def name\r\n\t\t@usr_name\r\n\tend",
"def display_name\n username\n end",
"def get_user_name\n\t\tretVal = \"User Not Found\"\n\t\tuser_id = self.user_id\n\t\tuser = User.find(user_id, :select=>[\"fname\",\"lname\"])\n\t\tunless user.nil?\n\t\t\tretVal = user.fname + \" \" + user.lname\n\t\tend\n\t\treturn retVal\n\tend",
"def user_name\n read_attribute('user_name') || \"anonymous\"\n end",
"def user_name\n decode_string_member(:user_name)\n end",
"def get_current_user_name\n return @name if @name\n name = get_current_user_meta\n name = name['query']['userinfo']['name'] if name\n\n name\n end",
"def user_name\n name = self.le_user.nil? ? '' : self.le_user.name\n end",
"def get_name()\n return @me.uname if @me.brother.nil?\n return @me.brother.full_name\n end",
"def display_name \n username\n end",
"def user_name\n\t\tobject.user.full_name \n\tend",
"def user_name\n name = user.nil? ? '' : user.name\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def simple_username\n return user.firstname + ' ' + user.lastname.first + '.' if !user.nil?\n name\n end",
"def username\r\n return @user.username\r\n end",
"def username # best practice to reference the same name\n @username\n end",
"def username\n user.username\n end",
"def user_name\n self.user.login\n end",
"def user_name\n self.user.login\n end",
"def get_user_name client, event\n # calls users_info on slack\n info = client.users_info(user: event.user_id ) \n info['user']['name']\n end",
"def get_user_name client, event\n # calls users_info on slack\n info = client.users_info(user: event.user_id )\n info['user']['name']\n end",
"def hubssolib_get_user_name\n user = self.hubssolib_current_user\n user ? user.user_real_name : nil\n end",
"def user_name\n @message[:user][:name]\n end",
"def username\n # this @user will always be an instance of a User\n @user.username\n end",
"def user_full_name\n @user[\"name\"]\n end",
"def user_name\n self.user.name\n end",
"def name\n \"#{user_name.titleize}\"\n end",
"def get_name(uid)\n\t\t\t\tusers().each do |user|\n\t\t\t\t\treturn user[1].username if user[1].uid == uid\n\t\t\t\tend\n\t\t\t\tnil\n\t\t\tend",
"def retrieve_name\n return @name\n end",
"def user_name\n object.user.name\n end",
"def username\n username = user.username\n end",
"def username\n user.username\n end",
"def get_name\n return @name\n end",
"def username\n user.username\n end",
"def username\n user.username\n end",
"def getUserName(userName)\n if(userName != nil)\n user = loadUser(userName)\n return user[\"fname\"]+\" \"+user[\"lname\"]\n end\n return \"User not Found!\"\n end",
"def get_user_name_not_null\n user = User.first(:id => self.user_id )\n return user.login if user\n return \"anon\"\n end",
"def user_name\n \"someone\"\n end",
"def username\n profile['Username']\n end",
"def nickname\r\n return @user.nickname\r\n end",
"def get_username(user_id)\n return User.find(user_id).username\n end",
"def username\n response = get 'v1/market/private/user/username.json'\n response[:username]\n end",
"def name_str\n self.anon ? \"Anonymous\" : self.user.name\n end",
"def get_name()\n @name\n end",
"def get_name()\n @name\n end",
"def display_name\n #self.email.split('@')[0]\n self.username\n end",
"def name\n\t\tself.rsuser.display_name\n\tend",
"def name\n if facebook_authentication && facebook_authentication.display_name\n return facebook_authentication.display_name\n end\n return username\n end",
"def name\n object.user.name\n end",
"def name\n object.user.name\n end",
"def name\n profile.user.name\n end",
"def get_user_name(user_id)\n if self.is_api then\n user = begin \n HuiMain.plugin_data.find_one(\"_id\" => BSON::ObjectId(user_id))\n rescue BSON::InvalidObjectId\n nil\n end\n if user then \n user[\"name\"]\n else\n nil\n end\n else # not api\n session[:current_user_name]\n end\n end",
"def get_name\n @name\n end",
"def user_username\n if self.user != nil\n self.user.username\n end\n end",
"def\n get_name()\n @name\n end",
"def username\n \"rocky\"\n end",
"def getusername()\r\n return getvalue(SVTags::USER_ID)\r\n end",
"def get_name\n return \"Name: \" + @name\n end",
"def name\n if first_name.present? || last_name.present?\n [first_name, last_name].join(\" \").strip\n else\n username\n end\n end",
"def username\n @username\n end",
"def user_name\n object.user.dxuser\n end",
"def user_name\n if self.user.blank?\n \"-\"\n else\n self.user.name\n end\n end",
"def username\n @username\n end",
"def get_name\n # The last sentence in a function is always returned so no need to mention return\n @name\n end",
"def get_name(id)\n return \"\" if !id\n user = User.find(id)\n user.first_name + ' ' + user.last_name\n end",
"def user_name\n self.user ? self.user.name : 'Anonymous'\n end",
"def name_of(user)\n user.to_s\n end",
"def user_name(name = nil)\n return user_name_from_name(name) if name\n\n user_name_random\n end",
"def full_name\n \"#{username}/#{name}\"\n end",
"def getName\n return @name\n end",
"def getName\n return @name\n end",
"def name(user_id)\n User.find(user_id).email\n end",
"def user_name\n @user_name ||= InchCI::ProjectUID.new(uid).user_name\n end",
"def get_name\n\t\treturn @name\n\tend",
"def get_name\n\t\treturn @name\n\tend",
"def get_name\n\t\treturn @name\n\tend",
"def getName()\n return @name ;\n end",
"def name\n \"#{self.class.name.titleize}: #{user.email rescue 'unknown user'}\"\n end",
"def name\n username || email\n end"
] | [
"0.8510286",
"0.8253431",
"0.81872946",
"0.81639075",
"0.81639075",
"0.801866",
"0.79995126",
"0.7944848",
"0.7914847",
"0.79084367",
"0.7885268",
"0.7870681",
"0.78506553",
"0.78332055",
"0.78332055",
"0.78220844",
"0.78083766",
"0.78002864",
"0.77891535",
"0.77659565",
"0.7752803",
"0.7738793",
"0.77380586",
"0.77189946",
"0.77128005",
"0.7710405",
"0.7710405",
"0.7710405",
"0.7710405",
"0.7710405",
"0.7710405",
"0.7710405",
"0.7710405",
"0.7710405",
"0.7710405",
"0.7697524",
"0.76839906",
"0.76209325",
"0.76039344",
"0.7579234",
"0.7579234",
"0.7578313",
"0.75688744",
"0.7565161",
"0.75602615",
"0.75403875",
"0.75315565",
"0.75215226",
"0.75002086",
"0.7498226",
"0.74931663",
"0.74805075",
"0.74714106",
"0.74704003",
"0.74686027",
"0.7466964",
"0.7466964",
"0.7462706",
"0.7460214",
"0.7455272",
"0.7452923",
"0.74364185",
"0.7434235",
"0.74318",
"0.74117947",
"0.73940104",
"0.73940104",
"0.73802966",
"0.7377332",
"0.7372709",
"0.73701465",
"0.73701465",
"0.73658055",
"0.7361918",
"0.7361083",
"0.7356981",
"0.7354481",
"0.735204",
"0.7350735",
"0.7349712",
"0.7339632",
"0.73222435",
"0.73196757",
"0.731945",
"0.7315765",
"0.73151463",
"0.73104924",
"0.73092747",
"0.730626",
"0.7303623",
"0.7302688",
"0.73006463",
"0.73006463",
"0.72960436",
"0.72927636",
"0.7285675",
"0.7285675",
"0.7285675",
"0.7280928",
"0.72734755",
"0.7272497"
] | 0.0 | -1 |
Enhance entry content through additional readability parsing | def enhance
require 'open-uri'
source = open(self.url).read
return Readability::Document.new(source).content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_entry(entry_name, content); end",
"def parse(entry, content_id)\n return '' unless entry.respond_to?(:event)\n # clean the html\n html = white_list(entry.event)\n \n # parse all standard lj tags first\n html = parse_lj_embed_tags(html,entry)\n html = parse_lj_user_tags(html)\n html = parse_lj_comm_tags(html)\n \n # create a cut version of the entry data\n cut = self.parse_lj_cut_tags(html.dup, content_id)\n\n # anchor the cuts in the main entry\n html = anchor_lj_cut_tags(html, content_id)\n\n # viola!\n {:cut => cut, :full => html}\n end",
"def read(entry); end",
"def render_entry(entry)\n %{<div class=\"hentry\" id=\"#{entry[:id]}\">\n <h2 class=\"entry-title\">#{entry[:title]}</h2>\n <span class=\"entry-content\">#{entry[:content]}</span>\n #{entry[:published_at].to_html}\n <span class=\"byline\">Posted by <span class=\"author vcard\"><span class=\"fn\"\n }\n end",
"def entry_summary(entry=@entry)\n filter(entry.summary, :markdown)\n end",
"def entry_summary(entry=@entry)\n filter(entry.summary, :markdown)\n end",
"def edit_entry_attrs\n test_entry_attrs\n end",
"def parse_entry(raw_entry)\n match_data = /#{@entry_regexp}/.match(raw_entry)\n return nil unless match_data\n values = match_data.captures\n values.shift if @multiline\n entry_hash([raw_entry, values].flatten)\n end",
"def content\n lines = super.lines.to_a\n fixed = []\n current_line = 0\n offset = 0\n formatted_lines = markup.lines.to_a\n lines.each_with_index do |line, index|\n formatted_line = formatted_lines[index + offset]\n if line.strip == \"\" and (formatted_line and formatted_lines[index + offset].strip != \"\")\n offset -= 1\n else\n fixed << line\n end\n end\n lines = fixed.join(\"\")\n lines\n end",
"def put_entry(entry)\n @io.puts EntryFormatter.new(entry)\n end",
"def get_entry(entry); end",
"def entry!(*args)\n substitute_values = if args.last.kind_of?(Hash)\n [args.delete_at(-1)]\n elsif args.last.kind_of?(Array)\n args.delete_at(-1)\n else\n []\n end\n \n entry = self.find(self.current_language, *args)\n entry.kind_of?(String) ? substitute_entry(entry, *substitute_values) : entry\n rescue EntryFormatError => e\n raise EntryFormatError.new(e.language, args, e.entry_content, e.format_values, e.original_exception) # reraise with more details\n end",
"def add_entry(entry)\n self.notes = \"#{entry}\\n#{notes}\".truncate_bytes(MAX_LENGTH)\n end",
"def alter_description(description, additions, subtractions)\n new_description = description\n additions.each do |addition|\n stylized_weights = addition.weights&.join('->')\n if stylized_weights == '' || stylized_weights.nil?\n stylized_weights = 'body weight'\n end\n\n # This will look off for things I do 1 set or rep of,\n # but I'm ok with that - it makes eventually parsing\n # a dump of my data from Strava in the future easier.\n new_description << <<~EOF\n #{addition.exercise}: #{addition.num_sets} sets of #{addition.num_reps} reps at #{stylized_weights} lbs\n EOF\n end\n subtractions.each do |subtraction|\n new_description_array = new_description.split(\"\\n\").reject do |line|\n line.index(subtraction) == 0\n end\n new_description = new_description_array.join(\"\\n\")\n end\n\n new_description\nend",
"def entry_helper_text(code, display, type, text, entry_type = 'COMP')\n s_entry = entry_helper(entry_type)\n s_obs = observation_helper('OBS', 'EVN')\n s_entry << s_obs\n s_obs << code_helper(code, '2.16.840.1.114222.4.5.1', display, 'NEDSS Base System')\n s_obs << value_helper_text(type, text)\n s_entry\n end",
"def content_manipulation\n self.summary = markup_manipulation self.summary if self.summary.present?\n self.content = markup_manipulation self.content if self.content.present?\n end",
"def clean_entry(entry)\n fields_to_check = [ :author, :title, :journal, :publisher, :booktitle,\n :month, :institution ]\n\n return unless entry.methods.include?(\"fields\".to_sym)\n entry.fields.each do |f, value|\n #puts \"Checking field #{f} for entry #{entry}\"\n next unless fields_to_check.include?(f) or !(entry[f].nil?)\n entry[f] = standardize_capitialization(entry[f])\n end\nend",
"def expand_line(line, value_escaper)\n # Generate a cross reference if a reference is given,\n # otherwise just fill in the name part\n\n line.gsub!(/HREF:(\\w+?):(\\w+?):/) {\n ref = @value_stack.lookup($1)\n name = @value_stack.find_scalar($2)\n\n if ref and !ref.kind_of?(Array)\n\t\"<a href=\\\"#{ref}\\\">#{name}</a>\"\n else\n\tname\n end\n }\n\n # Substitute in values for %xxx% constructs. This is made complex\n # because the replacement string may contain characters that are\n # meaningful to the regexp (like \\1)\n\n line = line.gsub(/%([a-zA-Z]\\w*)%/) {\n val = value_escaper.call(@value_stack.find_scalar($1).to_s)\n val.tr('\\\\', \"\\000\")\n }\n\n # Look for various controls (ddlb's etc)\n\n line = line.gsub(/%check:(\\w+?)%/) { check($1) }\n\n line = line.gsub(/%date:(\\w+?)%/) { date($1) }\n\n line = line.gsub(/%popup:(\\w+?):(\\w+?)%/) { popup($1, $2) }\n\n line = line.gsub(/%ddlb:(\\w+?):(\\w+?)%/) { ddlb($1, $2) }\n\n line = line.gsub(/%vsortddlb:(\\w+?):(\\w+?)%/) { ddlb($1, $2, 1) }\n\n line = line.gsub(/%radio:(\\w+?):(\\w+?)%/) { radio($1, $2) }\n\n line = line.gsub(/%radioone:(\\w+?):(\\w+?)%/) { radio($1, $2, \"\") }\n\n line = line.gsub(/%input:(\\w+?):(\\d+?):(\\d+?)%/) { input($1, $2, $3) }\n\n line = line.gsub(/%text:(\\w+?):(\\d+?):(\\d+?)%/) { text($1, $2, $3) }\n\n line = line.gsub(/%pwinput:(\\w+?):(\\d+?):(\\d+?)%/) { input($1, $2, $3, \"password\") }\n\n line = line.gsub(/%pair(\\d)?:([^:]+):(\\w+?)%/) { pair($2, $3, $1) }\n\n line\n rescue Exception => e\n err = Exception.new(\"Template error: #{e} in '#{line}'\")\n err.set_backtrace(e.backtrace)\n raise err\n end",
"def entry\n return @text_entry\n end",
"def store_article_text(entry)\n puts \"storing data\"\n if(entry.link != '#')\n \n # Get html from link\n response = Net::HTTP.get(URI.parse(entry.link))\n if(response.downcase.include?(\"<h1>moved permanently</h1>\"))\n html = Nokogiri::HTML(response, nil, 'UTF-8')\n tag = html.css(\"a\")\n link = tag.attribute('href')\n response = Net::HTTP.get(URI.parse(link))\n end\n \n # Use readability to find text from html\n data = Readability::Document.new(response || \"\")\n if(data.content == nil || data.content.length < 15)\n new_data = entry.description\n else\n new_data = data.content.gsub(/<[^>]+>/,\"\").squeeze(\" \").strip.toutf8 || \"\"\n end\n \n else\n new_data = entry.description\n end\n \n # Save data if new\n if(!entry.data || entry.data != new_data)\n entry.data = new_data\n return true\n end\n return false\nend",
"def process_entry(entry)\n doc = Nokogiri::XML(entry)\n yield doc\n entry.replace(doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML))\n end",
"def text\n self.entry\n end",
"def update!(**args)\n @clean_text = args[:clean_text] if args.key?(:clean_text)\n @info_string = args[:info_string] if args.key?(:info_string)\n @snippet = args[:snippet] if args.key?(:snippet)\n @text = args[:text] if args.key?(:text)\n end",
"def parse_entry(entry)\n\t\tsubentries = entry.split(@flags[1])\n\t\tsubentries.shift\n\t\tsubentries.each do |subent|\n\t\t\tparse_subentry(subent)\n\t\tend \n\tend",
"def entry; end",
"def entry; end",
"def entry; end",
"def entry; end",
"def update!(**args)\n @tagged_entry = args[:tagged_entry] if args.key?(:tagged_entry)\n end",
"def do_add_entry(entry,html_txt,infos)\n\t\t##debug(sprintf(\"ADD DICT ENTRY(%s)\\nINF(%s)\\n\",entry.inspect(),infos.inspect()))\n\n\t\t\n\t\tkey_words= entry['key_words']\n\t\tinfos[:key_words]=key_words\n\t\tinfos[:key_lang]=entry['key_lang']\n\n\n\t\tattr = \"\"\n\t\t[\"grammar\",\"category\"].each{|tag|\n\t\t\tattr << \"/\" << entry[tag] if entry[tag] != \"\"\n\t\t}\n\t\tattr << \"/\" if attr != \"\"\n\t\tprimary_lang=primary_lang(entry['dict_id'])\n\t\tif primary_lang==\"\"\n\t\t\tprimary_lang=entry['key_lang']\n\t\tend\n\t\tkey_term=\"\"\n\t\tif primary_lang != \"\" and infos[:xlated_word] != nil and infos[:xlated_word][primary_lang]!=nil\n\t\t\tinfos[:xlated_word][primary_lang].each{|w|\n\t\t\t\tkey_term << \",\" if key_term != \"\"\n\t\t\t\tkey_term << w \n\t\t\t}\n\t\tend\n\n\t\tinfos[:key_attr]=attr\n\t\tinfos[:attributes]=attr\n\t\tkey_txt = '<p class=\"dict_key_1\">'\n\t\tkey_txt << \"<b>\"\n\t\tif key_term==\"\"\n\t\t\tif key_words.index(\"$phrase$\")!= nil\n\t\t\t\tkey_txt << @to_search\n\t\t\telse\n\t\t\t\tkey_txt << key_words\n\t\t\tend\n\t\telse\n\t\t\tkey_txt << key_term\n\t\tend\n\t\tkey_txt << \"</b>\"\n\t\tif attr != \"\"\n\t\t\tkey_txt << ' <i>' + attr + '</i>' \n\t\tend\n\t\tkey_txt << '</p>'\n\n\t\tinfos[:dict_entry_key]= key_txt\n\t\tadd_entry(entry['dict_id'],\n\t\t\t key_words,\n\t\t\t [html_txt],\n\t\t\t infos)\n\t\t##debug(sprintf(\"INFOS-FINAL\\n %s\\n\",infos.inspect()))\n\tend",
"def format_input(input)\n raise \"No content in entry\" if input.nil? || input.strip.length == 0\n input_lines = input.split(/[\\n\\r]+/)\n title = input_lines[0].strip\n note = input_lines.length > 1 ? input_lines[1..-1] : []\n note.map! { |line|\n line.strip\n }.delete_if { |line|\n line =~ /^\\s*$/\n }\n\n [title, note]\n end",
"def cleanup_newlines\n [:description, :use].each do |field|\n self[field].gsub!(/\\r\\n/, \"\\n\") if self[field]\n end\n end",
"def entry_wrap(content_array)\n content_array.unshift(Atom::ENTRY_TAG[0]).push(Atom::ENTRY_TAG[1])\n end",
"def hreview entry, params\n review = <<END\n<div class=\"hreview\">\n <div class=\"item\">\nEND\n\n review << if params['item']['url'].empty?\n \"<span class='fn'>\" + CGI.escapeHTML(params['title']) + \"</span>\"\n else\n \"<a class='url fn' href='\" +\n CGI.escapeHTML(params['item']['url']) + \"'>\" +\n CGI.escapeHTML(params['title']) + \"</a>\"\n end\n\n unless params['rating'].empty?\n # 'rating' filled stars out of 5 hollow ones\n rating = params['rating'].to_i\n stars = ('★' * rating) + ('☆' * (5 - rating))\n\n review << \"<div>Rating: <abbr class='rating' title='#{rating}'>#{stars}</abbr></div>\"\n end\n\n if entry.content\n review << \"<div class='description'>#{entry.content.html}</div>\"\n end\n\n review <<<<END\n </div>\n</div>\nEND\n\n entry.content = review\n entry.content['type'] = 'html'\n end",
"def update_raw_text(item); end",
"def update_raw_text(item); end",
"def print_entry(entry)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # If no issues for this file, print that and break\n # The filename print is repetative, but reduces another check later\n if !entry[:has_issues]\n if @config.show_type != 'dirty'\n debug_print \"No issues for #{ entry }\\n\"\n print_status \"o\", GREEN\n cprint BOLD + UNDERLINE + GREEN + \"#{ entry[:relative_path] }\" + RESET + \"\\n\"\n return true\n end\n else\n if @config.show_type != 'clean'\n debug_print \"Issues found for #{ entry }\\n\"\n cprint \"\\n\"\n print_status \"x\", RED\n cprint BOLD + UNDERLINE + RED + \"#{entry[:relative_path]}\" + RESET + \"\\n\"\n else\n return true\n end\n end\n\n\n # [review] - Should the tag structure be self contained in the hash\n # Or is it ok to reference @config to figure out the tags\n @config.tag_list.each do | _tag |\n debug_print \"Checking for #{ _tag }\\n\"\n\n # [review] - Better way to ignore tags through structure (hash) data\n # Maybe have individual has_issues for each one?\n if entry[_tag].size.zero?\n debug_print \"#{ _tag } has no issues, skipping\\n\"\n next\n end\n\n debug_print \"#{ _tag } has issues in it, print!\\n\"\n print_status \"#{ _tag }\", BLUE\n cprint \"\\n\"\n\n # Go through each issue in tag\n entry[_tag].each do | _issue |\n cprint WHITE + \" line #{ _issue[:line_number] } - \" + RESET\n cprint BOLD + \"#{ _issue[:title] }\" + RESET\n\n\n # Check to see if it has been resolved on GitHub/Bitbucket\n debug_print \"Checking if issue has been resolved\\n\"\n @config.github_issues[:closed].each do | _closed |\n if _closed[\"body\"].include?(_issue[:md5])\n debug_print \"Found in #{ _closed[:comment] }, not posting\\n\"\n cprint BOLD + \" [\" + RESET\n cprint GREEN + BOLD + \"Resolved on GitHub\" + RESET\n cprint BOLD + \"]\" + RESET\n end\n debug_print \"Did not find in #{ _closed[:comment] }\\n\"\n end\n\n debug_print \"Checking if issue has been resolved\\n\"\n @config.bitbucket_issues[:closed].each do | _closed |\n if _closed[\"content\"].include?(_issue[:md5])\n debug_print \"Found in #{ _closed[\"content\"] }, not posting\\n\"\n cprint BOLD + \" [\" + RESET\n cprint GREEN + BOLD + \"Resolved on Bitbucket\" + RESET\n cprint BOLD + \"]\\n\" + RESET\n end\n debug_print \"Did not find in #{ _closed[\"title\"] }\\n\"\n end\n cprint \"\\n\"\n\n end\n cprint \"\\n\"\n end\n end",
"def show_entry(name, value, opt = nil)\n html_opt = { class: 'about-entry' }\n merge_html_options!(html_opt, opt)\n name = name.to_s\n value = value.inspect unless value&.html_safe?\n content_tag(:p, html_opt) {\n content_tag(:span, ERB::Util.h(name), class: 'about-item') +\n content_tag(:span, ERB::Util.h(value), class: 'about-value')\n }\n end",
"def transform_to_star(entry)\n # locale=* entries have a nil sys.locale\n unless entry_locale = entry.dig('sys', 'locale')\n # nothing to do\n return entry\n end\n\n new_entry = entry.dup\n\n new_entry['sys'] = entry['sys'].except('locale').merge({\n 'WCC::Contentful::EntryLocaleTransformer:locales_included' => [entry_locale]\n })\n if entry.key?('fields')\n new_entry['fields'] =\n entry['fields'].transform_values do |value|\n h = {}\n h[entry_locale] = value\n h\n end\n end\n\n new_entry\n end",
"def inject_content(item, contents)\n @formatter_options[:inject] ||= {}\n @formatter_options[:inject][item.to_sym] ||= []\n @formatter_options[:inject][item.to_sym] << contents\n end",
"def Process4Changes(content, dataset)\n # update this hash in the future\n change_flags = { \"[NAME]\" => [:firstname] , \"[FULLNAME]\" => [:firstname, :lastname]}\n \n # Please don't do something stupid like setting someone's first name to [FULLNAME] or something\n change_flags.each do |key, value|\n replacement_string = ''\n value.each do |wolf|\n replacement_string += dataset[wolf] + \" \"\n end\n content = content.gsub(key, replacement_string)\n end\n return content\n end",
"def fix_for_toc_entry(elements); end",
"def update!(**args)\n @alternate_text = args[:alternate_text] if args.key?(:alternate_text)\n @attribute = args[:attribute] if args.key?(:attribute)\n @chapter_start = args[:chapter_start] if args.key?(:chapter_start)\n @cleanup_annotation = args[:cleanup_annotation] if args.key?(:cleanup_annotation)\n @continues_from_previous_page = args[:continues_from_previous_page] if args.key?(:continues_from_previous_page)\n @continues_from_previous_page_hyphenated = args[:continues_from_previous_page_hyphenated] if args.key?(:continues_from_previous_page_hyphenated)\n @continues_on_next_page = args[:continues_on_next_page] if args.key?(:continues_on_next_page)\n @end_of_spanning_label = args[:end_of_spanning_label] if args.key?(:end_of_spanning_label)\n @experimental_data = args[:experimental_data] if args.key?(:experimental_data)\n @flow = args[:flow] if args.key?(:flow)\n @modification_record = args[:modification_record] if args.key?(:modification_record)\n @page_number_ordinal = args[:page_number_ordinal] if args.key?(:page_number_ordinal)\n @appearance = args[:appearance] if args.key?(:appearance)\n @columndetails = args[:columndetails] if args.key?(:columndetails)\n @contentlink = args[:contentlink] if args.key?(:contentlink)\n @editcorrectioncandidate = args[:editcorrectioncandidate] if args.key?(:editcorrectioncandidate)\n @overrides = args[:overrides] if args.key?(:overrides)\n @snippetfilter = args[:snippetfilter] if args.key?(:snippetfilter)\n @tablecelldetails = args[:tablecelldetails] if args.key?(:tablecelldetails)\n @tabledetails = args[:tabledetails] if args.key?(:tabledetails)\n end",
"def inline_formatting(input)\n @re_help.rewrite_emphasis input do |marker, body|\n m = MarkdownMap[marker]\n \"#{m}#{body}#{m}\"\n end\n @re_help.rewrite_subp input do |type, text|\n if type == \"_\" then\n \"<sub>#{text}</sub>\"\n elsif type == \"^\" then\n \"<sup>#{text}</sup>\"\n end\n end\n @re_help.rewrite_links input do |link, defi|\n # We don't add a description for images in links, because its\n # empty value forces the image to be inlined.\n defi ||= link unless link =~ @re_help.org_image_file_regexp\n link = link.gsub(/ /, \"%%20\")\n\n if defi =~ @re_help.org_image_file_regexp\n \"\"\n elsif defi\n \"[#{defi}](#{link})\"\n else\n \"[#{link}](#{link})\"\n end\n end\n\n # Just reuse Textile special symbols for now?\n Orgmode.special_symbols_to_textile(input)\n input = @re_help.restore_code_snippets input\n input\n end",
"def interpret(d)\n article = Article.new\n article.title = !d['webTitle'].nil? ? d['webTitle'] : 'n/a'\n article.source = @source\n article.pub_date = !d['webPublicationDate'].nil? ? (DateTime.parse d['webPublicationDate']) : nil\n article.author = !d['fields']['byline'].nil? ? d['fields']['byline'] : 'n/a'\n article.link = !d['webUrl'].nil? ? d['webUrl'] : 'n/a'\n\n re = /<(\"[^\"]*\"|'[^']*'|[^'\">])*>/\n summary = !d['fields']['body'].nil? ? d['fields']['body'] : 'n/a'\n summary.gsub!(re, '')\n article.summary = summary[0...126] + '...'\n\n article.image = !d['fields']['thumbnail'].nil? ? d['fields']['thumbnail'] : 'n/a'\n article\n end",
"def entry_filter; end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @text_segments = args[:text_segments] if args.key?(:text_segments)\n end",
"def initialize_entry_attributes\n fix_attributes\n special_feed_handling\n end",
"def generate_bib_entry(entry)\n s = \"\"\n if entry.type == :book\n # author/editor, title, publisher, year\n if entry[:author].nil?\n # just eds\n raise \"No author or editors\" if entry[:editor].nil?\n s << \"#{process_authors process_bibtex(entry[:editor])} (editors), \"\n else \n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n end\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"#{process_bibtex entry[:publisher]}, \" if !entry[:publisher].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :article\n # author, title, journal, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"#{process_bibtex entry[:journal]}, \" if !entry[:journal].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :inbook\n # author/editor, title, chapter/pages, publisher, year\n if entry[:author].nil?\n # just eds\n raise \"No author or editors\" if entry[:editor].nil?\n s << \"#{process_authors process_bibtex(entry[:editor])} (editors), \"\n else \n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n end \n s << \"\\\"#{to_google_scholar process_bibtex(entry[:chapter])}\\\", \" if !entry[:chapter].nil?\n s << \"in #{process_bibtex entry[:title]}, \"\n s << \"pages #{process_bibtex entry[:pages]}, \" if !entry[:pages].nil?\n s << \"#{process_bibtex entry[:publisher]}, \" if !entry[:publisher].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :techreport\n # author, title, institution, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"Technical Report #{process_bibtex entry[:number]}, \" if !entry[:number].nil? \n s << \"#{process_bibtex entry[:institution]}, \" if !entry[:institution].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :inproceedings\n # author, title, booktitle, year\n if entry[:author].nil?\n # just eds\n raise \"No author or editors\" if entry[:editor].nil?\n s << \"#{process_authors process_bibtex(entry[:editor])} (editors), \"\n else\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n end \n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"in #{process_bibtex entry[:booktitle]}, \" if !entry[:booktitle].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :phdthesis\n # author, title, school, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"[PhD Thesis] \"\n s << \"#{process_bibtex entry[:school]}, \" if !entry[:school].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :mastersthesis\n # author, title, school, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"[Masters Thesis] \"\n s << \"#{process_bibtex entry[:school]}, \" if !entry[:school].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :incollection\n # author, title, booktitle, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"in #{process_bibtex entry[:booktitle]}, \" if !entry[:booktitle].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :conference\n # author, title, booktitle, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"in #{process_bibtex entry[:booktitle]}, \" if !entry[:booktitle].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :unpublished\n # author, title\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"#{process_bibtex entry[:year]}.\"\n\telsif entry.type == :manual\n # author, title\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"#{process_bibtex entry[:year]}.\"\n else \n raise \"Unknown bibtex type: #{entry.type}\" \n end\n return s\nend",
"def parse_entries\n entries = []\n entry_name = nil\n entry_body = []\n\n @content.each_line do |line|\n case line\n when /^\\s*$/ then\n next\n when /^\\w.*/ then\n entries << [entry_name, entry_body] if entry_name\n\n entry_name = $&\n\n begin\n time = Time.parse entry_name\n # HACK Ruby 1.8 does not raise ArgumentError for Time.parse \"Other\"\n entry_name = nil unless entry_name =~ /#{time.year}/\n rescue NoMethodError\n # HACK Ruby 2.1.2 and earlier raises NoMethodError if time part is absent\n entry_name.split ' ', 2\n rescue ArgumentError\n if /out of range/ =~ $!.message\n Time.parse(entry_name.split(' ', 2)[0]) rescue entry_name = nil\n else\n entry_name = nil\n end\n end\n\n entry_body = []\n when /^(\\t| {8})?\\*\\s*(.*)/ then # \"\\t* file.c (func): ...\"\n entry_body << $2\n when /^(\\t| {8})?\\s*(\\(.*)/ then # \"\\t(func): ...\"\n entry = $2\n\n if entry_body.last =~ /:/ then\n entry_body << entry\n else\n continue_entry_body entry_body, entry\n end\n when /^(\\t| {8})?\\s*(.*)/ then\n continue_entry_body entry_body, $2\n end\n end\n\n entries << [entry_name, entry_body] if entry_name\n\n entries.reject! do |(entry,_)|\n entry == nil\n end\n\n entries\n end",
"def rebuildevent(e)\n if USEMEMCACHE != true\n static = Staticentry.find(e.staticentry.id)\n else\n static = Staticentry.get_cache(e.staticentry.id)\n end\n entries = e.payload.split('/111/')\n hash = Hash.new\n entries.each do |m|\n map = m.split('/000/')\n hash.store('<<<' + map[0] + '>>>',map[1])\n end\n p = static.data\n hash.each do |key, val|\n p = p.gsub(key,val)\n p = p.gsub(\"\\n\", \"<br/>\")\n end\n return p\n end",
"def parse_legacy_markup(markup)\n options = {}\n if markup =~ FullCiteWithTitle\n options['author'] = $1\n options['url'] = $2 + $3\n options['title'] = $4.strip\n elsif markup =~ FullCite\n options['author'] = $1\n options['url'] = $2 + $3\n elsif markup =~ AuthorTitle\n options['author'] = $1\n options['title'] = $2.strip\n elsif markup =~ Author\n options['author'] = $1\n end\n options\n end",
"def entry_body(entry=@entry)\n filter(entry.body, entry.filter)\n end",
"def entry_body(entry=@entry)\n filter(entry.body, entry.filter)\n end",
"def clean_entries(feed)\n full_sanitizer = Rails::Html::FullSanitizer.new\n feed.entries.map do |entry|\n clean_summary = full_sanitizer.sanitize(entry.summary)\n clean_sentences(clean_summary)\n end\n end",
"def preprocess_avc(contents)\n new_contents = contents # no manipulation done here\n new_contents\n end",
"def additional_text_edits\n attributes.fetch(:additionalTextEdits)\n end",
"def additional_text_edits\n attributes.fetch(:additionalTextEdits)\n end",
"def tree_entry_converted(prefix_str, doc_info)\n # Get the elements of the entry\n doc_title, doc_link, doc_details = format_title_and_ref doc_info\n warning_label = doc_info.stderr.empty? ? \"\" : \"(conv issues)\"\n\n # Calculate padding to get (conv issues) and details aligned between entries\n padding = 70\n [doc_title, prefix_str, warning_label].each { |p| padding -= p.length }\n padding = 0 unless padding.positive?\n \"#{prefix_str} #{doc_link}#{' ' * padding}#{warning_label} #{doc_details}\"\n end",
"def update_manga_info (manga, fetcher, builder)\n title = builder.get_object('title_entry')\n if manga.title.nil?\n\ttitle.text = \"\"\n else\n\ttitle.text = manga.title\n end\n\n alt_titles = builder.get_object('alt_titles_entry')\n if manga.alt_titles.nil? or manga.alt_titles.empty?\n\talt_titles.text = \"\"\n else\n\talt_titles.text = manga.alt_titles.join(', ')\n end\n\n authors = builder.get_object('authors_entry')\n if manga.author.nil? or manga.author.empty?\n\tauthors.text = \"\"\n else\n\tauthors.text = manga.author.join(', ')\n end\n\n artists = builder.get_object('artists_entry')\n if manga.artist.nil? or manga.artist.empty?\n\tartist.text = \"\"\n else\n\tartists.text = manga.artist.join(', ')\n end\n\n categories = builder.get_object('categories_entry')\n if manga.category.nil? or manga.category.empty?\n\tcategories.text = \"\"\n else\n\tcategories.text = manga.category.join(', ')\n end\n\n schedule = builder.get_object('schedule_entry')\n if manga.schedule.nil?\n\tschedule.text = \"\"\n else\n\tschedule.text = manga.schedule\n end\n\n state = builder.get_object('state_entry')\n if manga.state.nil?\n\tstate.text = \"\"\n else\n\tstate.text = manga.state\n end\n\n status = builder.get_object('status_entry')\n if manga.status.nil?\n\tstatus.text = \"\"\n else\n\tstatus.text = manga.status\n end\n\n last_update = builder.get_object('last_update_entry')\n if manga.last_update.nil?\n\tlast_update.text = \"\"\n else\n\tlast_update.text = manga.last_update\n end\n\n release_year = builder.get_object('release_year_entry')\n if manga.release_year.nil?\n\trelease_year.text = \"\"\n else\n\trelease_year.text = manga.release_year.year.to_s\n end\n\n when_added = builder.get_object('when_added_entry')\n if manga.when_added.nil?\n\twhen_added.text = \"\"\n else\n\twhen_added.text = manga.when_added\n end\n\n site_ranking = builder.get_object('site_ranking_entry')\n if manga.site_ranking.nil?\n\tsite_ranking.text = \"\"\n else\n\tsite_ranking.text = manga.site_ranking.to_s\n end\n\n summary = builder.get_object('summary_textview')\n if manga.summary.nil?\n\tsummary.buffer.text = \"\"\n else\n\tsummary.buffer.text = manga.summary\n end\n\n # Deal with the image\n cover = builder.get_object('image')\n url = manga.cover_page_url\n image_file = fetcher.get_image(url)\n\n if !image_file.nil?\n\tcover.pixbuf = Gdk::Pixbuf.new(image_file)\n else\n\tcover.stock = Gtk::Stock.MISSING_IMAGE\n end\nend",
"def format_input(input)\n raise EmptyInput, 'No content in entry' if input.nil? || input.strip.empty?\n\n input_lines = input.split(/[\\n\\r]+/).delete_if(&:ignore?)\n title = input_lines[0]&.strip\n raise EmptyInput, 'No content in first line' if title.nil? || title.strip.empty?\n\n date = nil\n iso_rx = /\\d{4}-\\d\\d-\\d\\d \\d\\d:\\d\\d/\n date_rx = /^(?:\\s*- )?(?<date>.*?) \\| (?=\\S)/\n\n raise EmptyInput, 'No content' if title.sub(/^.*?\\| */, '').strip.empty?\n\n title.expand_date_tags(Doing.setting('date_tags'))\n\n if title =~ date_rx\n m = title.match(date_rx)\n d = m['date']\n date = if d =~ iso_rx\n Time.parse(d)\n else\n d.chronify(guess: :begin)\n end\n title.sub!(date_rx, '').strip!\n end\n\n note = Note.new\n note.add(input_lines[1..-1]) if input_lines.length > 1\n # If title line ends in a parenthetical, use that as the note\n if note.empty? && title =~ /\\s+\\(.*?\\)$/\n title.sub!(/\\s+\\((?<note>.*?)\\)$/) do\n m = Regexp.last_match\n note.add(m['note'])\n ''\n end\n end\n\n note.strip_lines!\n note.compress\n\n [date, title, note]\n end",
"def parse_entry(line)\n\n return nil if line.nil? || line.length <= 0\n meta,msg = line.split(' : ',2)\n msg = msg.chomp unless msg.nil?\n\n parts=meta.split(' ')\n\n fields=[]\n\n unless parts.length < 3\n fields_str=parts[2][1..-2]\n fields = fields_str.split(',')\n end\n\n Entry.new(parts[0], parts[1], fields, msg, line)\n end",
"def load_notetags\n super\n init_custom_fields\n self.note.split(/[\\r\\n]+/).each { |line|\n case line\n when /<default title:\\s*(\\d*)\\s*>/i\n @default_title_id = $1.to_i\n when /<titles:[ ](\\d+(?:\\s*,\\s*\\d+)*)>/i\n $1.scan(/\\d+/).each { |num| \n @titles.push(num.to_i) if num.to_i > 0 \n }\n when /<icon_index:\\s*(\\d*)\\s*>/i\n @icon_index = $1.to_i\n when /<max_level:\\s*(\\d*)\\s*>/i\n @max_level = $1.to_i\n end\n }\n end",
"def editintro(value)\n merge(editintro: value.to_s)\n end",
"def enrich_data(a)\n b = a.scan(/<p>(.*)<\\/p>/)\n b = b.join(\"\")\n b = b.gsub(/\\(.*?\\)/,\"\")\n b = b.gsub(/<.*?>/,\"\")\n b = b.gsub(/^.*?\\(.*?\\).*?--/,\"\")\n\n # Replace \n # ? => ?.\n # ! => !.\n # ... => <blank>\n # so that the text is suitable for pcfg parsers\n b = b.gsub(/\\?/,\"?.\")\n b = b.gsub(/\\!/,\"!.\")\n b = b.gsub(/\\.\\.\\./, \"\")\n end",
"def parse_moreinfo\n if @input.match?(/Tov.* ld\\.:\\n/)\n @ast[\"moreinfo\"] = @input.scan_until(/^\\n/)\n end\n end",
"def load_notetags\n super\n init_custom_fields\n self.note.split(/[\\r\\n]+/).each { |line|\n case line\n when /<(.*) growth:\\s*(\\d+\\.?\\d*)>/i\n case $1.upcase\n when \"HP\"\n @growth_rate[0] = $2.to_f\n when \"MP\", \"TP\"\n @growth_rate[1] = $2.to_f\n when \"P.ATK\"\n @growth_rate[2] = $2.to_f\n when \"P.DEF\"\n @growth_rate[3] = $2.to_f\n when \"M.ATK\"\n @growth_rate[4] = $2.to_f\n when \"M.DEF\"\n @growth_rate[5] = $2.to_f\n when \"AGI\"\n @growth_rate[6] = $2.to_f\n when \"LCK\", \"LUCK\"\n @growth_rate[7] = $2.to_f\n end\n when /<max sp:\\s*(\\d+\\.?\\d*)>/i\n @msp = $1.to_i\n when /<capacities:[ ](\\d+(?:\\s*,\\s*\\d+)*)>/i\n $1.scan(/\\d+/).each { |num| \n @capacities.push(num.to_i) if num.to_i > 0 \n }\n end\n }\n end",
"def format_content(type, args, content)\n Formatter.new(content).apply(type, args)\n end",
"def inline_formatting(input)\n input = @re_help.rewrite_emphasis(input) do |marker, body|\n m = TextileMap[marker]\n \"#{m}#{body}#{m}\"\n end\n input = @re_help.rewrite_subp(input) do |type, text|\n if type == \"_\" then\n \"~#{text}~\"\n elsif type == \"^\" then\n \"^#{text}^\"\n end\n end\n input = @re_help.rewrite_links(input) do |link, text|\n text ||= link\n link = link.gsub(/ /, \"%20\")\n \"\\\"#{text}\\\":#{link}\"\n end\n input = @re_help.rewrite_footnote(input) do |name, defi|\n # textile only support numerical names! Use hash as a workarround\n name = name.hash.to_s unless name.to_i.to_s == name # check if number\n @footnotes[name] = defi if defi\n \"[#{name}]\"\n end\n Orgmode.special_symbols_to_textile(input)\n input\n end",
"def parse(line)\n raise EntryFileError, \"Do not know how to parse the entries in #{File.basename(@data_file)}!\"\n end",
"def parse_content(content); end",
"def generate_excerpt?; end",
"def process_codes(node, entry)\n codes = node.xpath(\"./ccr:Description/ccr:Code\")\n desctext = node.at_xpath(\"./ccr:Description/ccr:Text\").content\n entry.description = desctext\n if codes.size > 0 \n found_code = true\n codes.each do |code|\n normalize_coding_system(code)\n codetext = code.at_xpath(\"./ccr:CodingSystem\").content\n entry.add_code(code.at_xpath(\"./ccr:Value\").content, codetext)\n end\n end\n end",
"def markup_file_contents(contents); end",
"def parse_article_from_file article_file_name\n article_values = {}\n article_values[:content] = ''\n article_values[:introduction] = ''\n article_values[:tags] = []\n article_values[:authors] = []\n article_values[:title] = ''\n article_values[:date] = nil\n article_values[:updated_at] = nil\n next_is = ''\n\n puts \"Parsing: #{article_file_name}\"\n File.open(File.join(ARTICLE_PATH, article_file_name), 'r') do |article_file|\n article_file.each_line do |line|\n next if line.blank?\n ##### Checking what next line will be\n # Detect date\n if line.include?(DATE_DELIMITER)\n next_is = 'date'\n # Detect updated_at date\n elsif line.include?(UPDATED_AT_DELIMITER)\n next_is = 'updated_at'\n # Detect introduction\n elsif line.include?(INTRODUCTION_DELIMITER)\n next_is = 'introduction'\n # Detect content\n elsif line.include?(CONTENT_DELIMITER)\n next_is = 'content'\n elsif line.include?(TAGS_DELIMITER)\n next_is = 'tags'\n elsif line.include?(TITLE_DELIMITER)\n next_is = 'title'\n elsif line.include?(AUTHORS_DELIMITER)\n next_is = 'authors'\n else\n case(next_is)\n when 'date' then article_values[:date] = Time.zone.parse(line.strip)\n when 'updated_at' then article_values[:updated_at] = Time.zone.parse(line.strip)\n when 'introduction' then article_values[:introduction] << line.strip\n when 'content' then article_values[:content] << line\n when 'title' then article_values[:title] << line.strip\n when 'authors' then\n line.strip.split(',').each do |author|\n author.strip! # Removing eventual spaces at the begining or at the end\n article_values[:authors] << Author.where(:name => author).first unless Author.where(:name => author).empty?\n end\n when 'tags' then\n line.strip.split(',').each do |tag_name|\n tag_name.strip! # Removing eventual spaces at the begining or at the end\n # If the tag exists, add it to the list of tags\n if Tag.where(:name => tag_name).empty?\n article_values[:tags] << Tag.create(:name => tag_name)\n else\n article_values[:tags] << Tag.where(:name => tag_name).first\n end\n end\n end\n end\n end\n end\n return article_values\nend",
"def gather_info(entry)\n gathered = false\n while not gathered do\n hsay \"Gathering information for entry '#{entry.title}'\", :information\n\n entry = fill_entry(entry)\n\n # dump the info we have gathered and make sure that\n # it is the input that the user wants to store.\n\n hsay \"-\" * 40, :separator_bar\n hsay entry, :normal\n hsay \"-\" * 40, :separator_bar\n\n gathered = hagree \"Is this information correct? (y/n)\"\n end\n\n entry\n end",
"def parse_emphasis; end",
"def entry_params\n params.require(:entry).permit(:content)\n end",
"def build_post_from_entry(entry)\n text = entry.text.gsub(/\\\\u([0-9a-zA-Z]{4})/) { |s| [$1.to_i(16)].pack(\"U\") }\n self.posts.build(\n :service_action => Service::SERVICE_ACTION_POST,\n :identifier => entry.id.to_s,\n :title => text,\n :markup => Post::HTML_MARKUP,\n :summary => text,\n :url => \"#{self.profile_url}/status/#{entry.id}\",\n :published_at => entry.created_at.to_time,\n :extra_content => {\n :original_tags => self.search_for_hashtags(text) # array de tags\n }\n )\n end",
"def tree_entry_converted(prefix_str, node)\n # Get the elements of the entry\n doc_title, doc_link, doc_details = format_title_and_ref(node)\n warning_label = node.data.stderr.empty? ? \"\" : \"(conv issues)\"\n\n # Calculate padding to get (conv issues) and details aligned in columns\n padding = 70\n [doc_title, prefix_str, warning_label].each { |p| padding -= p.length }\n padding = 0 unless padding.positive?\n\n \"#{prefix_str} #{doc_link}#{\" \" * padding}#{warning_label} #{doc_details}\"\n end",
"def tagline; end",
"def content=(_); end",
"def interpret(d)\n article = Article.new\n\n if d['headline'] != []\n if !d['headline']['main'].nil?\n article.title = d['headline']['main']\n elsif !d['headline']['name'].nil?\n article.title = d['headline']['name']\n end\n end\n if article.title.nil?\n article.title = 'n/a'\n end\n\n article.source = @source\n article.pub_date = !(d['pub_date'].eql? '') ? (DateTime.parse d['pub_date']) : nil\n\n byline = (d['byline'] != []) ? d['byline']['original'] : 'n/a'\n article.author = (byline[0..2] == 'By ') ? byline[3..byline.size] : byline\n\n article.link = !(d['web_url'].eql? '') ? d['web_url'] : 'n/a'\n article.summary = !(d['snippet'].eql? '') ? d['snippet'] : 'n/a'\n\n # an article may contain several images\n image = []\n if d['multimedia'] != []\n url = 'http://www.nytimes.com/'\n img = d['multimedia']\n img.each { |i| (i['type'] == 'image') ? image << (url + i['url']) : 'n/a' }\n else\n image << 'n/a'\n end\n article.image = image.join(',')\n\n article\n end",
"def to_s\n TEXT_SYMBOLS[self.entry_type] + \n \"] \" +\n body\n end",
"def update_line(line_text)\n updated_line_text = line_text\n # replace outlook list format with textile list format:\n updated_line_text.gsub!(/^[\\u00b7] /,\"* \") # middot - middle dot\n updated_line_text.gsub!(/^[\\u2022] /,\"* \") # bull - bullet\n updated_line_text.gsub!(/^o /,\"** \") # second level bullet\n updated_line_text.gsub!(/^[\\u00A7] /,\"*** \") # 3rd level bullet (section entity)\n \n updated_line_text.gsub!(/^[0-9]+\\. /, \"# \")\n \n updated_line_text\n end",
"def render_entry_json(global_id_prefix, inner_id, entry, filter, include_description)\n filtered_entry_count = 0 # Anzahl dem Filter entsprechende Einträge, egal ob Knoten oder Abfrage\n result =\n \"{\n \\\"id\\\": \\\"#{\"#{global_id_prefix}_#{inner_id}\"}\\\",\n \\\"text\\\": \\\"#{inner_id+1}. #{entry[:name]}\\\",\n \\\"state\\\": { \\\"opened\\\": false }\n\"\n if entry[:entries] # Menu-Knoten\n result << \", \\\"children\\\": [ \" # Space nach [ um leere Position entfernen zu können, wenn kein Nachfolger mit Komma getrennt\n entry_id = 0\n entry[:entries].each do |e|\n subresult = render_entry_json(\"#{global_id_prefix}_#{inner_id}\", entry_id, e, filter, include_description)\n if subresult\n result << subresult\n filtered_entry_count = filtered_entry_count + 1\n end\n entry_id = entry_id + 1\n end\n result[result.length-1] = ' ' # letztes Komma entfernen\n result << \"]\"\n else\n result << \", \\\"icon\\\":\\\"assets/application-monitor.png\\\"\"\n end\n result << \"},\"\n return nil if filter && entry[:entries] && filtered_entry_count == 0 # Anzeige unterdrücken wenn Knoten keine Treffer für Filter hat\n return nil if filter && !entry[:entries] && !entry[:name].upcase[filter.upcase] && !(entry[:desc].upcase[filter.upcase] && include_description)\n result\n end",
"def to_s\n output = \n 'AUTHOR: ' + self.author.author_name + \"\\n\" +\n 'TITLE: ' + self.entry_title + \"\\n\" +\n 'STATUS: ' + self.status_string + \"\\n\" +\n 'ALLOW COMMENTS: ' + self.entry_allow_comments.to_s + \"\\n\" +\n 'CONVERT BREAKS: ' + self.entry_convert_breaks + \"\\n\" +\n 'ALLOW PINGS: ' + self.entry_allow_pings.to_s + \"\\n\\n\" +\n 'DATE: ' + self.entry_created_on.strftime(EXPORT_DATE_FORMAT) + \"\\n\" +\n EXPORT_ATTRIBUTE_BREAK\n\n output += 'BODY:' + \"\\n\"\n output += self.entry_text.blank? ? \"\\n\" : self.entry_text.chomp + \"\\n\\n\"\n output += EXPORT_ATTRIBUTE_BREAK\n \n output += 'EXTENDED BODY:' + \"\\n\"\n output += self.entry_text_more.blank? ? \"\\n\" : self.entry_text_more.chomp + \"\\n\\n\"\n output += EXPORT_ATTRIBUTE_BREAK\n\n output += 'EXCERPT:' + \"\\n\"\n output += self.entry_excerpt.blank? ? \"\\n\" : self.entry_excerpt.chomp + \"\\n\\n\"\n output += EXPORT_ATTRIBUTE_BREAK\n\n output += 'KEYWORDS:' + \"\\n\"\n output += self.entry_keywords.blank? ? \"\\n\" : self.entry_keywords.chomp + \"\\n\\n\"\n output += EXPORT_ATTRIBUTE_BREAK\n\n # Append comments.\n output += self.comments.collect { |comment| comment.to_s }.join\n \n output += EXPORT_ENTRY_BREAK\n output\n end",
"def characterize\n content = source_to_content\n extracted_md = extract_metadata(content)\n terms = parse_metadata(extracted_md)\n store_metadata(terms)\n end",
"def main_description; end",
"def replace(content)\n \n # pre-structuring\n content.gsub!( /^(\\w.*)\\n(\\w.*)/ ) { \"#{$1} #{$2}\" } # remove single line breaks between text in order to avoid false paragraph markup\n content.gsub!( /<!--/ ) { \"--\" } # replace opening html commentaries\n content.gsub!( /-->/ ) { \"--\" } # replace closing html commentaries\n \n # templates\n content.gsub!( /\\{\\{Zitat\\|(.*)\\|.*\\}\\}\\s*$\\n/ ) { \"\\{p\\}\\\"#{$1}\\\"\\{/p\\}\\n\" } # citation\n content.gsub!( /\\{\\{.*(Finale Version).*\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1}</font>{/status}<br>\" } # final version\n content.gsub!( /\\{\\{Vorlage:(Dokument.*)\\n*(.*)\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1} #{$2}</font>{/status}<br>\" } # document status\n content.gsub!( /\\{\\{.*\\}\\} *$/ ) { '' } # remove single line templates\n content.gsub!( /\\{\\{.*\\n?.*\\}\\} *$/ ) { '' } # remove all remaining templates\n \n # tags\n content.gsub!( /<nowiki>(.*?)<\\/nowiki>/ ) { \"<pre>#{$1}</pre>\" }\n content.gsub!( /^ +(.*)/ ) { \"<pre>#{$1}</pre>\" }\n\n # special markup of qualidative data analysis\n content = content + \"\\n\\n{!end}\"\n \n # categories\n content.gsub!( /\\[\\[Kategorie:(.*?)\\]\\]/i ) { \"{category}<font color=\\\"#FF0000\\\">Kategorie:#{$1}</font>{/category}<br>\" }\n \n # images\n content.gsub!( /\\[\\[Bild:(.*?)\\]\\]/i ) { \"{image}Bild:#{$1.gsub!(/.*\\|/,'')}{/image}<br>\"} # Bild:lpscreen.jpg|thumb|Bereichseite des Landesportals\n\n # bold\n content.gsub!(/'''(.*?)'''/) {\"<strong>#{$1}</strong>\"}\n content.gsub!(/'''(.*?)$/) {\"<strong>#{$1}</strong>\"}\n\n # italics\n content.gsub!(/''(.*?)''/) {\"<em>#{$1}</em>\"}\n content.gsub!(/''(.*?)$/) {\"<em>#{$1}</em>\"}\n\n # headings\n 6.downto(1) { |i| content.gsub!( /^={#{i}}(.*?)={#{i}} *$/ ) { \"<h#{i}>\\{h>#{i}\\}#{$1}\\{/h>#{i}\\}</h#{i}>\" } }\n \n # links, internal\n content.gsub!( /\\[\\[([^\\[\\n]*?)\\| *(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[\\[(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n\n # links, external\n content.gsub!( /\\[([^\\[\\n]*?)\\| *(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n \n # lists\n content.gsub!(/^:+/,'') # remove forced indenting\n content.gsub!( /^((?:\\*.*\\n+)+)/ ) { \"\\{l>ul\\}<ul>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^\\*/,'')}</li>\\n\" }.join}</ul>\\{/l>ul\\}<br>\\n\" } # first level ul\n content.gsub!( /^((?:#.*\\n+)+)/ ) { \"\\{l>ol\\}<ol>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^#/,'')}</li>\\n\" }.join}</ol>\\{/l>ol\\}<br>\\n\" } # first level ol\n content.gsub!( /<li>\\s*<\\/li>\\n/ ) { '' } # remove empty list entries (this may occur if first-level wiki-lists are entered with \\n\\n; they look like a single list when, in fact, they are but multiple single lists)\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # second level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # second level ol\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # third level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # third level ol\n\n # tables\n # the table conversion barely works, cf. http://johbuc6.coconia.net/doku.php/mediawiki2html_machine/code?DokuWiki=7c542b97df2bc0f82fec0f4875265a20 for an implementation in PHP\n content.gsub!( /^\\{\\|(.*)/ ) { \"\\{table\\}\\n<table #{$1}>\" }\n content.gsub!( /\\|\\}/ ) { \"</table>\\n\\{/table\\}\" }\n content.gsub!( /^\\|-(.*)/ ) { \"<tr>#{$1}\" }\n content.gsub!( /^!(.*?)\\|(.*)/ ) { \"<th #{$1}>#{$2}</th>\" } # table header with piped markup\n content.gsub!( /^!(.*)/ ) { \"<th>#{$1}</th>\" } # table header without piped markup\n content.gsub!( /^\\|(.*?)\\|(.*)/ ) { \"<td #{$1}>#{$2}\" } # table data with piped markup\n content.gsub!( /^\\|(.*)/ ) { \"<td>#{$1}\" } # table data without piped markup\n \n # line breaks\n content.gsub!( /(^(?:\\w|<strong|<em|<a|\\\").*)\\n\\s*\\n/ ) {\"<p>\\{p\\}#{$1}\\{/p\\}</p>\\n\"}\n \n # special markup of qualidative data analysis\n content.gsub!( /(\\{id\\}.*\\{\\/title\\})/ ) { \"<p><strong><em>#{$1.gsub(/_/,' ')}</em></strong></p>\" }\n \n# //$html = nl2br($html);\n# \t// line breaks\n# \t$html = preg_replace('/[\\n\\r]{4}/',\"<br/><br/>\",$html);\n# \t$html = preg_replace('/[\\n\\r]{2}/',\"<br/>\",$html);\n\n# \t$html = preg_replace('/[>]<br\\/>[<]/',\"><\",$html);\n \n# // allowed tags\n# \t$html = preg_replace('/<(\\/?)(small|sup|sub|u)>/','<${1}${2}>',$html);\n#\n# \t$html = preg_replace('/\\n*<br *\\/?>\\n*/',\"\\n\",$html);\n# \t$html = preg_replace('/<(\\/?)(math|pre|code|nowiki)>/','<${1}pre>',$html);\n# \t$html = preg_replace('/<!--/','<!--',$html);\n# \t$html = preg_replace('/-->/',' -->',$html);\n# \n return content\n\nend",
"def update!(**args)\n @is_vulgar = args[:is_vulgar] if args.key?(:is_vulgar)\n @leading_text_type = args[:leading_text_type] if args.key?(:leading_text_type)\n @snippet_html = args[:snippet_html] if args.key?(:snippet_html)\n @snippet_type = args[:snippet_type] if args.key?(:snippet_type)\n @source = args[:source] if args.key?(:source)\n @tidbits = args[:tidbits] if args.key?(:tidbits)\n @trailing_ellipsis = args[:trailing_ellipsis] if args.key?(:trailing_ellipsis)\n end",
"def entry_params\n params.fetch(:entry, {}).permit(:title, :sub_title, :body, :tag_id, :home_page, :summary, :img,\n :news_item, :image_in_news, :image_disable, :news_img, :newsletter_img, :merge_to_id,\n :position, :change_main_entry_position, :doc, :doc_description, :summary_length, :locale, :style_class, :header_colour, :background_colour, :colour,\n :banner_id, :partial, :entry_position, :master_entry_id, :youtube_id_str, :use_as_news_summary, :simple_text,\n :sidebar_id, :side_bar, :side_bar_news, :side_bar_social, :side_bar_search, :side_bar_gallery, :side_bar_tag_id, :unrestricted_html,\n :merge_with_previous, :raw_html, :image_popup, :alt_title, :acts_as_tag_id, :gallery_id,\n :facebook_share, :linkedin_share, :xing_share, :twitter_share, :email_share, :instagram_share, :show_in_documents_tag, :image_caption,\n :tag_line, :raw_html, :show_image_titles, :doc_delete, :img_delete, :alt_img_delete, :header_html,\n :enable_comments, :comment_strategy, :layout_select, :link_to_tag, :style, :event_id, :squeeze_id, :job_posting_id)\n end",
"def parse_entry(io)\n # Read INSDC or RefSeq entry\n Bio::FlatFile.auto(io).each do |entry|\n @entry = entry\n @features = entry.features\n @source = @features.shift\n parse_sequence\n parse_source\n #parse_genes\n parse_features\n end\n end",
"def share_description(value) \n raw(value).gsub(\"<br>\", \" \").gsub(\"<br />\", \" \")\n end",
"def render_article(p)\n r = \"\"\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n r += p.title.detex.titlecase + \". \"\n\n r += text_for_field(\"Journal\", p, :postfix => \", \").detex\n r += text_for_field(\"Volume\", p)\n r += text_for_field(\"Number\", p, :prefix => \"(\", :postfix => \")\").detex\n\n # TODO simplify this complex nested if structures that result from the conversion\n # from BibDesks abbrv template\n if field(p,\"Pages\") then # <$fields.Pages?>\n if field(p,\"Volume\") then # <$fields.Volume?>\n r += \":\"\n else # <?$fields.Volume?>\n if field(p,\"Number\") then #<$fields.Number?>\n r+= \":\"\n else # <?$fields.Number?>\n r += \"page \"\n end # </$fields.Number?>\n end # </$fields.Volume?>\n\n r += text_for_field(\"Pages\", p, :postfix => \", \").detex # <$fields.Pages/>,\n else # <?$fields.Pages?>\n if field(p,\"Volume\") then #<$fields.Volume?>\n r += \", \"\n else # <?$fields.Volume?>\n if field(p,\"Number\") then #<$fields.Number?>\n r += \", \"\n end #</$fields.Number?>\n end\n end #</$fields.Pages?>\n\n r += month_for_field(\"Month\", p, :postfix => \" \").detex\n r += text_for_field(\"Year\", p, :postfix => \". \").detex\n r += text_for_field(\"Note\", p, :postfix => \". \")\n return r\nend",
"def update_html_for_abstract\n return unless details\n self.details_filtered = textile_to_html( details )\n end",
"def create\n if params[:entry][:entry_metas_attributes].present?\n params[:entry][:entry_metas_attributes].replace(convert_entry_metas_attributes(params[:entry][:entry_metas_attributes]))\n end\n @entry = Entry.new(params[:entry])\n \n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to edit_admin_entry_path(@entry), notice: 'Entry was successfully created' }\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def share_description(value)\n raw(value).gsub(\"<br>\", \" \").gsub(\"<br />\", \" \")\n end",
"def add_news_to_entries\n doc = Nokogiri::HTML(open(@config[\"url\"]))\n # the bloody dynamic loading only gives me the first 10\n canonical = doc.xpath('//head/link[@rel=\"canonical\"]').first['href']\n @canonical = canonical\n\n doc.css('.block-content').take(@config[\"consume_top\"]).each do |item|\n link = item.css('h3.block-title>a').first\n next if @entries.any? {|e| e[:rel_href] == link['href']} # skip duplicate entries\n @entries << {\n title: link.content,\n reading_time: item.css('.readingTime').first.content,\n rel_href: link['href']\n }\n end\n end",
"def new_entry_attrs\n test_entry_attrs\n end",
"def handle_text(name, attrs)\n \n end"
] | [
"0.6827422",
"0.5886299",
"0.58785635",
"0.5751225",
"0.5726346",
"0.5726346",
"0.57228243",
"0.561852",
"0.5605897",
"0.5574541",
"0.5544793",
"0.5529843",
"0.55210596",
"0.54944944",
"0.5487143",
"0.54641396",
"0.5460121",
"0.5448047",
"0.5438285",
"0.5436883",
"0.543416",
"0.5414049",
"0.5406585",
"0.53753376",
"0.5367405",
"0.5367405",
"0.5367405",
"0.5367405",
"0.53632194",
"0.53569293",
"0.5344803",
"0.53436464",
"0.5329329",
"0.5304131",
"0.5294611",
"0.5294611",
"0.5289452",
"0.52811486",
"0.5270524",
"0.52654964",
"0.5260025",
"0.52546567",
"0.52443427",
"0.5242873",
"0.52384144",
"0.52130187",
"0.5202709",
"0.5197215",
"0.5194705",
"0.5189742",
"0.51876193",
"0.5186065",
"0.5183604",
"0.5183604",
"0.5178666",
"0.5177578",
"0.5176458",
"0.5176458",
"0.516194",
"0.5156605",
"0.5155131",
"0.51516694",
"0.51426387",
"0.51400644",
"0.5139452",
"0.5134321",
"0.51322526",
"0.51307726",
"0.5128508",
"0.5124191",
"0.51197237",
"0.51189363",
"0.5117566",
"0.5116063",
"0.51061046",
"0.5097426",
"0.50921553",
"0.5082835",
"0.50816715",
"0.5076893",
"0.5065811",
"0.50580376",
"0.50542563",
"0.50530463",
"0.50522053",
"0.504563",
"0.50444704",
"0.5044334",
"0.5031326",
"0.5027911",
"0.5027743",
"0.50276875",
"0.5023812",
"0.5022059",
"0.5016057",
"0.5007416",
"0.5006751",
"0.5006362",
"0.50028527",
"0.49981993",
"0.4995446"
] | 0.0 | -1 |
Distribute entry for all users subscribed to entries' feed | def distribute_to_feed_postboxes
self.feed.postboxes.each do |postbox|
self.distribute_to(postbox)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def associate_feed_entries\n feed_users = FeedUser.find_all_by_feed_id(self.feed_id)\n entry_list = []\n feed_users.each do |feed_user|\n feu = FeedEntryUser.new\n feu.feed_id = self.feed_id\n feu.feed_entry_id = self.id\n feu.user_id = feed_user.user_id\n entry_list.push(feu)\n end\n FeedEntryUser.import(entry_list)\n return true\n end",
"def index\n @feeds = current_user.subscriptions.ordered_by_title\n @entries = current_user.entries.for_user(current_user.id, @@per_page).paginate(page: params[:page], per_page: @@per_page).set_read_attribute\n @unread_entries_count = current_user.reads.where(read: false).count \n end",
"def publish!(entry)\n # no-op (for now)\n end",
"def subscribed\n super\n increase_current_users\n stream_from channel\n end",
"def broadcast\n user.followers.each do |follower|\n entry = TimelineEntry.new(user: follower, tweet: self).to_hash\n self.database.bulk_save_doc(entry)\n end\n self.database.bulk_save\n end",
"def add_entries(feed_entries)\n guids = entries.map(&:guid)\n feed_entries.reject {|e| guids.include? e.id}.each do |entry|\n entry.sanitize!\n entries.add(entry)\n end\n end",
"def push_to_all\n me_in_json = self.to_json\n followers = user.followers\n $redis.pipelined { followers.each { |u_id| $redis.lpush(\"feed:#{u_id}\", me_in_json) }}\n end",
"def feeds\n @user = current_user\n @subscribed_ids = @user.subscriptions.pluck(:feed_uid)\n end",
"def initial_unread_entries\n update unread_entries: feed.entries.count\n end",
"def backfill_subscriptions()\n empty_subscriptions = FeedSubscription.find(:all, :conditions => [\"caught_up = 0\"])\n empty_subscriptions.each do |feed_sub|\n if feed_sub.feed.user_id.nil?\n user = User.find(feed_sub.user_id)\n puts \"Populating new subscription to course feed id: #{feed_sub.feed_id} course: #{feed_sub.feed.course.title} for user id: #{user.id} #{user.display_name}\"\n user_feed_id = user.create_feed.id\n # This is a course feed. Find all items shared with the course and place that item in the user's feed.\n ItemShare.find_each(:batch_size => 2000, :conditions => [\"course_id = ?\", feed_sub.feed.course_id]) do |is|\n begin\n fitem = FeedsItems.find(:first, :conditions => [\"feed_id = ? and item_id = ?\", user_feed_id, is.item.id])\n if fitem.nil?\n FeedsItems.create(user_feed_id, is.item.id, is.item.created_at)\n end\n rescue\n # This is OK - a duplicate key violation\n end\n end\n\n feed_sub.caught_up = true\n feed_sub.save\n else\n # This is a user's feed.\n # TODO(mikehelmick): Implement catching up on a user's feed.\n # This will likely result in nothing, unless the other user has done a share w/ that user directly.\n puts \"Backfill to user feed not yet implemented.\"\n end\n end\n end",
"def add_subscription_entry(name, entry)\n\t\tend",
"def publish_to(*user_ids)\n @users_to_notify += user_ids\n end",
"def touch_subscriptions\n Rails.logger.info \"Touching subscription of user #{user_id} to feed #{feed_id}\"\n self.touch unless destroyed?\n if user.present?\n user.update subscriptions_updated_at: Time.zone.now\n folder = feed.user_folder user\n folder.update subscriptions_updated_at: Time.zone.now if folder.present?\n end\n end",
"def subscribe\n @entry.subscribers << current_user\n\n rescue ActiveRecord::StatementInvalid\n # ignore ... and just render nothing (this happens when user clicks too fast before getting previous update)\n render :nothing => true\n end",
"def subscription_mailer\n users_id = Subscription.where('category_id in (?)', self.categories.ids).distinct.pluck(:user_id)\n users_id.delete(self.user.id)\n if users_id.any?\n number_elements = ((users_id.size/25.to_f).round == 0 ? 1 : (users_id.size/25.to_f).round)\n users_id.each_slice(number_elements) {|array| UserMailer.delay.subscription(array, self.id) }\n end\n end",
"def all_people_scheduled\n Entry.users_for_client(self.id)\n end",
"def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end",
"def fetch_urls_from_feedly\n yaml = YAML.load_file('env.yaml')\n client = Feedlr::Client.new(oauth_access_token: yaml['account']['feedly']['access_token'])\n client.user_subscriptions.map{|m|\n # puts m.id\n hotentries = client.stream_entries_contents(m.id, :count => 5 ).items\n return hotentries\n };\nend",
"def publish_to_users\n data = { users: users }.merge!(payload)\n client.post('publishes/users', data)\n end",
"def add_to_feeds( feed_item, achievement )\n feed_item.user = achievement.creator\n feed_item.referenced_model = achievement\n feed_item.save!\n\n achievement.group.feed.add_feed_item( feed_item )\n # achievement.creator.feed.add_feed_item( feed_item )\n achievement.group.users.each { |user| user.feed.add_feed_item( feed_item ) } # add to each feed item for members of the group\n end",
"def add_to_feeds( feed_item, membership )\n feed_item.user = membership.user\n feed_item.referenced_model = membership.group\n feed_item.save!\n membership.group.feed.add_feed_item( feed_item )\n membership.user.feed.add_feed_item( feed_item )\n membership.group.users.each { |user| user.feed.add_feed_item( feed_item ) } # add to each feed item for members of the group\n end",
"def add_weiner_twitter_feeds\n\tWeiner.get.each do |twitter_results|\n\n\tend\nend",
"def index_all\n # If feed subscriptions have not changed, return a 304\n if stale? etag: EtagCalculator.etag(current_user.subscriptions_updated_at),\n last_modified: current_user.subscriptions_updated_at\n @folder = nil\n @feeds = current_user.subscribed_feeds include_read: @include_read, page: params[:page]\n index_feeds\n end\n end",
"def regenerate_feed!\n user_set = active_followed_users + [@user.id]\n\n stories = Story.for_user(@user).order('updated_at DESC').where(user_id: user_set).includes(:user, :target, :substories).limit(FRESH_FETCH_SIZE)\n stories.each {|story| add! story }\n end",
"def rt_update\n Realtime::Publisher.instance.batch_update all_members\n end",
"def subscribed_friends_and_me(pack)\n friends = self.friends.registered.all + [self]\n join_users_to_pack_user_links_and_sort(friends, pack)\n end",
"def subscribed_friends(pack)\n friends = self.friends.registered.all\n join_users_to_pack_user_links_and_sort(friends, pack)\n end",
"def update_weekly_happiness_distributions! \n HappinessEntry.beginning_of_week_days.each do |beginning_of_week_day|\n uid = uid_for_week(beginning_of_week_day)\n end_of_week_day = beginning_of_week_day.end_of_week\n entries_for_week = HappinessEntry.in_week(beginning_of_week_day, end_of_week_day)\n update_happiness_distribution! uid, :week, entries_for_week \n end\n end",
"def subscribe_all\n # Get an array of all the email addresses accociated with this devise class.\n emails = all.map(&:email).select {|e| Devise::Models::Campaignable.valid_campaign_email? e}\n\n # Ask the list managed to subscibe all of these emails.\n list_manager.batch_subscribe(emails)\n end",
"def mark_unread_entries(feed_subscription)\n feed = feed_subscription.feed\n feed.entries.find_each do |entry|\n if !EntryState.exists? user_id: self.id, entry_id: entry.id\n entry_state = self.entry_states.create! entry_id: entry.id, read: false\n end\n end\n end",
"def perform\n entries.each do |entry|\n @items << generate_item(entry)\n end\n add_ids\n end",
"def add_to_feeds( feed_item, user_achievement )\n feed_item.user = user_achievement.user\n feed_item.referenced_model = user_achievement\n feed_item.save!\n\n user_achievement.achievement.group.feed.add_feed_item( feed_item )\n user_achievement.achievement.group.users.each { |user| user.feed.add_feed_item( feed_item ) } # add to each feed item for members of the group\n end",
"def sync\n prizes = params[:prizes]\n users = params[:users]\n if prizes\n prizes.each do |entry|\n entry = entry[1]\n @entry = Entry.find_or_create_by_id(entry['id']);\n logger.debug(\"entry remote id #{entry['created_at']}\")\n @entry.update_attributes({:delivered => entry['delivered']})\n end\n\n end\n if users\n users.each do |entry|\n entry = entry[1]\n @entry = User.find_or_create_by_id(entry['id']);\n logger.debug(\"entry remote id #{entry['created_at']}\")\n @entry.update_attributes({:laps => entry['laps']})\n end\n end\n\n end",
"def get_all_entries\n @feed_entries = FeedEntry.find(:all, :conditions => { :person_id => self.id}, :order => 'published_at DESC')\n end",
"def send_to_all\n User.newsletters_allowed.each do |user|\n UserMailer.delay.new_newsletter(user, self)\n end\n end",
"def xml_feed_entries(feed_url, locale, offset)\r\n p \"Feed #{feed_url}\"\r\n doc = Nokogiri::XML(open(feed_url))\r\n doc.xpath(\"//item\").count.times do |n|\r\n \r\n # process dates\r\n sdt = DateTime.parse(doc.xpath(\"//item//xCal:dtstart\")[n].text) rescue nil\r\n edt = doc.xpath(\"//item//xCal:dtend\")[n].text\r\n edt.blank? ? enddt = sdt.advance(:hours => 2) : enddt = DateTime.parse(edt)\r\n \r\n # get event title and url\r\n etitle = doc.xpath(\"//item//title\")[n].text.split(' at ')[0]\r\n url = doc.xpath(\"//item//link\")[n].text \r\n sid = doc.xpath(\"//item//id\")[n].text \r\n\r\n # get county based on coordinates\r\n lat = doc.xpath(\"//item//geo:lat\")[n].text\r\n lng = doc.xpath(\"//item//geo:long\")[n].text\r\n county = Schedule.chk_geocode(lat, lng) rescue nil\r\n \r\n # add only current events \r\n if sdt >= Date.today\r\n \r\n # find correct channel and location\r\n cid = LocalChannel.select_channel(etitle, county, locale).flatten 1\r\n# cid.map {|channel| p \"Channel: #{channel.channelID}\" }\r\n\r\n # add event to calendar\r\n cid.map {|channel| add_event(doc, n, sid, etitle[0..199], sdt, enddt, channel.channelID, url, offset)} if cid\r\n# add_event(doc, n, sid, etitle[0..199], sdt, enddt, cid[0].channelID, url, offset) if cid\r\n end\r\n end \r\n end",
"def entries\n if @entries.nil?\n raw_entries = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.root_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\",\n \"story\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"story\"\n ])\n ])\n\n # create the individual feed items\n @entries = []\n unless raw_entries.blank?\n for entry_node in raw_entries.reverse\n new_entry = FeedItem.new\n new_entry.feed_data = entry_node.to_s\n new_entry.feed_data_type = self.feed_data_type\n new_entry.root_node = entry_node\n if new_entry.root_node.namespace.blank?\n new_entry.root_node.add_namespace(self.root_node.namespace)\n end\n @entries << new_entry\n end\n end\n end\n \n # Sort the items\n if self.configurations[:entry_sorting_property] == \"time\"\n @entries = @entries.sort do |a, b|\n (b.time or Time.utc(1970)) <=> (a.time or Time.utc(1970))\n end\n elsif self.configurations[:entry_sorting_property] != nil\n sorting_property = self.configurations[:entry_sorting_property]\n @entries = @entries.sort do |a, b|\n eval(\"a.#{sorting_property}\") <=> eval(\"b.#{sorting_property}\")\n end\n else\n return @entries.reverse\n end\n return @entries\n end",
"def entries\n Entry.where(:feed_id => pk)\n end",
"def add_entries(entries, entry_id)\n entries.each do |entry|\n data = ::RssFeedDatum.where(url: entry.url).first_or_create(rss_feed_keyword_id: entry_id, guid: entry.id, name: entry.title, published_at: entry.published, blurb: get_html_content(\"#{entry.url}\"))\n end\n end",
"def update_daily_happiness_distributions! \n HappinessEntry.dates.each do |date|\n uid = uid_for_day(date)\n entries_for_date = HappinessEntry.on_date(date)\n update_happiness_distribution! uid, :day, entries_for_date \n end\n end",
"def subscribe_owner\n\t subscription = owner.subscribe_to(activity_feed)\n\t subscription.save\n\t end",
"def gather_feed_items(user = nil)\n if user\n # Notes left on your posts and pictures\n notes_on_your_posts = []\n\n user.posts.each do |post|\n notes_on_your_posts = smush(notes_on_your_posts, post.notes)\n post.pictures.each do |picture|\n notes_on_your_posts = smush(notes_on_your_posts, picture.notes)\n end\n end\n\n # Notes left by people the current user is following\n notes_left_by_followees = []\n\n # Notes left on posts owned by people the current user is following\n notes_left_on_followees_posts = []\n\n # Notes left on pictures owned by people the current user is following\n notes_left_on_followees_pictures = []\n\n # Posts created by people the current user is following\n posts_by_followees = []\n\n # Followings of people the current user is following\n following_followees = []\n\n # People the current user is following, following other people\n followees_following = []\n\n user.followees.each do |followee|\n posts_by_followees = smush(posts_by_followees, followee.posts)\n notes_left_by_followees = smush(notes_left_by_followees, followee.notes)\n\n followee.posts.each do |post|\n notes_left_on_followees_posts = smush(notes_left_on_followees_posts, post.notes)\n post.pictures.each do |picture|\n notes_left_on_followees_pictures = smush(notes_left_on_followees_pictures, picture.notes)\n end\n end\n\n following_followees = smush(following_followees, Follow.find_all_by_followee_id(followee.id, :conditions => \"follower_id <> #{user.id}\"))\n followees_following = smush(followees_following, Follow.find_all_by_follower_id(followee.id, :conditions => \"follower_id <> #{user.id}\"))\n end\n\n # Remove totally blank posts from feed\n posts_by_followees.each do |post|\n if post.title.blank? and post.content.blank? and post.pictures.length == 0\n posts_by_followees.delete(post)\n end\n end\n blavel_posts = User.find_by_login('blavel') ? User.find_by_login('blavel').posts : nil\n posts = smush(posts_by_followees, blavel_posts)\n if posts\n posts = posts.uniq\n end\n\n # Remove notes left by logged in user\n notes = smush(notes_on_your_posts, notes_left_by_followees, notes_left_on_followees_posts, notes_left_on_followees_pictures)\n notes.each do |note|\n if note.user == user\n notes.delete(note)\n end\n end\n notes = notes.uniq\n\n # Add together follows\n following_you = Follow.find_all_by_followee_id(user.id)\n follows = smush(following_you, following_followees, followees_following)\n follows = follows.uniq\n else\n # If no user is specified, return all feed items\n notes = Note.find(:all)\n posts = Post.find(:all)\n follows = Follow.find(:all)\n\n # Remove totally blank posts from feed\n posts.each do |post|\n if post.title.blank? and post.content.blank? and post.pictures.length == 0\n posts.delete(post)\n end\n end\n end\n\n feed_items = smush(notes, posts, follows)\n feed_items.sort! { |x,y| y.created_at <=> x.created_at }\n feed_items = feed_items[0..19]\n\n return feed_items\n end",
"def push_to_lists_and_feeds\n add_to_stories_lists\n pushed_user_ids = add_to_friend_feeds\n pushed_user_ids\n end",
"def subscribe(url)\n subscribed_feed = UrlSubscriber.subscribe url, self\n end",
"def index\n @broadcaster_social_entries = Broadcaster::SocialEntry.all\n end",
"def subscribe_teachers\n self.indicated_teachers.each do |teacher|\n self.subscriptions.create user_id: teacher.id\n end\n end",
"def update_all_feeds\n Feed.all.each do |feed_entry|\n begin\n feed = Feedzirra::Feed.fetch_and_parse(feed_entry.feed_url)\n rescue Exception => e\n Rails.logger.error \"Feedzirra threw an error on feed_entry #{feed_entry.id}: #{e.inspect}\"\n end\n if !feed.blank? && !feed.is_a?(Fixnum) && !feed.entries.blank?\n feed.entries.each do |entry|\n begin\n entry.summary = @html_sanitizer.sanitize(entry.summary) unless entry.summary.blank?\n next if entry.title.blank? || entry.summary.blank? || entry.url.blank? || entry.id.blank? || entry.published.blank?\n guid = Base64.urlsafe_encode64(OpenSSL::Digest::MD5.digest(entry.id))\n unless FeedEntry.exists?(guid: guid)\n FeedEntry.create(title: clean_string(entry.title), summary: clean_string(entry.summary), url: clean_string(entry.url), published_at: entry.published, guid: guid, fetched: false)\n end\n rescue Exception => e\n Rails.logger.error \"Caught an error on inserting feed_entry #{entry.id}: #{e.inspect}\"\n end\n end\n end\n end\n end",
"def index\n #body, ok = SuperfeedrEngine::Engine.retrieve(Feed.first) \n @entries = Entry.all\n end",
"def add_first_users_to_stream(client, twitter_ids)\n log(\"Adding #{twitter_ids.length} user(s) to stream: #{twitter_ids}\")\n\n # We can add up to 100 users when we first create the stream.\n client.sitestream(twitter_ids.slice!(0,100)) do |hash|\n if hash[:message][:direct_message]\n log(\"DM received: #{hash[:message][:direct_message][:sender_id]} to #{hash[:message][:direct_message][:recipient_id]}\")\n # We get DMs the user has both sent and received.\n # We only want the ones they've received.\n if hash[:for_user] == hash[:message][:direct_message][:recipient_id]\n bergcloud.direct_message(\n ::Twitter::DirectMessage.new(hash[:message][:direct_message]))\n end\n end\n end\n\n # Users 101-1000 must be added invidiually.\n # We can only add up to 25 extra users per second to a stream.\n timer = EventMachine.add_periodic_timer(0.04) do\n if id = twitter_ids.shift\n add_user_to_client(client, id)\n else\n timer.cancel\n end\n end\n\n return client\n end",
"def notify_and_share_admins\n mentioned_admins.each do |mentioned|\n # Here put email \n entry = self.library_entries.create(sender_id: self.admin.id, receiver_id: mentioned.id, admin_library_id: mentioned.library.id, shared: true)\n if entry.valid?\n Notification.create(recipient: mentioned, actor: self.admin, action: \"shared\", notifiable: self)\n end\n end\n end",
"def create_feed_item\n feed_item = FeedItem.create(:item => self)\n owner.feeds.create(:feed_item_id => feed_item.id, :is_public => true)\n notifiers = [] + owner.followers\n notifiers += [event.owner]\n notifiers.uniq!\n notifiers.each{|p| p.feeds.create(:feed_item_id => feed_item.id, :is_public => false)}\n end",
"def show\n @entries = @feed.entries.for_user(current_user.id, @@per_page).paginate(page: params[:page], per_page: @@per_page).set_read_attribute\n @unread_entries_count = @feed.entries.for_user(current_user.id,nil).where(reads: {read: false}).count\n end",
"def index\n @user_entries = UserEntry.all\n end",
"def index\n @user_entries = UserEntry.all\n end",
"def create\n \n object = params[:object]\n entry = params[:entry]\n\n unless object && entry \n raise IOError, \"Incorrect params for fb subscription updates\"\n end\n\n user_fb_ids = entry.map{|permission| permission['uid']} \n users = User.find_all_by_fb_user_id(user_fb_ids)\n users = users.select do |user| \n user.visited_at && user.visited_at > 30.days.ago \n end\n \n if object == 'user'\n users.each do |user|\n ProcessingQueue.push(\n UserDelayedObserver,\n :mine_fb_data,\n user) \n end \n end\n\n rescue => ex\n handle_exception(ex)\n ensure\n respond_to do |format|\n format.json\n end\n end",
"def unsubscribe\n @entry.subscribers.delete(current_user)\n end",
"def set_user_feed\n @feed = current_user.subscriptions.find(params[:id])\n end",
"def create\n @entry = current_user.entries.build(entry_params)\n if @entry.save\n flash[:success] = \"Entry created!\"\n redirect_to root_url\n else\n @feed_items = []\n render 'static_pages/home'\n end\n end",
"def index\n @user_feeds = UserFeed.find_all_by_user_id(current_user.id)\n end",
"def collect_all_entries\n person = Person.find(params[:id])\n Delayed::Job.enqueue(CollectAllFeedEntriesJob.new(person.id))\n\n respond_to do |format|\n format.js do\n render :update do |page|\n flash[:notice] = 'FeedEntries will be collected. Around ' + person.statuses_count.to_s + ' Feed entries will be gathered.'\n page.reload\n end\n end\n end\n end",
"def update_subscriber_list\n @mandrill = Mandrill::API.new 'nDSi_tYPhOy6QpG8Kn_lqg'\n @subscriber_list = User.where(isSubscribed: true)\n end",
"def index\n @project = Project.find(params[:project_id])\n \n #depending if I am showing all entries or only the persons entries.\n @count = 0\n if params[:person_id] == nil\n @show_all = true\n @feed_entries = []\n @grouped_entries = []\n @grouped_by_hashtags = {}\n @grouped_by_replies = {}\n @grouped_urls = {}\n @feed_entries_count = @project.feed_entries_count\n @feed_entries = @project.feed_entries(1000).paginate :page => params[:page]\n \n \n #Get a distribution of collected tweets per person.\n @feed_entries_pp = {}\n @project.persons.each do |person|\n key = (FeedEntry.count(:conditions => \"person_id = #{person.id}\") / 100).to_i*100\n begin\n @feed_entries_pp[key] += 1\n rescue\n @feed_entries_pp[key] = 1\n end \n end\n @feed_entries_pp = @feed_entries_pp.sort{|a,b| a <=> b}\n\n @retweets_distr = {}\n @project.persons.each do |person| \n person.feed_entries.each do |f| \n key = f.retweet_count.to_i \n if key > 0\n begin\n @retweets_distr[key] += 1\n rescue\n @retweets_distr[key] = 1\n end\n end\n end\n end\n @retweets_distr = @retweets_distr.sort{|a,b| a <=> b}\n\n else \n @person = Person.find(params[:person_id])\n @feed_entries_count = @person.feed_entries.count\n @feed_entries = @person.feed_entries.paginate :page => params[:page], :order => 'updated_at DESC' \n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feed_entries }\n end\n end",
"def poll_registrations\n log(\"Polling registrations\")\n em_redis.blpop('twitterpush:new', 0).callback do |list, new_id|\n if twitter_id = twitter_store.get_twitter_id(new_id)\n streamer.add_user(twitter_id)\n end\n EventMachine.next_tick {\n poll_registrations\n }\n end\n end",
"def calculate_recipients\n # TODO (Step 3) - Fix, not working\n SUBSCRIBERS.filter do |email|\n !UNSUBSCRIBED.include?(email)\n end\nend",
"def merge_entries! other_feed\n other_feed.each do |entry|\n # TODO: add atom:source elements\n self << entry\n end\n end",
"def feed_items\n feed_item\n end",
"def index\n people_in_feed = current_user.feed_list\n @posts = Post.where(user: people_in_feed)\n end",
"def send_emails\n self.attendees.distinct.each do |attendee|\n UpdatesMailer.updates_mail(attendee, self).deliver_now\n end\n end",
"def feed\n\n out = {\n chats: [],\n notes: []\n }\n\n users = self.swap.to_a\n\n out[:chats] = self.chats\n\n unless users.empty?\n\n users.each do |user|\n if user.id != self.id # Swap returs itself also!\n # Find notification that are pointed to user\n note = Note.first(conditions: {:to_id => self.id, :from_id => user.id})\n out[:notes] << note unless note.nil?\n end\n end\n\n # Fix order\n unless out[:notes].empty?\n out[:notes].sort_by!(&:created_at).reverse!\n\n out[:notes].map! do |note|\n found_user = users.select{ |user_p| user_p.id == note.from_id }.first\n \n unless found_user.nil?\n found_user.define_singleton_method :notified_at do\n note.created_at \n end\n found_user.define_singleton_method :stamp do\n note.stamp\n end\n end\n\n found_user\n end\n end\n end\n\n out\n end",
"def feed_entries(feed, include_read: false, page: nil)\n EntriesPagination.feed_entries feed, self, include_read: include_read, page: page\n end",
"def twitter_scan_and_repost(connect, user)\n connect.updates.each do |u|\n# puts \"Checking the content for ublog: '#{u[:content]}'\"\n if ((u[:from] == user.twitter_name) and (hash_ublog? u[:content]))\n# puts \"Got a #ublog message from #{u[:from]}\"\n blog = Blog.new(:home_id => user.id, :content => u[:content][0..139],\n :source => \"Twitter\", :in_solr => 1)\n add_blog_to_ublog(blog, user)\n end\n end\n end",
"def subscribed; end",
"def subscriptions; end",
"def subscriptions; end",
"def subscriptions; end",
"def create_feed_item\n feed_item = FeedItem.create(:item => self)\n owner.feeds.create(:feed_item_id => feed_item.id, :is_public => true)\n notifiers = [] + owner.followers\n notifiers += lesson.watchers\n notifiers -= [owner]\n notifiers.uniq!\n notifiers.each{|p| p.feeds.create(:feed_item_id => feed_item.id, :is_public => false)}\n end",
"def share(users)\n users.each do |user|\n f = user.friend_feed.build(friend_id: current_user, post_id: params[:post_id])\n f.save\n end\n end",
"def perform\n self.subscriptions.each do |blog| \n begin\n blog.find_twitterers\n rescue Exception => whoops\n puts \"Error on blog #{blog.title}: \" + whoops\n end\n end\n # +++ sub name of host.\n # +++ page will have to deal with unauthenticated user.\n puts \"Sending direct message to #{tname}\"\n twitter_direct_message(\"Your blogs have been processed: http://twitlines.net/blogs\")\n end",
"def fetch_entries\n entries.inject([]){ |all, entry| all << entry << addendas[entry] }.flatten.compact\n end",
"def feed\n # defer to Micropost.from_users_followed_by\n Micropost.from_users_followed_by(self)\n end",
"def fetch!\n parsed_feed = FeedNormalizer::FeedNormalizer.parse open(self.feed_url)\n \n self.update_attributes( :title => parsed_feed.title,\n :url => parsed_feed.url\n #:etag => parsed_feed.etag\n #:last_modified => parsed_feed.last_modified\n )\n \n parsed_feed.entries.each do |entry|\n self.entries.create(:url => entry.url,\n :title => entry.title,\n :author => entry.author,\n #:summary => entry.summary,\n :content => entry.content\n #:published => entry.published\n #:categories => entry.categories\n ) if !Entry.find_by_url(entry.url)\n end\n end",
"def feed_to\n @feed_to_users ||= [self] | self.friends | self.followers # prevent duplicates in the array\n end",
"def index\n @user_to_channel_subscriptions = UserToChannelSubscription.all\n end",
"def create_entries_for_user(_user)\n entries = []\n (0..30).each do |_number|\n entries << EntryBuilder.new(number).entry\n end\n end",
"def demo1\n @feed_entries = []\n \n (4..7).each do |channelnum|\n json_str = Net::HTTP.get(URI.parse(\"http://\" + THINGSPEAK_SERVER + \"/channels/#{channelnum}/feed.json?results=5\"))\n parsed_hash = ActiveSupport::JSON.decode(json_str)\n parsed_hash[\"feeds\"].each do |e|\n entry = {}\n t = Time.strptime(e[\"created_at\"], \"%FT%T%z\")\n entry[\"time\"] = t\n entry[\"created_at\"] = t.strftime(\"%H:%M\")\n entry[\"field1\"] = e[\"field1\"].to_i\n entry[\"field2\"] = e[\"field2\"]\n @feed_entries.push(entry)\n end\n end\n @feed_entries.sort! { |a,b| b[\"time\"] <=> a[\"time\"] }\n end",
"def subscribe_author\n self.subscriptions.create user_id: self.user.id\n end",
"def argument_daily_digest\n subscriptions = Subscription.find(:all , :conditions => ['status = 1 && daily_digest = 1 && argument_id is not null'])\n subscriptions.each do |sub|\n Mailers::Debate.deliver_send_subscription_email(\"\",sub.argument,sub,HOST_DOMAIN)\n end\n end",
"def getAllUserFeed(userID)\n i = 0\n feed = Array.new\n feed[i] = getUserProfileFeed(userID, 0, 0)\n count = feed[i][\"count\"]\n i += 1\n while count > 0\n feed[i] = getUserProfileFeed(userID, feed[i-1][\"last_document_id\"], feed[i-1][\"last_event_id\"])\n count = feed[i][\"count\"]\n i += 1\n end\n feed\n end",
"def index\n @feed_entries = FeedEntry.all\n end",
"def send_new_entry(entry, current_user)\n @greeting = \"Hi\"\n #@current_user = current_user.entries\n @entry = entry\n\n mail to: '[email protected]',\n \t\tfrom: current_user.email,\n \t\tsubject: 'Door-to-Door Donations Confirmation'\n end",
"def collect_all_project_entries\n @project = Project.find(params[:id])\n total_entries = 0\n \n puts \"Analyzing \" + @project.name.to_s + \" with \" + @project.persons.count.to_s + \" persons.\" \n \n @project.persons.each do |person|\n if person.private == false\n if person.statuses_count > 3200\n total_entries = total_entries + person.statuses_count - 3200\n else\n total_entries = total_entries + person.statuses_count\n end\n end\n Delayed::Job.enqueue(CollectAllFeedEntriesJob.new(person.id)) \n end \n \n respond_to do |format|\n flash[:notice] = total_entries.to_s + ' feed entries of the ' + @project.persons.count.to_s + ' people on this project will be collected. Please give it some time to finish.'\n format.js do\n render :update do |page| \n page.reload\n end\n end\n end \n end",
"def run\n local_only_uids = serializer.uids - folder.uids\n return if local_only_uids.empty?\n\n serializer.filter do |message|\n !local_only_uids.include?(message.uid)\n end\n end",
"def handle_notify_event(event, is_being_published)\n event.users.each do |user|\n I18n.with_locale(user.get_locale) do\n status = EventStatus.find_by(user_id: user.id, event_id: event.id)\n if !status.blank? && !status.not_attending?\n if is_being_published\n send_publish_event_notification(event, user, status)\n else\n send_delete_event_notification(event, user)\n end\n end\n end\n end\n end",
"def email\n # redirect to the first page of the website\n redirect_to login_path\n\n # Get all users who subscribe\n users = User.where(subscribe: true)\n\n # Get mandril object\n mandrill = Mandrill::API.new 'SyKEz-QytC97dIODlvKQoQ'\n\n # Send a digest to each user\n users.each do |user|\n # Set the elementary content string\n content = \"Here is the list of interesting articles for you\\n\\n\"\n\n # Get all the interesting articles and order by date_time\n articles = Article.tagged_with(user.interest_list, any: true).order(date_time: :desc)\n\n # Get at most 10 new interesting articles\n num = 0\n articles.each do |article|\n # If 10 interesting articles are already extracted, break the loop\n break if num >= MAX_NUM_ARTICLES\n\n # If this article has not been sent to this user, include this to digest\n unless user.articles.include?(article)\n user.articles << article\n # Update content string\n content += make_paragraph(article.title, article.link)\n num += 1\n end\n end\n\n # If there is no interesting article\n if num == 0\n content = \"There is no any new interesting articles for you this time.\\n\"\n end\n\n # create a message to send\n message = {\n subject: 'Hello, ' + user.first_name + '. This is the digest you required',\n from_name: 'The Digest',\n text: content,\n to: [\n {\n email: user.email,\n name: user.first_name + ' ' + user.last_name\n }\n ],\n from_email: '[email protected]'\n }\n\n # send the email\n mandrill.messages.send message\n end\n end",
"def set_cheerers\n @cheerers = @entry.cheering_users.limit(10)\n end",
"def feed\n\t\tMicropost.where(\"user_id IN (?) OR user_id = ?\", following_ids, id)\n \n\tend",
"def create\n @limit = false\n set_current_tags\n params[:entry][:tag_ids] = Tag.process_tag_names(params)\n @entry = current_user.create_entry(params[:entry])\n \n if @entry == nil\n @limit = true\n flash.now[:alert] = \"Unable to create any more hackrLog() entries for this account. Upgrade to <a href='#{url_for(edit_hacker_url(current_user.id))}'>hackrLog() Premium</a> to remove this limit.\".html_safe\n end\n \n if current_user.subscription.at_limit?\n @limit = true\n flash.now[:alert] = \"You have reached the entry limit for a free account. Upgrade to <a href='#{url_for(edit_hacker_url(current_user.id))}'>hackrLog() Premium</a> to remove the limit.\".html_safe\n end\n \n respond_to do |format|\n format.html { redirect_to entries_url }\n format.js\n format.json { render json: @entry, status: :created, location: @entry }\n end\n end",
"def feed\n Post.where(\"user_id IN (?) OR user_id = ?\", friend_ids, id).feed\n end",
"def publish (workitem)\n synchronize do\n filename = \"work/atom_#{workitem.participant_name}.xml\"\n f = File.open(filename, \"w\")\n f << @feed.to_s\n f.close()\n end\n end",
"def feed\n FeedItem.from_users_followed_by(self)\n end"
] | [
"0.6506629",
"0.6101022",
"0.6036367",
"0.5999645",
"0.59847975",
"0.5864682",
"0.58420336",
"0.5826251",
"0.58260345",
"0.5805036",
"0.57635134",
"0.5740913",
"0.57036173",
"0.569269",
"0.56819063",
"0.5669513",
"0.5654116",
"0.5613711",
"0.5607827",
"0.5589152",
"0.5563618",
"0.5559505",
"0.55354255",
"0.5510717",
"0.5506554",
"0.5503772",
"0.5500821",
"0.549734",
"0.5471189",
"0.5470839",
"0.54688597",
"0.5465817",
"0.54496884",
"0.54393786",
"0.54345953",
"0.54282504",
"0.5396118",
"0.5392193",
"0.5389316",
"0.538406",
"0.536293",
"0.5352467",
"0.53381526",
"0.53331393",
"0.53219795",
"0.5308315",
"0.5303501",
"0.5291202",
"0.5260472",
"0.52437055",
"0.52435464",
"0.5243059",
"0.524225",
"0.524225",
"0.5240331",
"0.52233523",
"0.52126086",
"0.52110916",
"0.5209088",
"0.51780885",
"0.5155756",
"0.5152583",
"0.5142638",
"0.5135627",
"0.5132776",
"0.5132427",
"0.51198804",
"0.51131344",
"0.51013917",
"0.5098512",
"0.5091865",
"0.5088395",
"0.5083262",
"0.5083262",
"0.5083262",
"0.5073511",
"0.50716364",
"0.5056234",
"0.5049449",
"0.50421256",
"0.50419796",
"0.5036244",
"0.503187",
"0.50234365",
"0.5019215",
"0.5010209",
"0.5006647",
"0.49948812",
"0.4993591",
"0.4992815",
"0.49838442",
"0.49814385",
"0.49762157",
"0.497164",
"0.4971625",
"0.49640328",
"0.49622568",
"0.49564365",
"0.4942157",
"0.49399266"
] | 0.5830821 | 7 |
Distribute entry to the pending leaflet for specified user | def distribute_to(postbox)
leaflet = postbox.find_or_create_active_leaflet
leaflet.entries << self unless leaflet.entries.exists? self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def itemized_stash_data(users)\n user = users.first\n # enable stash for the user?\n end",
"def add_stash_to_all_users\n add_stash_to_all_users_link.click\n end",
"def raffle_entry user\n @user = user\n\n mail to: \"[email protected]\"\n end",
"def update_user(user)\n @users[user]=Hash.new if !@users[user]\n \n vmpool=OpenNebula::VirtualMachinePool.new(@client, user)\n vmpool.info\n \n one_ids=vmpool.map {|vm| vm.id }\n vms=@users[user]\n user_ids=vms.keys\n \n deleted_vms=user_ids-one_ids\n added_vms=one_ids-user_ids\n \n deleted_vms.each {|vmid| vms.delete(vmid) }\n \n added_vms.each do |vmid|\n vm=OpenNebula::VirtualMachine.new(\n OpenNebula::VirtualMachine.build_xml(vmid), @client)\n vm.info\n \n usage=VmUsage.new(vm['TEMPLATE/CPU'].to_f,\n vm['TEMPLATE/MEMORY'].to_i)\n vms[vmid.to_i]=usage\n end\n end",
"def insert_key_data_for_user(d)\n if d['name'] == 'pivotal' && config[:skip_pivotal]\n ui.warn \"Skipping pivotal user.\"\n return\n end\n ui.msg \"Updating key data for user[#{d['name']}]\"\n new_id = if config[:skip_ids]\n db[:users].where(:username => d['name']).first[:id]\n else\n d['id']\n end\n Chef::Log.debug(\"Found user id for #{d['name']}: #{new_id}\")\n upsert_key_record(key_record_for_db(d, new_id))\n end",
"def send_new_entry(entry, current_user)\n @greeting = \"Hi\"\n #@current_user = current_user.entries\n @entry = entry\n\n mail to: '[email protected]',\n \t\tfrom: current_user.email,\n \t\tsubject: 'Door-to-Door Donations Confirmation'\n end",
"def add_new_itemized_users(users)\n user = users.first\n\n unless user.user_group.nil?\n user_group_select.type_text(user.user_group)\n page.driver.execute_script(\"document.querySelector('img[alt=\\\"Search-button-icon\\\"]').click()\")\n wait_until { !loading_img.visible? }\n find(:xpath,\"//li[text()='#{user.user_group}']\").click unless user.user_group == ''\n wait_until {!(find(:xpath, \"//li[text()='#{user.user_group}']\").visible?) }\n end\n\n # name/email section\n nu_name_tb.type_text(user.name) unless user.name.nil?\n nu_email_tb.type_text(user.email) unless user.email.nil?\n # quota/device section\n nu_devices_server_tb.type_text(user.devices_server) unless user.devices_server.nil?\n nu_quota_server_tb.type_text(user.quota_server) unless user.quota_server.nil?\n nu_devices_desktop_tb.type_text(user.devices_desktop) unless user.devices_desktop.nil?\n nu_quota_desktop_tb.type_text(user.quota_desktop) unless user.quota_desktop.nil?\n\n unless user.enable_stash.nil?\n if user.enable_stash.downcase.eql?('yes')\n nu_enable_stash_cb.check\n else\n nu_enable_stash_cb.uncheck\n end\n end\n\n # default quota for stash?\n unless user.stash_quota.nil?\n if user.enable_stash.downcase.eql?('yes')\n if user.stash_quota.downcase.eql?('default')\n #its default\n else\n nu_stash_quota_tb.type_text(user.stash_quota) unless user.stash_quota.nil?\n end\n else\n end\n end\n\n # send stash invite emails?\n unless user.send_invite.nil?\n if user.send_invite.downcase.eql?('yes')\n nu_send_stash_inv_cb.check\n else\n nu_send_stash_inv_cb.uncheck\n end\n end\n\n # finishing up\n nu_create_btn.click\n #wait_until_bus_section_load\n end",
"def processUserGem(args, successMsg='Successed', failMsg='Failed', &block)\n args.push('--user-install')\n processStartCmds(GemCmd.locCmds + args, successMsg, failMsg, &block)\n end",
"def add_user_ban(data); end",
"def add_user_ban(data); end",
"def add_guts(user, item)\n return\n end",
"def set_entry\n @user = Entry.find(params[:id])\n end",
"def stash_user_file(file,path)\n users = get_all_over500_users\n users.each_key do |u|\n puts \"copying files to #{u}\\'s home at #{path}.\"\n system \"ditto -V #{file} #{get_homedir(u)}/#{path}/#{File.basename(file)}\"\n FileUtils.chown_R(\"#{u}\", nil, \"#{get_homedir(u)}/#{path}/#{File.basename(file)}\")\n end\n end",
"def display_map\n puts \"--------------#{current_user.inspect}\"\n end",
"def set_user_entry\n @user_entry = UserEntry.find(params[:id])\n end",
"def set_user_entry\n @user_entry = UserEntry.find(params[:id])\n end",
"def add user, pin = nil\n command = aqhbci <<-CMD\n adduser \\\n --tokentype=#{user.tokentype} \\\n --context=#{user.context} \\\n --bank=#{user.bank} \\\n --user=#{user.userid} \\\n --server=#{user.server} \\\n --username=#{user.name} \\\n --hbciversion=#{user.hbciversion}\n CMD\n stdin, stdout, stderr, wait_thr = Open3.popen3(command.strip)\n success = wait_thr.value.success?\n\n if pin && success\n with_secure_pin user, pin do |f|\n sysid_command = aqhbci(\"getsysid --user=#{user.userid}\", \"--pinfile=#{f.path.strip}\").strip\n stdin, stdout, stderr, wait_thr = Open3.popen3(sysid_command)\n wait_thr.join\n success = success && wait_thr.value.success?\n end\n end\n return success\n end",
"def add_user_permission(u)\n\t\t\n\tend",
"def post_process(user, assume_user_exists=false)\n\n user.update_user_organization_filters unless Rails.application.config.try(:user_organization_filters_ignored).present?\n\n\n if user.has_role?(:manager) && user.organization_ids.include?(HighwayAuthority.first.id)\n user.viewable_organizations = Organization.all\n else\n user.viewable_organizations.clear\n user.viewable_organizations << HighwayAuthority.first\n\n user.organizations.each do |org|\n user.viewable_organizations << org unless user.viewable_organization_ids.include? org.id\n if org.organization_type.class_name == 'HighwayConsultant'\n typed_org = Organization.get_typed_organization(org)\n typed_org.highway_consultants.each do |consultant|\n user.viewable_organizations << consultant unless user.viewable_organization_ids.include? consultant.id\n end\n end\n end\n end\n user.save!\n\n UserMailer.send_email_on_user_creation(user).deliver unless assume_user_exists\n end",
"def assign_user_id(user_id, cluster_name, opts = {})\n request_options = symbolize_hash(opts)\n request_options[:headers] = { 'X-Algolia-User-ID': user_id }\n\n @transporter.write(:POST, '/1/clusters/mapping', { cluster: cluster_name }, request_options)\n end",
"def process_workshop_users(data)\n\t\tdata.each do |item|\n\t\t\tif item[:password] == \"local\"\n\t\t\t\titem[:password] = @user.password\n\t\t\tend\n\t\t\[email protected]_user(item)\n\t\tend\n\tend",
"def addWorkingUser user\n @workingUsers << user\n @workingUsers.uniq!\n end",
"def tourn_listing_wrapper(user)\n user_list = get_user_tourns(user); #get the list\n \n listing = {}; #rtn value\n \n end",
"def create\n @group_map = GroupMap.new(params[:group_map])\n @group_map.owner == current_user\n @group_map.users << current_user\n\n respond_to do |format|\n if @group_map.save\n format.html { redirect_to @group_map, notice: 'Group map was successfully created.' }\n format.json { render json: @group_map, status: :created, location: @group_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_entry(entry, ldap_attrs, user_attrs, ldap_key, user_key)\n if user_attrs.has_key?(user_key)\n if ldap_attrs.has_key?(ldap_key)\n if user_attrs[user_key] != ldap_attrs[ldap_key].first\n entry << LDAP.mod(LDAP::LDAP_MOD_REPLACE, ldap_key, user_attrs[user_key].is_a?(String) ? [ user_attrs[user_key] ] : user_attrs[user_key] )\n end\n else\n entry << LDAP.mod(LDAP::LDAP_MOD_ADD, ldap_key, user_attrs[user_key].is_a?(String) ? [ user_attrs[user_key] ] : user_attrs[user_key] )\n end\n else\n if ldap_attrs.has_key?(ldap_key)\n entry << LDAP.mod(LDAP::LDAP_MOD_DELETE, ldap_key, [ ])\n end\n end\n end",
"def map\n add_breadcrumb :map\n @map_opt = {\n :zoom => 2,\n :auto_adjust => true,\n :auto_zoom => false,\n :center_on_user => true,\n :detect_location => true\n }\n @users = User.search do\n with :published, true\n fulltext params[:q] do\n fields(:bio, :name => 2.0)\n end\n order_by :id, :desc\n end.results\n\n @markers = @users.to_gmaps4rails do |user, marker|\n marker.infowindow render_to_string(:partial => \"/users/marker_template\", :locals => {:usr => user})\n marker.json({:id => user.id})\n end\n end",
"def allow_user(user_id)\n create_entry(user_id, USER, true)\n end",
"def home\n @users = User.geocoded #returns user with coordinates\n @user = User.find_by(params[:user_id])\n\n\n @markers = @users.map do |user|\n if user == current_user\n dog_image = helpers.asset_url('dog_crown.png')\n {\n lat: user.latitude,\n lng: user.longitude,\n infoWindow: render_to_string(partial: \"info_window\", locals: { user: user }),\n image_url: dog_image,\n owner: true\n # image_url: user.dog.photo_url\n }\n else\n dog_image = helpers.asset_url('logo.png')\n {\n lat: user.latitude,\n lng: user.longitude,\n infoWindow: render_to_string(partial: \"info_window\", locals: { user: user }),\n image_url: dog_image,\n user: user,\n owner: false\n # image_url: user.dog.photo_url\n }\n end\n\n end\n end",
"def user_entry\n @user = User.find(params[:id])\nend",
"def update_geoloc\n # Too simple ! Need to check than every user are contributors for this project.\n # Ok, I admit this is realy not accurate for any security purpose... Curious to see what Novagile think about\n CacheUser.update_geocodes(geoloc_params)\n respond_to do |format|\n format.html { render text: \"Request processed\", status: \"ok\" }\n format.json { render text: {message: \"Request processed\"}, status: :ok}\n end\n end",
"def add_requester(user)\n attempted_interpreter_requests.create(user_id: user.id)\n end",
"def add\n # ask the user for the user name\n new_user_name = @view.ask_user_for(:username)\n # ask the user for the user continent\n new_user_continent = @view.ask_user_for(:password)\n # create an instance of `Country` based on what the user said\n new_user = User.new(username: new_user_name, password: new_user_continent)\n # adding in to the repo\n @repo.add(new_user)\n end",
"def user_location(user)\n geo = user.geolocation\n geo.latitude = 32.7157\n geo.longitude = -117.1611\n geo.fetch_address\n geo.save\n end",
"def create\n @entry = Entry.new(params[:entry])\n\n respond_to do |format|\n if @current_user.entries << @entry\n format.html { redirect_to user_entries_path, notice: 'Entry was successfully created.' }\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def entry\n authorize! :show, PointsEntryType\n authorize! :show, Client\n authorize! :create, PointsEntry\n\n load_points_entry_type\n build_client\n build_points_entry\n end",
"def processUserSysGem(args, successMsg='Successed', failMsg='Failed', &block)\n processStartCmds(GemCmd.suCmds + args, '(system) '+successMsg, failMsg) do |ret|\n args.push('--user-install')\n processStartCmds(GemCmd.locCmds + args, '(user) '+successMsg, failMsg, &block)\n end\n end",
"def sync\n prizes = params[:prizes]\n users = params[:users]\n if prizes\n prizes.each do |entry|\n entry = entry[1]\n @entry = Entry.find_or_create_by_id(entry['id']);\n logger.debug(\"entry remote id #{entry['created_at']}\")\n @entry.update_attributes({:delivered => entry['delivered']})\n end\n\n end\n if users\n users.each do |entry|\n entry = entry[1]\n @entry = User.find_or_create_by_id(entry['id']);\n logger.debug(\"entry remote id #{entry['created_at']}\")\n @entry.update_attributes({:laps => entry['laps']})\n end\n end\n\n end",
"def owned_entry \n unless current_user == @entry.user\n flash[:alert] = \"That entry doesn't belong to you!\"\n redirect_to root_path\n end\n end",
"def point_attribution(user, problem)\n if !user.pb_solved?(problem) # Avoid giving two times the points to a same problem\n pt = problem.value\n\n partials = user.pointspersections\n\n user.rating = user.rating + pt\n user.save\n\n partial = partials.where(:section_id => problem.section.id).first\n partial.points = partial.points + pt\n partial.save\n end\n end",
"def set_listings\n @user = User.find(params[:user_id])\n end",
"def extra_users_data_look_up\n return if @results.empty?\n\n tickets = DataStore.instance.tickets\n @results.each do |user|\n ticket_names = tickets.select { |t| t['assignee_id'] == user['_id'] }.map { |t| t['subject'] }\n user['tickets'] = ticket_names\n end\n end",
"def update_user(jid, node)\n redis.publish(\"cluster:nodes:#{node}\", {\n from: @cluster.id,\n type: USER,\n jid: jid.to_s\n }.to_json)\n end",
"def create\n @entry = Entry.new(entry_params)\n @entry.user = current_user\n\n ['definitions', 'examples', 'references'].each do |name|\n @entry.send(name).each do |model|\n model.user = current_user\n end\n end\n\n authorize @entry\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to @entry, notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: @entry }\n else\n format.html { render :new }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def alteration_approve\n UserNotifier.deliver_in_process(self, user)\n end",
"def users\n @map = Map.find_by_name('Stor-Oslo') \n @gmap = @map.to_gmap\n Users.find(:all).each { |u| @gmap.overlay_init(u.to_gmarker) }\n render :action => :index\n end",
"def geo_notification(to_user, cc_users, new_subs, hostname)\n recipients \"#{to_user.name} <#{to_user.email}>\"\n cc cc_users.map{|user| \"#{user.name} <#{user.email}>\"}\n from \"[email protected]\"\n reply_to \"[email protected]\"\n subject GEO_SUBJECT_TEMPLATE\n body :name => to_user.name.split(/ /).first,\n :subs_with_geo => new_subs[:with_geo],\n :subs_no_geo => new_subs[:no_geo],\n :subs_processing => new_subs[:processing],\n :hostname => hostname\n end",
"def set_entry\n @entry = current_user.entries.find(params[:id])\n end",
"def create\n @entry = Entry.new(entry_params)\n\n @job = Job.find(params[:job_id])\n\n @user = User.find_by(email: params[:entry][:entry_email])\n\n unless @user\n random_password = Devise.friendly_token\n @user = User.new(name: params[:entry][:entry_name],\n email: params[:entry][:entry_email],\n phone: params[:entry][:entry_phone],\n address: params[:entry][:entry_address],\n password: random_password,\n password_confirmation: random_password)\n @user.skip_confirmation!\n @user.save!\n end\n\n @entry.user_id = @user.id\n @entry.job_id = @job.id\n\n if @user.jobs.find_by(id: @job.id)\n redirect_to job_url(@job), flash: { secondary: 'You has been entry this job.' }\n else\n if @entry.save\n UserMailer.job_apply(@user, @job).deliver_now\n redirect_to @entry, flash: { secondary: 'Thank you for apply. Please check your email.' }\n else\n render :new\n end\n end\n end",
"def distribute_cc\n\n self.get_target_users.each do |user_id|\n next if self.user_id == user_id\n\n decided_inbox = WorkflowsHelper.get_decided_inbox(user_id)\n copied_item = self.item.copy(user_id, decided_inbox.id)\n end\n end",
"def populate_user_pool(user, type)\n case type\n when 'iso'\n @iso_users << user\n when 'agent'\n @agent_users << user\n end\n end",
"def add_user(user)\r\n\t\tsend(\"ADC\",\"FL N=#{user.name} F=#{user.safenick}\")\r\n\t\tsend(\"ADC\",\"AL N=#{user.name} F=#{user.safenick}\")\r\n\t\t## XXX changes recorded locally by ADD msg back\r\n\t\treturn 1\r\n\tend",
"def update\n current_user.update(user_params)\n @current_gears = Item.current_job(current_user.job_id, current_user.lang)\n render partial: 'layouts/gearset_partial', locals: { current_user: current_user, lang: current_user.lang.to_sym }\n end",
"def put_user(coord)\n x_position = coord[0]\n y_position = coord[1]\n if !((0 < x_position && x_position < @width - 1) && (0 < y_position && y_position < @height - 1))\n raise RangeError.new(\"User coordinate out of map size bound\")\n end\n for row in [-1, 0, 1]\n for column in [-1, 0, 1]\n if !(row == 0 && column == 0) && @map[y_position + row][x_position + column] == @WALL\n @map[y_position + row][x_position + column] = @FLOOR\n end\n end\n end\n @map[y_position][x_position] = @USER\n join_rooms\n clear_small_wall\n end",
"def add_to_group(team, this_user)\n team[:user_ids] << this_user\n end",
"def update_map\n @class = Key\n @css_class = \"keys\"\n @enduser = EndUser.find(session[:enduser])\n \n # Verify the parameters and collect the keys\n gather_map_border_paramters()\n gather_group_end_users_and_keys()\n end",
"def approval_needed(user)\n @user = user\n\n mail to: ENV['ADMIN_EMAIL'], subject: \"User wants approval for Thumbline Set List\"\n end",
"def permit_user\n if (!current_user.lunches_admin?) \n flash[:alert] = 'You not allowed to see all orders.'\n respond_to do |format| \n format.html {redirect_to(root_url)}\n end\n end\n end",
"def loan_request_notification(owner, requester, user_lacquer)\n @owner = owner\n @requester = requester\n @user_lacquer = user_lacquer\n @user_url = \"http://www.lacquerloveandlend.com/users/#{@owner.id}\"\n\n mail(to: @owner.email, subject: \"#{@requester.name} wants to borrow #{@user_lacquer.lacquer.name}\")\n\n headers['X-MC-Track'] = \"opens, clicks_all\"\n end",
"def set_listings\n @user = User.find(params[:user_id])\n end",
"def add_user_to_group(username, groupname)\n\t\t\t\t# Check for validity first\n\t\t\t\tsuper(username, groupname)\n\n\n\t\t\t\t`/usr/sbin/pw groupmod #{shellescape(groupname)} -m #{shellescape(username)}`\n\t\t\tend",
"def check_out_by(user)\n borrowed_by.push(user)\n end",
"def notification (user_id)\n requests = Requests.requests_for_edit_notification(user_id)\n if(requests != nil)\n senders_id = Array.new\n requests.each do |t|\n sender_id = t.senders_id\n senders_id.push sender_id\n end\n senders_id.each do |s|\n notification = Notifications.set_notification(s)\n user = Users.find_by_id(user_id).username\n requests.each do |t|\n if (t.senders_id == s)\n description = user + \" \" + \"edited his/her trip, please check it!\"\n Notifications.create_notification_trip(notification, description)\n end\n end\n end\n return\n end\n end",
"def add_user_to_marketing_list(user)\n gv_free_5_alerts_plan_list = 'a8c9d4b3b1'\n location = user.locations.last\n \n merge_vars = {\n 'FNAME' => user.first_name,\n 'LNAME' => user.last_name,\n 'PHONE' => user.phone_number,\n 'COMPANY' => location.name,\n 'WEBSITE' => location.website,\n 'ADDRESS' => [:addr1 => location.street_address, \n :addr2 => location.address_line_2, \n :city => location.city, \n :zip => location.zip ]\n }\n double_optin = false\n response = Mailchimp::API.listSubscribe({:id => gv_free_5_alerts_plan_list,\n :email_address => user.email, :merge_vars => merge_vars,\n :double_optin => double_optin})\n rescue => e\n puts \"Error from Mailchimp\"\n puts e.message\n end",
"def replicate_address_from_current_user_details(id, user)\n\n address = Address.find(id)\n\n address.update(\n line1: user.line1,\n line2: user.line2,\n line3: user.line3,\n town_city: user.townCity,\n county: user.county,\n postcode: user.postcode\n )\n\n end",
"def perform(phenotype_id,user_id)\n @phenotype = Phenotype.find_by_id(phenotype_id)\n User.where(:message_on_new_phenotype => true).find_each do |u|\n if u.id != user_id\n UserMailer.new_phenotype(@phenotype,u).deliver_later\n end\n end\n end",
"def add_user!( user, update_user = true )\n puts \"add_user\"\n unless @users.include?( user )\n @users << user\n user.add_badge!( self, false ) if update_user\n end\n return @users\n end",
"def process_entry(entry)\n # No-op.\n end",
"def remove_pending\n authorize! :update, @user, :message => t('errors.messages.not_authorized_as_manager')\n\n @user = User.find(params[:id])\n @marina = Marina.find(params[:marina])\n @marina.pending_users.delete(@user)\n\n @user.marina_state= \"\"\n UserNotifier.remove_pending(@user).deliver\n @user.save\n @marina.save\n redirect_to marina_path(@marina), :notice => t('errors.messages.remove_pending')\n #\"Bertholder and marina are now connected. a notification email has been sent\"\n\n\n\n end",
"def prepare_deploy_access(user_data)\n node['users']['accessed_by'].each do |target, accessors|\n unless user_data.include?(target)\n raise \"Cannot grant access to an inexistent user '#{target}'\"\n end\n if target == 'root'\n raise \"Can't create access to root user\"\n end\n accessors.each do |accessor|\n unless user_data.include?(accessor)\n raise \"Can't grant SSH access to user '#{target}' by user '#{accessor}' - no data bag found for user '#{accessor}'\"\n end\n user_data[target]['public_keys'] += user_data[accessor]['public_keys']\n end\n end\nend",
"def after_merge_rpx_data( from_user, to_user )\n\t\t\t\n\t\t\tend",
"def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end",
"def assign_user_ids(user_ids, cluster_name, opts = {})\n @transporter.write(:POST, '/1/clusters/mapping/batch', { cluster: cluster_name, users: user_ids }, opts)\n end",
"def update_users\n\tusers = [['adoni','Biwi'],\n\t['biwi','Biwi'],\n\t['dyton','Biwi'],\n\t['bwalo','Bwalo 1'],\n\t['bwalo2','Bwalo 2'],\n\t['bwatha','Bwatha'],\n\t['zunguzeni','Bwatha'],\n\t['chagamba','Chagamba'],\n\t['kelvin','Chagamba'],\n\t['chakale','Chakala'],\n\t['chalasa','Chalasa'],\n\t['chaonya','Chaonya'],\n\t['kenivasi','Chaonya'],\n\t['chidalanda','Chidalanda'],\n\t['gilbert','Chidalanda'],\n\t['chembekezo','Chidzele'],\n\t['chigo','Chikamba'],\n\t['chikamba','Chikolokoto'],\n\t['abisoni','Chimphepo'],\n\t['chimphepo','Chimphepo'],\n\t['salimoni','Chimphepo'],\n\t['chisomba','Chisomba'],\n\t['rose','Chisomba'],\n\t['biliyati','Chitawa'],\n\t['liana','Chitawa'],\n\t['rihanna','Chitawa'],\n\t['chithengo','Chithengo'],\n\t['yoki','Chithengo'],\n\t['chitululu','Chitululu'],\n\t['chizumba','Chizumba'],\n\t['chule','Chule 1'],\n\t['kathumba','Chule 1'],\n\t['rodiwelo','Chule 1'],\n\t['chule2','Chule 2'],\n\t['kambizeni','Chule 2'],\n\t['dongo','Dongolosi'],\n\t['dongolosi','Dongolosi'],\n\t['fainda','Fainda'],\n\t['yolamu','Fainda'],\n\t['beatrice','Kabzyoko'],\n\t['kabzoko','Kabzyoko'],\n\t['kacheche','Kacheche'],\n\t['esawo','Kalulu'],\n\t['kamadzi','Kamadzi'],\n\t['steve','Kamadzi'],\n\t['kambira','Kambiri'],\n\t['kambulire','Kambulire 1'],\n\t['kambulire2','Kambulire 2'],\n\t['sankhani','Kambulire 2'],\n\t['kamphinga','Kamphinga'],\n\t['kaninga','Kaninga'],\n\t['kondwani','Kaninga'],\n\t['kanyoza','Kanyoza'],\n\t['bazale','Kanyoza'],\n\t['lotale','Kazinkambani'],\n\t['kholongo','Kholongo'],\n\t['david',\"M’maso\"],\n\t['davie',\"M’maso\"],\n\t['mayikolo','Malenga'],\n\t['mankhwazi','Mankhwazi'],\n\t['jenet','Maole'],\n\t['maole','Maole'],\n\t['maselero','Maselero'],\n\t['charles','Masumba'],\n\t['masumba','Masumba'],\n\t['weluzani','Masumba'],\n\t['matchakaza','Matchakaza'],\n\t['william','Matchakaza'],\n\t['mawunda','Maunda'],\n\t['mazira','Mazira'],\n\t['kazimkambani','Mbalame'],\n\t['mbalame','Mbalame'],\n\t['mblame','Mbalame'],\n\t['mbewa','Mbewa'],\n\t['mbulachisa','Mbulachisa'],\n\t['kasakula','Mchena'],\n\t['mchena','Mchena'],\n\t['nchazime','Mchezime'],\n\t['henry','Mdzoole'],\n\t['mdzoole','Mdzoole'],\n\t['mfuti','Mfuti'],\n\t['mgwadula','Mgwadula'],\n\t['misewu','Misewo'],\n\t['mkupeta','Mkupeta'],\n\t['mmaso','Mmaso'],\n\t['brino','Mndele'],\n\t['mphandu','Mphandu'],\n\t['mphonde','Mphonde'],\n\t['mseteza','Mseteza'],\n\t['jackson','Mtema 1'],\n\t['makombe','Mtema 1'],\n\t['mtema1','Mtema 1'],\n\t['fredrick','Mtema 2'],\n\t['mtsukwachikupa','Mtsukwa Chikupa'],\n\t['mtsukwakalonje','Mtsukwa Kalonje'],\n\t['mutu','Mutu'],\n\t['mwaza','Mwaza'],\n\t['mtsatsula','Mzingo'],\n\t['hezekia','Mzumanzi 1'],\n\t['mzumazi2','Mzumanzi 2'],\n\t['nzumazi2','Mzumanzi 2'],\n\t['nzumazi','Mzumazi 1'],\n\t['ndalama','Ndalama'],\n\t['ngoza','Ngoza'],\n\t['sitima','Ngoza'],\n\t['nkhadani1','Nkhadani 1'],\n\t['nkhadani2','Nkhadani 2'],\n\t['nkhanamba','Nkhanamba'],\n\t['konkha','Nkhonkha'],\n\t['amosi','Nkhutchi'],\n\t['chisisi','Nkhutchi'],\n\t['andrew','Nkhutchi'],\n\t['ezala','Nsanda'],\n\t['ezara','Nsanda'],\n\t['nsanda','Nsanda'],\n\t['pheleni','Pheleni'],\n\t['laston','Suntche 1'],\n\t['suntche1','Suntche 1'],\n\t['jonathani','Suntche 1'],\n\t['boston','Suntche 2'],\n\t['suntche2','Suntche 2'],\n\t['jonas','Taiza'],\n\t['kwimbayani','Taiza'],\n\t['taiza','Taiza'],\n\t['joseph','Wayakumseche']]\n\t\n\t#-----------------------------\n\t\n\t(users || []).each do |user|\n\t\tusername = user[0]\n\t\tvillage_name = user[1]\n\t\tuser_village = Village.find_by_name(village_name)\n\t\tif user_village.nil?\n\t\t\tputs \"#{user} failed to update. Moving on to next user\"\n\t\t\tnext\n\t\tend\n\t\t\n\t\tuser_district = District.find_by_name('Lilongwe')\n\t\t\n\t\tuser_update = User.find(username)\n\t\tnext if user_update.nil?\n\t\t\n\t\tuser_update.district_id = user_district.id\n\t\tuser_update.ta_id = user_village.ta_id\n\t\tuser_update.village_id = user_village.id\n\t\tuser_update.save\n\t\t\n\t\tputs \"Username #{user} updated successfully \\n\"\n\tend\nend",
"def add_lat_longt\n users = User.find(:all)\n for user in users\n if !user.city.blank? && !user.country_id.blank?\n address = Country.get_alt_longt(user.city,user.country_id)\n if address != nil\n user.update_attributes(:lat => address.latitude, :longt => address.longitude)\n end\n end\n end \n end",
"def others_bdfl(user)\n case user['gh_login']\n when 'dhh', 'jeresig', 'matz', 'rlerdorf', 'TimToady', 'torvalds'\n user['achievements']['BDFL'] = 'Benevolent Dictator for Life'\n end\n end",
"def create_entries_for_user(_user)\n entries = []\n (0..30).each do |_number|\n entries << EntryBuilder.new(number).entry\n end\n end",
"def admit_user user_id = nil\n return if is_global\n if (tagtype != 0) || user_id.nil? || (user_id == User.super_id)\n self.is_global = true\n elsif !owner_ids.include?(user_id) && (user = User.find_by id: user_id)\n self.owners << user unless owners.include?(user)\n end\n end",
"def modified_by_user(user_id, source_id, number_to_return = :all, starting_index = 0)\n # ids = PublicEarth::Db::Place.many.modified_by_user(user_id, source_id, number_to_return == :all && 250 || number_to_return, starting_index).map { |result| result['modified_by_user'] }\n ids = PublicEarth::Db::Place.many.modified_by_user(user_id, source_id).map { |result| result['modified_by_user'] }\n PublicEarth::Db::Place.find_from_search(*ids)\n end",
"def update!(**args)\n @user_info = args[:user_info] if args.key?(:user_info)\n end",
"def user_entry(arg)\n arg = arg.sub(/@.*$/, '').presence&.to_sym if arg.is_a?(String)\n # noinspection RubyMismatchedReturnType\n arg if arg.is_a?(Symbol) && (arg != :anonymous)\n end",
"def add_spl_callback(_obs)\n SiteData.update_contribution(:add, :species_list_entries, user_id)\n end",
"def add_user(user)\n user = user.strip.downcase\n key = key_for('autocomplete')\n (1..(user.length)).each{ |l|\n prefix = user[0...l]\n @redis.zadd(key,0,prefix)\n }\n @redis.zadd(key,0,user+'*')\n end",
"def create\n @entry = Entry.new(user_id: current_user.id)\n @entry.update(entry_params)\n if @entry.save\n redirect_to entry_path(@entry)\n else\n redirect_to controller: 'entries', action: 'new'\n end\n end",
"def direct_share( user, privileges )\n @acl ||= Acl.new\n @acl << { :user => user, :privileges => privileges }\n end",
"def provide_admin_pin\n NotificationsMailer.with(sports_centre: SportsCentre.first, new_rep: Representative.last, adminPin: \"3724\").provide_admin_pin\n end",
"def update_location\n suggestion = Suggestion.find(params[:id])\n if admin or suggestion.user == @current_user\n suggestion.lat = params[:lat]\n suggestion.lon = params[:lon]\n suggestion.save\n end\n render :text => suggestion.to_json\n end",
"def add_item(users)\n print_item(users)\n print \"What is the name of the user you wish to edit?\".yellow\n person = gets.chomp\n users.each do |user|\n if user[:user] == person\n print \"What's the name of the new item? \".green\n added_item = gets.chomp\n user[:item].push(added_item)\n puts \"Adding #{added_item} to the user...\".red\n sleep(2)\n print_item(users)\n end\n end\nend",
"def user_add argv = {}\n\t\tfkv\t\t\t= {}\n\t\tfkv[:name]\t= argv[:name]\n\t\tfkv[:level]\t= argv[:level]\n\t\tfkv[:tag]\t= argv[:tag] if argv[:tag]\n\n\t\t# if the username is existed\n\t\t_throw Sl[:'the user is existed'] if user_has? fkv[:name]\n\n\t\t# password\n\t\trequire \"digest/sha1\"\n\t\tfkv[:salt] \t= _random 5\n\t\tfkv[:pawd] \t= Digest::SHA1.hexdigest(argv[:pawd] + fkv[:salt])\n\n# \t\tSdb[:user].insert(f)\n\t\tdata_submit :user_info, :fkv => fkv, :uniq => true\n\n\t\tuid = Sdb[:user_info].filter(:name => fkv[:name]).get(:uid)\n\t\tuid ? uid : 0\n\tend",
"def wanted_list usr, cid=nil, loc=nil, adminFlg=true\n ListingDataProcessor.new(@listing).wanted_list(usr, cid, loc, adminFlg)\n end",
"def add\n # ask the user for the user name\n new_user_name = @view.ask_user_for(:username)\n # ask the user for the user continent\n new_user_continent = @view.ask_user_for(:password)\n # create an instance of `Country` based on what the user said\n new_user = User.new(username: new_user_name, password: new_user_continent)\n # adding in to the user_repository\n @user_repository.add(new_user)\n end",
"def add_to_queue!(user)\n $redis.lpush(self.class.redis_key_for_user(user), to_redis_object)\n end",
"def deny_user(user_id)\n create_entry(user_id, USER, false)\n end",
"def requests_on_map\n params[:listing_type] = \"request\"\n @to_render = {:action => :index}\n @listings = Listing.open.order(\"created_at DESC\").find_with(params, @current_user, @current_community)\n @listing_style = \"map\"\n load\n end",
"def index\n $new_unread_messages_cnt = Message.current_user_unread(current_user).unread_messages.length\n @users = User.all.sort_by {|user| user.userInterests(current_user) + user.ccLocation(current_user.latitude, current_user.longitude) }.reverse\n @user = current_user\n @latTest = params[:lat]\n\n\n if current_user.is_admin == false or current_user.is_admin == nil\n redirect_to root_path\n end\n\n end",
"def collect_user_info(get_password=true, \n first_time=false,\n third_party=false,\n need_email=true)\n\n values = {\n \"form_target\" => url(:handle_collect_user_info, \n get_password, \n third_party,\n need_email),\n \"user_affiliate_opts\" => Affiliate.options,\n \"first_time\" => first_time,\n \"third_party\" => third_party\n }\n\n \n @data.user.add_to_hash(values)\n\n standard_page(\"Create New User\",\n values,\n Login::EDIT_USER)\n end",
"def increase_frequent_flyer_total\n # self.user.update_attribute miles, user.miles + flight.miles\n self.user.miles += self.flight.miles\n self.user.save\n end",
"def update\n\n available_users\n \n #assign users to mission\n if params[:user_ids].present?\n user = params[:user_ids].delete_if{ |x| x.empty? }\n @mission.users = []\n @mission.users << User.find(params[:user_ids]) \n end\n respond_to do |format|\n if @mission.update(mission_params)\n format.html { redirect_to [:admin, @mission], notice: 'Mission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n if current_user.role == 'admin'\n @verfasser = User.find(params[:entry].delete('user_id'))\n @entry.user = @verfasser\n end\n\n respond_to do |format|\n if @entry.update_attributes(entry_params)\n format.html { redirect_to @entry, notice: \"Eintrag erfolgreich gespeichert. #{undo_link}\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mini_map_index\n @mini_maps = MiniMap.find_all_by_houdd_user_id(params[:user_id])\n\n respond_to do |format|\n format.html # mini_map_index.html.erb\n end\n end",
"def update\n @entry = current_user.entries.find(params[:id])\n \n if params[:entry] && params[:entry].has_key?(:user_id)\n params[:entry].delete(:user_id)\n end\n\n respond_to do |format|\n if @entry.update_attributes(entry_params)\n format.html { redirect_to @entry, notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.54341406",
"0.539824",
"0.5181867",
"0.51694775",
"0.5134313",
"0.51079077",
"0.5049179",
"0.4929479",
"0.49120942",
"0.49120942",
"0.48985064",
"0.48944438",
"0.48727462",
"0.48544717",
"0.48423412",
"0.48423412",
"0.48398894",
"0.48283106",
"0.47862995",
"0.47750166",
"0.47693706",
"0.4766588",
"0.47612002",
"0.47238111",
"0.4723169",
"0.47164375",
"0.4716217",
"0.46908253",
"0.46816567",
"0.46814772",
"0.4681021",
"0.4680984",
"0.46669307",
"0.46610975",
"0.46606272",
"0.46539038",
"0.46503043",
"0.46481684",
"0.4647741",
"0.46428746",
"0.46386266",
"0.4634837",
"0.46331403",
"0.4632324",
"0.4622754",
"0.46194753",
"0.4614471",
"0.4612963",
"0.4608632",
"0.45931095",
"0.45916164",
"0.45894372",
"0.45892197",
"0.4586231",
"0.45819432",
"0.4575659",
"0.45703885",
"0.45687833",
"0.45678362",
"0.45628646",
"0.4557558",
"0.4554109",
"0.4540502",
"0.45398897",
"0.45365667",
"0.45148852",
"0.4513798",
"0.45104057",
"0.45023203",
"0.45020688",
"0.44909182",
"0.44891414",
"0.44798076",
"0.44753847",
"0.44730246",
"0.4467579",
"0.4467086",
"0.44652334",
"0.44593918",
"0.44591698",
"0.4458958",
"0.4457125",
"0.44557527",
"0.44535357",
"0.44516367",
"0.4451541",
"0.4447674",
"0.4443754",
"0.44421127",
"0.4441447",
"0.44293967",
"0.44286424",
"0.4424049",
"0.44239035",
"0.44236594",
"0.44114074",
"0.44096217",
"0.44077712",
"0.4406426",
"0.43992954"
] | 0.60076034 | 0 |
return true or false | def test_condition(i)
case self.rc_query
when (:contains || :is)
#i =~ #self.rc_regex
when :does_not_contain
#i =~ #self.rc_regex
when :is_greater_than
i > self.rc_integer_value
when :is_less_than
i < self.rc_integer_value
when :equals
i == self.rc_integer_value
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def success?() end",
"def success?(*) end",
"def result?\n false\n end",
"def check ; true ; end",
"def result?\n true\n end",
"def success?\n return true\n end",
"def success?\n end",
"def do_pigs_fly?\n return true,false\nend",
"def success?()\n result != false\n end",
"def success?\n false\n end",
"def success?\n false\n end",
"def ok? \n @funct == nil ? (return false) : (return true)\n end",
"def test?\n false\n end",
"def aye?\n true\n end",
"def truth\n\t\t\t\"You can't handle the truth\" ; true\n\t\tend",
"def success?\n true\n end",
"def semact?; false; end",
"def success?\n !error\n end",
"def stand\r\n return true\r\n end",
"def match?\n false\n end",
"def result_to_get?\n if not @result.nil?\n if @result.downcase == 'true'\n return true\n else\n return false\n end\n else\n return false\n end\n end",
"def working?\n false\n end",
"def ok?\n @result.retval == 0\n end",
"def check!\n true\n end",
"def true(_argvs)\n return nil\n end",
"def valid?\r\n return true\r\n end",
"def nd?\n true\n end",
"def open_status?\n return @ajar == true\n end",
"def test?\n true\n end",
"def multi_arged?\n false\n end",
"def success?\n @success == true\n end",
"def success?\n\t\t\t@success\n\t\tend",
"def ai?\n\ttrue\n end",
"def success?\n completed? && !error?\n end",
"def value?(value) true end",
"def truth?\n truth\n end",
"def ok?\n return @ok\n end",
"def recommendable?() false end",
"def isSatisfiable?()\n\tend",
"def delicious?\n\t\treturn true\n\tend",
"def ok?\n @ok\n end",
"def error?\n false\n end",
"def usable?; end",
"def success?\n @error == false\n end",
"def mixed?\n return false\n end",
"def working?\n true\n end",
"def working?\n true\n end",
"def success?\n @success\n end",
"def errors?\n\t\treturn !self.okay?\n\tend",
"def errors?\n\t\treturn !self.okay?\n\tend",
"def failure?\n false\n end",
"def ok?\n skip? || @result\n end",
"def match\n true\n end",
"def to_bool() true end",
"def exist\n\treturn true\n end",
"def qwerty\n\t\tfalse\n\tend",
"def double?\n if self.id\n return true if self.torrent_url && Torrent.not_self(self.id).find_by_torrent_url(self.torrent_url)\n return true if self.transmission_hash_string && Torrent.not_self(self.id).find_by_transmission_hash_string(self.transmission_hash_string)\n return true if self.name && Torrent.not_self(self.id).find_by_name(self.name)\n else\n return true if self.torrent_url && Torrent.find_by_torrent_url(self.torrent_url)\n return true if self.transmission_hash_string && Torrent.find_by_transmission_hash_string(self.transmission_hash_string)\n return true if self.name && Torrent.find_by_name(self.name) \n end\n \n \n return false\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return 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 if @metadata.nil?\n return false\n end\n\n \n \n \n \n \n \n \n \n end",
"def no? ; false ; end",
"def ok_enabled?\r\n return true\r\n end",
"def single_value?\n return false\n end",
"def evaluate?\n false\n end",
"def evaluate?\n false\n end",
"def usable?\n false\n end",
"def matched?\n !failed?\n end",
"def broken?\n @broken == :broken \n\tend",
"def suitable?\n false\n end",
"def suitable?\n false\n end",
"def over?\n\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end"
] | [
"0.76842064",
"0.7317909",
"0.72932243",
"0.7269014",
"0.7193875",
"0.7127188",
"0.7072812",
"0.7021545",
"0.6982793",
"0.6935535",
"0.6935535",
"0.6920994",
"0.6912691",
"0.6871823",
"0.6865664",
"0.6835404",
"0.6820766",
"0.68019915",
"0.6725268",
"0.66672367",
"0.6633488",
"0.6631666",
"0.66298056",
"0.66028726",
"0.6594586",
"0.6590824",
"0.65862733",
"0.6585183",
"0.6570303",
"0.65612364",
"0.6540201",
"0.65385723",
"0.6528159",
"0.6524349",
"0.65192926",
"0.651646",
"0.6501459",
"0.65006953",
"0.6493632",
"0.64882207",
"0.6485753",
"0.6482766",
"0.6482571",
"0.6470815",
"0.6468946",
"0.64601266",
"0.64601266",
"0.64575374",
"0.64553577",
"0.64553577",
"0.6455303",
"0.64537424",
"0.6433216",
"0.6429715",
"0.64266",
"0.642146",
"0.6417057",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64145935",
"0.64144117",
"0.6410843",
"0.64074636",
"0.6406831",
"0.6405274",
"0.6405274",
"0.64012456",
"0.6393227",
"0.639047",
"0.6384519",
"0.6384519",
"0.6383155",
"0.63806736",
"0.63806736",
"0.63806736"
] | 0.0 | -1 |
time samtools view ./0.bam | ./plot_dist_mapq.rb for i in `seq 0 8`; do samtools view ./$i.bam | ./plot_dist_mapq.rb $i 2>/dev/null & done ; wait & /stornext/snfs1/nextgen/software/jdk1.6.0_01/bin/java jar Xmx8g /stornext/snfs1/nextgen/software/picardtools/current/MergeSamFiles.jar INPUT=1.bam INPUT=2.bam TMP_DIR=/space1/tmp/ OUTPUT=./out.bam VALIDATION_STRINGENCY=STRICT | def per(x,t)
p = (x * 100)/t
"#{p}%"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildSampeCommand(read1File, read2File, read1Seq, read2Seq)\n puts \"BWA command\"\n puts @bwaPath\n puts @reference\n puts read1File + \" \" + read2File\n puts read1Seq + \" \" + read2Seq\n puts @samFileName\n cmd = \"time \" + @bwaPath + \" sampe -P \" + \n \" -r \" + buildRGString() + \" \" + @reference + \" \" +\n read1File + \" \" + read2File + \" \" + read1Seq + \" \" + read2Seq +\n \" > \" + @samFileName.to_s\n puts cmd\n return cmd\n end",
"def perform\n @commands << \"/usr/bin/python #{SAMCC}/samcc.py #{@paramsfile} #{@outfile} >> #{job.statuslog_path} 2>&1\"\n\n for i in 0..3\n @commands << \"cd #{job.job_dir}; /usr/bin/gnuplot temp#{i}.run\"\n end\n logger.debug \"Commands:\\n\"[email protected](\"\\n\")\n queue.submit(@commands)\n end",
"def sortBamCommand()\n cmd = \"time java \" + @heapSize + \" -jar \" + @picardPath + \"/SortSam.jar I=\" + @samFileName +\n \" O=\" + @sortedBam + \" SO=coordinate \" + @picardTempDir + \" \" +\n \" MAX_RECORDS_IN_RAM=\" + @maxRecordsInRam.to_s + \" \" + @picardValStr\n return cmd\n end",
"def buildSamseCommand(read1File, read1Seq)\n cmd = \"time \" + @bwaPath + \" samse \" + \" -r \" + buildRGString() +\n \" \" + @reference + \" \" + read1File + \" \" +\n read1Seq + \" > \" + @samFileName\n return cmd\n end",
"def run_align_assess\n filename = self.generate_fasta_alignment_file_for_all\n string = \"./lib/AlignAssess_wShorterID #{filename} P\"\n seq_array = Array.new\n if system(string)\n seq_id_array = self.sequences.map{|s| s.seq_id}\n new_filename = filename + \"_assess\"\n f = File.new(new_filename, \"r\")\n flag = false\n read_row= 999999999\n cur_row = 0\n while (line = f.gets)\n if cur_row > read_row && flag\n if line == \"\\n\"\n flag =false\n else\n seq_array << line.split(\"\\t\")\n end\n elsif line == \"Pair-wise %ID over shorter sequence:\\n\"\n flag=true\n read_row = cur_row + 2\n end\n cur_row +=1\n end\n range = seq_array.length - 1\n #seq_array.each do |row|\n for row_num in 0..range\n for i in 1..range#(row_num) \n PercentIdentity.first_or_create(:seq1_id=>seq_id_array[row_num],\n :seq2_id=>seq_id_array[i],\n :alignment_name => self.alignment_name,\n :percent_id=>seq_array[row_num][i])\n # print \"[#{row_num}:#{i-1}=>#{row[i]}],\"\n end\n #print \"\\n\"\n end\n end\n end",
"def runCommand(bamFile, chipDesignPath)\n FileUtils.mkdir(@outputDir)\n cmd = \"java -Xmx8G -cp \" + @captureCodeDir + \"/picard-1.07.jar:\" + @captureCodeDir +\n \"/sam-1.07.jar:\" + @captureCodeDir + \" CaptureStatsBAM5\"\n cmd = cmd + \" -o \" + @outputDir + \"/\" + @resultPrefix.to_s + \" -t \" +\n chipDesignPath.to_s + \" -i \" + bamFile + \" -d -w\"\n\n puts \"Running the following command for capture stats : \"\n puts cmd\n `#{cmd}`\n exitStatus = $?\n puts \"Exit status of Capture Stats Command : \" + exitStatus.to_s\n\n parseResults()\n uploadToLIMS()\n emailResults()\n puts \"Completed Everything\"\n end",
"def find_blat_out_candidate_reads\n\t\tputs \"step 4 find blat out candidate reads\"\n\t\tblat_out_candidate_reads(\n\t\t\tfiles.keys.sort.collect{|k| \"chopped_#{k}lane.psl \" },\n\t\t\tfiles.keys.sort.collect{|k| \"#{k}lane.fa \" },\n\t\t\tfiles.keys.sort.collect{|k| \"04_blat_out_candidate_#{k}lane.fa\" })\n\n#\t\tcommand = \"blatoutcandidate.rb \"\n#\t\t#\tfiles is a hash and the keys are not guaranteed to be sorted\n#\t\t#\tsort alphabetically and left is first, right is last (conveniently)\n#\t\tfiles.keys.sort.each{|k| command << \"chopped_#{k}lane.psl \" } #\tNON-HUMAN matches\n#\t\tfiles.keys.sort.each{|k| command << \"#{k}lane.fa \" } #\traw reads input\n#\t\tcommand.execute\n##\n##\tblatoutcandidate.pl ALWAYS creates ... blat_out_candidate_#{k}lane.fa\n##\tI REALLY don't like that. So much inconsistancy. Will overwrite existing.\n##\n##\tTODO wrote my own version of blatoutcandidate so could change this\n##\n#\t\tfiles.each_pair { |k,v| \n#\t\t\t#\t\n#\t\t\t#\traw reads with names in the psl files.\n#\t\t\t#\t\n#\t\t\t\"blat_out_candidate_#{k}lane.fa\".file_check(die_on_failed_file_check)\n#\t\t\tFileUtils.mv( \"blat_out_candidate_#{k}lane.fa\",\n#\t\t\t\t\"04_blat_out_candidate_#{k}lane.fa\" )\t#\tNON-HUMAN matches \n#\t\t}\n\tend",
"def filterPhixReadsCmd(bamFile)\n jarName = @javaDir + \"/PhixFilterFromBAM.jar\"\n cmd = \"time java \" + @heapSize + \" -jar \" + jarName + \" I=\" + bamFile\n return cmd\n end",
"def run_score\n filename = self.generate_fasta_alignment_file\n string = \"./lib/score_mac #{filename} temp_data/#{self.alignment_name}_res.txt temp_data/#{self.alignment_name}_dif.txt temp_data/#{self.alignment_name}_alignments.txt\"\n puts string\n if system(string)\n \n end\n end",
"def prepare_reads(base, map, fqgz0, *fqgzs0)\n\n fqgzs = [fqgz0] + fqgzs0\n\n bcs = Hash.new\n open(map, 'r').each do |line|\n bc, well = line.rstrip.split(',')\n bcs[bc] = well\n end\n \n bcl = bcs.keys.map!{|key| key.length}.sort.uniq[0]\n\n tso_pattern = '.'*options.umi_length + '.'*bcl + 'GG'\n\n #\n \n STDERR.puts \"#{`date`.strip}: Demultiplexing each raw sequence files...\"\n \n fqgz2csv0 = Hash.new\n fqgz2csv1 = Hash.new\n fqgz2base = Hash.new\n fqgzs.each do |fqgz|\n fqgz2csv0[fqgz] = get_temporary_path('strt.preprocess', 'csv', false)\n fqgz2csv1[fqgz] = get_temporary_path('strt.preprocess', 'csv', false)\n fqgz2base[fqgz] = get_temporary_path('strt.preprocess', 'base', false)\n end\n\n Parallel.map(fqgz2csv0.keys, in_processes: options.parallel) do |fqgz|\n cmds = [\n \"unpigz -c #{fqgz}\",\n \"#{fq1l_convert_command(options)}\",\n \"#{fq1l_count_command(options)} #{fqgz2csv0[fqgz]}\",\n \"fq1l match_5end#{grep_prefix_option(options)} #{tso_pattern}\",\n \"#{fq1l_count_command(options)} #{fqgz2csv1[fqgz]}\",\n \"fq1l annotate_index --first-cycle=#{options.umi_length+1} --last-cycle=#{options.umi_length+bcl}\",\n \"fq1l annotate_umi --first-cycle=1 --last-cycle=#{options.umi_length}\",\n \"fq1l sort_index#{coreutils_prefix_option}#{parallel_option(options)} --buffer-size=#{(options.maximum_memory/(fqgz2csv0.keys.size+1)).to_i}%\",\n \"fq1l demultiplex #{fqgz2base[fqgz]} #{map}\"\n ]\n cmds.insert(2, \"#{head_command(options)} -n #{options.reads}\") unless options.reads.nil?\n stats = Open3.pipeline(*cmds)\n stats.each_index do |i|\n raise \"Fail at process #{i}; #{stats[i]}; #{cmds[i]}\" unless stats[i].success? || (stats[i].signaled? && stats[i].termsig == 13)\n end\n end\n\n system \"fq1l sum_counts #{fqgz2csv0.values.join(' ')} > #{base}.count.step1.csv\"\n unlink_files(fqgz2csv0.values)\n \n system \"fq1l sum_counts #{fqgz2csv1.values.join(' ')} > #{base}.count.step2.csv\"\n unlink_files(fqgz2csv1.values)\n\n #\n \n (bcs.values + ['NA']).each do |well|\n\n STDERR.puts \"#{`date`.strip}: Finishing well #{well}...\"\n \n tmpfqgzs = fqgz2base.values.map {|base| \"#{base}.#{well}.fq.gz\"}\n csvs = Array.new(6) {|i| \"#{base}.#{well}.count.step#{i+3}.csv\"}\n \n pipeline(\"unpigz -c #{tmpfqgzs.join(' ')}\",\n \"#{fq1l_convert_command(options)}\",\n \"#{fq1l_count_command(options)} #{csvs[0]}\",\n \"#{fq1l_sort_command} --buffer-size=#{(options.maximum_memory/2).to_i}%\",\n \"fq1l exclude_duplicate\",\n \"#{fq1l_count_command(options)} #{csvs[1]}\",\n \"fq1l trim_3end_quality\",\n \"#{fq1l_count_command(options)} #{csvs[2]}\",\n \"fq1l trim_3end_primer#{coreutils_prefix_option}#{grep_prefix_option(options)}#{parallel_option(options)}\",\n \"#{fq1l_count_command(options)} #{csvs[3]}\",\n \"#{fq1l_sort_command} --buffer-size=#{(options.maximum_memory/2).to_i}%\",\n \"fq1l exclude_degenerate\",\n \"#{fq1l_count_command(options)} #{csvs[4]}\",\n \"fq1l trim_5end --minimum-length=#{options.minimum_length} #{tso_pattern}+\",\n \"#{fq1l_count_command(options)} #{csvs[5]}\",\n \"fq1l restore#{coreutils_prefix_option}\",\n \"pigz -c > #{base}.#{well}.fq.gz\")\n \n unlink_files(tmpfqgzs)\n \n end\n \n end",
"def process()\n # For lanes that don't need alignment, run post run and exit\n if @reference.eql?(\"sequence\")\n puts \"No alignment to perform since reference is \\\"sequence\\\"\"\n puts \"Running postrun script\"\n runPostRunCmd(\"\")\n exit 0\n end\n\n outputFile1 = @sequenceFiles[0] + \".sai\"\n\n alnCmd1 = buildAlignCommand(@sequenceFiles[0], outputFile1) \n obj1 = Scheduler.new(@fcAndLane + \"_aln_Read1\", alnCmd1)\n obj1.setMemory(@maxMemory)\n obj1.setNodeCores(@cpuCores)\n obj1.setPriority(@priority)\n obj1.runCommand()\n alnJobID1 = obj1.getJobName()\n\n # paired end flowcell\n if @isFragment == false\n outputFile2 = @sequenceFiles[1] + \".sai\"\n alnCmd2 = buildAlignCommand(@sequenceFiles[1], outputFile2)\n obj2 = Scheduler.new(@fcAndLane + \"_aln_Read2\", alnCmd2)\n obj2.setMemory(@maxMemory)\n obj2.setNodeCores(@cpuCores)\n obj2.setPriority(@priority)\n obj2.runCommand()\n alnJobID2 = obj2.getJobName()\n\n sampeCmd = buildSampeCommand(outputFile1, outputFile2, @sequenceFiles[0],\n @sequenceFiles[1])\n obj3 = Scheduler.new(@fcAndLane + \"_sampe\", sampeCmd)\n obj3.setMemory(@lessMemory)\n obj3.setNodeCores(@minCpuCores)\n obj3.setPriority(@priority)\n obj3.setDependency(alnJobID1)\n obj3.setDependency(alnJobID2)\n obj3.runCommand()\n makeSamJobName = obj3.getJobName()\n else\n # Flowcell is fragment\n samseCmd = buildSamseCommand(outputFile1, @sequenceFiles[0])\n obj3 = Scheduler.new(@fcAndLane + \"_samse\", samseCmd)\n obj3.setMemory(@lessMemory)\n obj3.setNodeCores(@minCpuCores)\n obj3.setPriority(@priority)\n obj3.setDependency(alnJobID1)\n obj3.runCommand()\n makeSamJobName = obj3.getJobName()\n end\n\n # Sort a BAM\n sortBamCmd = sortBamCommand()\n obj5 = Scheduler.new(@fcAndLane + \"_sortBam\", sortBamCmd)\n obj5.setMemory(@lessMemory)\n obj5.setNodeCores(@minCpuCores)\n obj5.setPriority(@priority)\n obj5.setDependency(makeSamJobName)\n obj5.runCommand()\n sortBamJobName = obj5.getJobName() \n\n # Mark duplicates on BAM\n markedDupCmd = markDupCommand()\n obj6 = Scheduler.new(@fcAndLane + \"_markDupBam\", markedDupCmd)\n obj6.setMemory(@lessMemory)\n obj6.setNodeCores(@minCpuCores)\n obj6.setPriority(@priority)\n obj6.setDependency(sortBamJobName)\n obj6.runCommand()\n markedDupJobName = obj6.getJobName()\n prevCmd = markedDupJobName\n\n # Filter out phix reads\n if @filterPhix == true\n phixFilterCmd = filterPhixReadsCmd(@markedBam)\n objX = Scheduler.new(@fcAndLane + \"_phixFilter\", phixFilterCmd)\n objX.setMemory(@lessMemory)\n objX.setNodeCores(@minCpuCores)\n objX.setPriority(@priority)\n objX.setDependency(prevCmd)\n objX.runCommand()\n phixFilterJobName = objX.getJobName()\n prevCmd = phixFilterJobName\n end\n\n # Fix mate information for paired end FC\n if @isFragment == false\n fixMateCmd = fixMateInfoCmd()\n objY = Scheduler.new(@fcAndLane + \"_fixMateInfo\" + @markedBam, fixMateCmd)\n objY.setMemory(@lessMemory)\n objY.setNodeCores(@minCpuCores)\n objY.setPriority(@priority)\n objY.setDependency(prevCmd)\n objY.runCommand()\n fixMateJobName = objY.getJobName()\n prevCmd = fixMateJobName\n end\n\n # Fix unmapped reads. When a read aligns over the boundary of two\n # chromosomes, BWA marks this read as unmapped but does not reset CIGAR to *\n # and mapping quality zero. This causes picard's validator to complain.\n # Hence, we fix that anomaly here.\n fixCIGARCmd = buildFixCIGARCmd(@markedBam)\n fixCIGARObj = Scheduler.new(@fcAndLane + \"_fixCIGAR\" + @markedBam, fixCIGARCmd)\n fixCIGARObj.setMemory(@lessMemory)\n fixCIGARObj.setNodeCores(@minCpuCores)\n fixCIGARObj.setPriority(@priority)\n fixCIGARObj.setDependency(prevCmd)\n fixCIGARObj.runCommand()\n fixCIGARJobName = fixCIGARObj.getJobName()\n prevCmd = fixCIGARJobName\n\n # Calculate Alignment Stats\n mappingStatsCmd = calculateMappingStats()\n obj7 = Scheduler.new(@fcAndLane + \"_AlignStats\", mappingStatsCmd)\n obj7.setMemory(@lessMemory)\n obj7.setNodeCores(@minCpuCores)\n obj7.setPriority(@priority)\n obj7.setDependency(prevCmd)\n obj7.runCommand()\n runStatsJobName = obj7.getJobName()\n prevCmd = runStatsJobName\n\n if @chipDesign != nil && [email protected]?()\n captureStatsCmd = buildCaptureStatsCmd()\n capStatsObj = Scheduler.new(@fcAndLane + \"_CaptureStats\", captureStatsCmd)\n capStatsObj.setMemory(@lessMemory)\n capStatsObj.setNodeCores(@minCpuCores)\n capStatsObj.setPriority(@priority)\n capStatsObj.setDependency(prevCmd)\n capStatsObj.runCommand()\n capStatsJobName = capStatsObj.getJobName()\n prevCmd = capStatsJobName\n end\n\n # Hook to run code after final BAM is generated\n runPostRunCmd(prevCmd)\n end",
"def align_compressed_reads_to_human_genome_reference_using_bowtie\n\t\tputs \"step 7 align compressed reads to human genome reference using bowtie\"\n\t\tfiles.each_pair do |k,v|\n\t\t\t#\tbowtie's verbose is RIDICULOUS!\n\t\t\t#\tIt prints WAY too much and adds WAY too much time.\n\t\t\t#\t\t\t\t\"--verbose \"<<\n\t\t\tcommand = \"bowtie -n #{bowtie_mismatch} -p #{bowtie_threads} -f \" <<\n\t\t\t\t\"-S #{bowtie_index_human} compress_#{k}lane.fa compress_#{k}lane.sam\"\n\t\t\tcommand.execute\n\t\t\t\"compress_#{k}lane.sam\".file_check(die_on_failed_file_check) #\tthe reads that DIDN'T align?\tNO\n\n\t\t\t\"sam2names.rb compress_#{k}lane.sam bowtie_#{k}lane.names\".execute\n\t\t\t\"bowtie_#{k}lane.names\".file_check(die_on_failed_file_check)\n\t\tend\n\n\t\tpull_reads_from_fastas(\n\t\t\tfiles.keys.sort.collect{|k| \"bowtie_#{k}lane.names\" },\n\t\t\tfiles.keys.sort.collect{|k| \"compress_#{k}lane.fa\" },\n\t\t\tfiles.keys.sort.collect{|k| \"bowtie_#{k}lane.fa\" })\n\n#\n#\tThis script has fixed input of chopped_leftlane.psl (and right or single)\n#\tBAD. BAD. BAD.\tTODO\n#\tThis is only informative and nothing uses the output\n#\tso could be commented out.\n#\n#\n#\tTODO Replaced with ruby version, but still in development\n#\n#\n#\t\tcommand = \"candidate_non_human.rb \"\n#\t\t#\tfiles is a hash and the keys are not guaranteed to be sorted\n#\t\t#\tsort alphabetically and left is first, right is last (conveniently)\n#\t\tfiles.keys.sort.each{|k| command << \"bowtie_#{k}lane.names \" }\n#\t\tcommand.execute\n#\t\tfile_check( \"candidate_non_human.txt\" )\n\tend",
"def buildFixCIGARCmd(bamFile)\n jarName = @javaDir + \"/FixCIGAR.jar\"\n cmd = \"time java \" + @heapSize + \" -jar \" + jarName + \" I=\" + bamFile\n return cmd\n end",
"def process_all_db(blast_result_hash,gbff_dir,seq_dir,flanking_res)\n gbff_files = Array.new\n numbThreads = 3\n gbff_files =Dir.glob(\"#{seq_dir}/*.seq\")\n gbff_files.concat(Dir.glob(\"#{gbff_dir}/*.gbff\"))\n gbff_files.each do |gbff_file|\n process_single_db(blast_result_hash,flanking_res,gbff_file)\n #print(\"#{Thread.list.size}\\n\")\n # if(Thread.list.size < numbThreads)\n # a = Thread.new{process_single_db(blast_result_hash,flanking_res,gbff_file)}\n # a.run\n #else\n # Thread.list.each do |thr|\n # thr.join\n # end\n #end\n end\n #output all the unseen items in the database to the insufficient DNA database\n blast_result_hash.each do |key,value|\n if(value.output_to_db == false)\n output_blast_hit(value)\n end\n end\nend",
"def runLaneBarcodes()\n cmdPrefix = \"ruby \" + PathInfo::BIN_DIR +\n \"/LaneAnalyzer.rb fcname=\" + @fcName + \" queue=\" +\n SchedulerInfo::DEFAULT_QUEUE + \" lanebarcode=\" \n\n laneBarcodes = AnalysisInfo.getBarcodeList(@baseCallsDir + \"/FCDefinition.xml\")\n \n # Write the list of commands to make sequences for each lane barcode in a\n # shell script called \"barcodes.sh\" in the BaseCalls directory. Run this\n # script to start the next step. \n outputFileName = @baseCallsDir + \"/barcodes.sh\"\n\n outFile = File.open(outputFileName, \"w\")\n outFile.puts \"#!/bin/bash\"\n\n laneBarcodes.each do |lbc|\n outFile.puts cmdPrefix + lbc.to_s\n end\n outFile.close\n\n buildSeqCmd = \"sh \" + outputFileName\n obj = Scheduler.new(@fcName + \"-LaneBarcodes\", buildSeqCmd)\n obj.setMemory(8000)\n obj.setNodeCores(1)\n obj.setPriority(@queue)\n obj.setDependency(@bclToFastQMakeJobName)\n obj.runCommand()\n runLanesJobName = obj.getJobName()\n puts \"Job name to start lanebarcode analyses : \" + runLanesJobName.to_s\n end",
"def runLaneBarcodes()\n cmdPrefix = \"ruby \" + File.dirname(File.expand_path(__FILE__)) +\n \"/LaneAnalyzer.rb fcname=\" + @fcName + \" queue=normal \" +\n \"lanebarcode=\" \n\n laneBarcodes = AnalysisInfo.getBarcodeList(@baseCallsDir + \"/FCDefinition.xml\")\n \n # Write the list of commands to make sequences for each lane barcode in a\n # shell script called \"barcodes.sh\" in the BaseCalls directory. Run this\n # script to start the next step. \n outputFileName = @baseCallsDir + \"/barcodes.sh\"\n\n outFile = File.open(outputFileName, \"w\")\n outFile.puts \"#!/bin/bash\"\n\n laneBarcodes.each do |lbc|\n outFile.puts cmdPrefix + lbc.to_s\n end\n outFile.close\n\n buildSeqCmd = \"sh \" + outputFileName\n obj = Scheduler.new(@fcName + \"-LaneBarcodes\", buildSeqCmd)\n obj.setMemory(8000)\n obj.setNodeCores(1)\n obj.setPriority(@queue)\n obj.setDependency(@bclToFastQMakeJobName)\n obj.runCommand()\n runLanesJobName = obj.getJobName()\n puts \"Job name to start lanebarcode analyses : \" + runLanesJobName.to_s\n end",
"def bsub_muscle(names)\n names.split(\"\\n\").each do |name|\n puts \"bsub muscle -in #{name} -out #{name + \".fa\"} -tree2 #{name + \".tre\"} -maxiters 2 -cluster neighborjoining\"\n end\nend",
"def startMergeProcess()\n schedulerQueue = SchedulerInfo::DEFAULT_QUEUE\n yamlConfigFile = PathInfo::CONFIG_DIR + \"/config_params.yml\" \n configReader = YAML.load_file(yamlConfigFile)\n\n cmd = \"ruby \" + PathInfo::LIB_DIR + \"/MergeHelper.rb \" + @sampleName.to_s +\n \" \" + @outputDir\n\n @inputList.each do |inputDir|\n cmd = cmd + \" \" + inputDir\n end\n\n obj = Scheduler.new(\"Merge_\" + @sampleName.to_s, cmd)\n obj.lockWholeNode(schedulerQueue)\n obj.runCommand()\n jobID = obj.getJobName()\n\n puts \"Job ID : \" + jobID.to_s\n end",
"def run\n mutex = Mutex.new\n threads = []\n count = 0\n imagepipeline do |from,to|\n while (@pipesize <= count) do\n # do not start until a worker is available\n end\n # record worker thread before he starts\n mutex.synchronize { count += 1 }\n threads << Thread.new do\n #run command\n system \"#{@command} #{from} #{to}\"\n # must maintain synchronization\n mutex.synchronize { count -= 1 }\n end\n end\n # clean up\n threads.each {|t| t.join }\n end",
"def blast_permutations! fastas, blast_dbs, cpus=4\n file_permutations = one_way_combinations fastas, blast_dbs, true\n file_permutations = file_permutations.select do |f1, f2|\n genome_from_fname(f1) != genome_from_fname(f2)\n end\n\n first_files = file_permutations.map(&:first)\n second_files = file_permutations.map(&:last)\n\n first_genomes = first_files.map do |fname|\n ary = fname.split(\".\")\n ary.take(ary.length - 1).join\n end\n\n second_genomes = second_files.map do |fname|\n ary = fname.split(BLAST_DB_SEPARATOR).take(1)\n AbortIf.abort_unless ary.length == 1,\n \"Bad file name for #{fname}\"\n\n ary = ary.first.split(\".\")\n\n File.basename ary.take(ary.length - 1).join\n end\n\n outf_names = first_genomes.zip(second_genomes).map do |f1, f2|\n \"#{f1}____#{f2}.aai_blastp\"\n end\n\n args = first_files.length.times.map do |idx|\n [first_files[idx], second_files[idx], outf_names[idx]]\n end\n\n Parallel.each(args, in_processes: cpus) do |infiles|\n query = infiles[0]\n db = infiles[1]\n out = infiles[2]\n\n cmd = \"diamond blastp --threads 1 --outfmt 6 \" +\n \"--query #{query} --db #{db} --out #{out} \" +\n \"--evalue #{EVALUE_CUTOFF}\"\n\n Process.run_and_time_it! \"Diamond blast\", cmd\n end\n\n outf_names\n end",
"def run fastq_directory, dependency = nil, output_directory = File.join(fastq_directory, \"fastqc\"), fastq_pattern = \"*.fastq.gz\"\n\n system(\"mkdir -p #{output_directory}\")\n\n fastq_files = Dir.glob(File.expand_path(File.join(fastq_directory, fastq_pattern)))\n output_directory = File.expand_path(output_directory)\n puts \"Analyzing #{fastq_files.size} files with Fastqc\"\n return unless fastq_files.size > 0\n\n database = []\n fastq_files.each do |fastq_file|\n database << {\"input\" => fastq_file, \"output\" => output_directory, \"program\" => fastqc_path}\n end\n\n db_directory = File.join(output_directory, \"fastqc_db\")\n system(\"mkdir -p #{db_directory}\")\n\n distributer = SimpleDistribute::Distributer.new(db_directory)\n\n worker_task_name = distributer.submit(WORKER_SCRIPT, {:prefix => \"fastqc\", :database => database, :dependency => dependency})\n\n combiner_task_name = distributer.submit(COMBINER_SCRIPT, {:prefix => \"fastqc\", :dependency => worker_task_name, :args => output_directory})\n\n wait_on_task = combiner_task_name\n\n if self.data[\"projects\"]\n puts \"Projects found!! - distributing to #{self.data[\"projects\"].size} locations\"\n distribute_database = []\n self.data[\"projects\"].each do |out|\n distribute_database << {\"input\" => output_directory, \"output\" => out, \"recursive\" => true}\n end\n\n distribute_task_name = distributer.submit(DISTRIBUTE_SCRIPT, {:prefix => \"fastqc\", :dependency => combiner_task_name, :database => distribute_database})\n wait_on_task = distribute_task_name\n else\n puts \"NO projects found!! - NOT DISTRIBUTING DATA\"\n end\n\n flowcell_id = \"A_FLOWCELL\"\n if self.data[\"flowcell_id\"]\n flowcell_id = self.data[\"flowcell_id\"].strip\n end\n\n email_task_name = distributer.submit(EMAIL_SCRIPT, {:prefix => \"fastqc\", :dependency => wait_on_task, :args => \"FASTQC #{flowcell_id}\"})\n email_task_name\n end",
"def calculateMappingStats()\n cmd = \"ruby \" + File.dirname(__FILE__) + \"/BWAMapStats.rb \" + @markedBam\n puts \"Command to generate Mapping Stats : \" + cmd\n return cmd\n end",
"def generate_fastq\n\n # Generate FASTQ file list, expanding patterns if found.\n fastq_input_file_list = []\n fastq_output_prefix_list = []\n fastq_output_group_list = []\n ARGV.each do |fastq_input_file|\n if fastq_input_file =~ /[\\+\\?\\*]/\n # File is regexp: use it to do our own \"glob\".\n # If the regexp has at least one group in it, save the group match\n # in a corresponding list to use in making the output files.\n fastq_input_dir = File.dirname(fastq_input_file)\n fastq_input_patt = File.basename(fastq_input_file)\n\n Dir.entries(fastq_input_dir).sort().each do |entry|\n if entry =~ /#{fastq_input_patt}()/o\n fastq_input_file_list << entry\n if not @out_prefix.nil?\n fastq_output_prefix_list << @out_prefix\n else\n fastq_output_prefix_list << entry[0..Regexp.last_match.begin(1)-1-1] # Second -1 is for underline.\n end\n fastq_output_group_list << $1\n end\n end\n else\n if File.file? fastq_input_file\n fastq_input_file_list << fastq_input_file\n fastq_output_prefix_list << @out_prefix\n end\n end\n end\n\n die \"no FASTQ files found\" if fastq_input_file_list.length == 0\n\n STDERR.puts(\"Input files: #{fastq_input_file_list}\") if @verbose\n\n fastq_list = fastq_input_file_list.zip(fastq_output_prefix_list, fastq_output_group_list)\n fastq_list.each do |fastq_input_file, fastq_output_prefix, fastq_output_group|\n\n # If we are splitting to subfiles, reset the output sub filenames to\n # the new destination for the new input file; also reset statistics.\n if @save_subfiles\n if fastq_output_group == \"\"\n fastq_output_group_mod = fastq_output_group\n else\n fastq_output_group_mod = \"_#{fastq_output_group}\"\n end\n @pass_sub_filename = File.join(@pass_dir, \"#{fastq_output_prefix}_pf#{fastq_output_group_mod}.fastq\")\n @pass_sub_filename += \".gz\" if @compress\n @reject_sub_filename = File.join(@reject_dir, \"#{fastq_output_prefix}_reject#{fastq_output_group_mod}.fastq\")\n @reject_sub_filename += \".gz\" if @compress\n\n @stats_sub_filename = File.join(@stats_dir, \"#{fastq_output_prefix}_seq_stats#{fastq_output_group_mod}.txt\")\n @pass_sub_read_cnt = @reject_sub_read_cnt = @total_sub_read_cnt = 0\n end\n\n if @save_subfiles\n open_fastq_sub_output_files\n end\n\n # split one FASTQ file into post-filter and reject FASTQ\n STDERR.puts \"Processing #{fastq_input_file}...\" if @verbose\n fastq_input_fp = open_fastq_input(fastq_input_file)\n if fastq_input_fp.nil?\n warn \"#{fastq_input_file} is empty...skipping\"\n next\n end\n begin\n while fastq_input_fp.readline\n header_line = $_\n if header_line !~ /^@/\n STDERR.puts \"Missing header line (#{header_line})...exiting\"\n exit(-1)\n end\n\n header_fields = header_line.split(/[ _]/)\n die \"header parse error at #{fastq_input_file}:#{$INPUT_LINE_NUMBER} [#{header_fields.join(\"!\")}]\" if header_fields.size != 2\n\n sub_header_fields = header_fields[1].split(\":\",-1)\n die \"sub header parse error at #{fastq_input_file}:#{$INPUT_LINE_NUMBER} [#{header_fields.join(\":\")}(#{sub_header_fields.join(\":\")})]\" if sub_header_fields.size != 4\n\n @total_read_cnt += 1\n @total_sub_read_cnt += 1\n\n if sub_header_fields[1] == \"N\"\n out = @pass\n @pass_read_cnt += 1\n out_sub = @pass_sub\n @pass_sub_read_cnt += 1\n elsif sub_header_fields[1] == \"Y\"\n out = @reject\n @reject_read_cnt += 1\n out_sub = @reject_sub\n @reject_sub_read_cnt += 1\n else\n die \"filter field value error at #{fastq_input_file}:#{$INPUT_LINE_NUMBER}...skipping read\"\n out = nil\n end\n\n # Read the rest of the sequence.\n seq_line = fastq_input_fp.readline\n plus_line = fastq_input_fp.readline\n if plus_line !~ /^\\+/\n STDERR.puts \"Malformed FASTQ +line (#{plus_line})\"\n end\n qual_line = fastq_input_fp.readline\n\n # Output the sequence to whatever file was chosen above.\n if !out.nil?\n if not @remove_spaces\n out.print \"#{header_line}\"\n out_sub.print \"#{header_line}\" if not out_sub.nil?\n else\n out.puts header_fields.join(\"_\")\n out_sub.puts header_fields.join(\"_\") if not out_sub.nil?\n end\n out.print \"#{seq_line}\"\n out.print \"#{plus_line}\"\n out.print \"#{qual_line}\"\n if not out_sub.nil?\n out_sub.print \"#{seq_line}\"\n out_sub.print \"#{plus_line}\"\n out_sub.print \"#{qual_line}\"\n end\n end\n end # while\n\n rescue EOFError\n\n end\n\n fastq_input_fp.close()\n\n if @save_subfiles\n close_fastq_sub_output_files\n store_stats @stats_sub_filename, @pass_sub_read_cnt, @reject_sub_read_cnt, @total_sub_read_cnt\n end\n\n end # fastq_list.each\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 run_seq(test=false)\n if @opts[:gtpath].nil?\\\n || !File.exist?(@opts[:gtpath])\\\n || !File.executable?(@opts[:gtpath]) then\n raise \"gt binary not found or executable: #{@opts[:gtpath]}\"\n end\n each_seq do |nr, chr, arglist, chr_cfg|\n if test then\n run \"#{@opts[:gtpath]} #{arglist.join(\" \")}\", :maxtime => 500\n else\n STDERR.puts \"Running #{@job}: seq '#{nr}'\"\n success = Kernel.system(\"#{@opts[:gtpath]} #{arglist.join(\" \")}\")\n end\n if success or test then\n yield nr, chr[:resultfile], chr[:innerfile], \\\n chr[:gff3file], chr[:fastafile]\n else\n raise \"canceled command: #{@opts[:gtpath]} #{arglist.join(\" \")}\"\n end\n end\n end",
"def dist_merge inputs, output, options = {}\n options[:reduce_tasks] ||= 25\n options[:partition_fields] ||= 2\n options[:sort_fields] ||= 2\n options[:field_separator] ||= '/t'\n names = inputs.map{|inp| File.basename(inp)}.join(',')\n cmd = \"#{@hadoop_home}/bin/hadoop \\\\\n jar #{@hadoop_home}/contrib/streaming/hadoop-*streaming*.jar \\\\\n -D mapred.job.name=\\\"Swineherd Merge (#{names} -> #{output})\\\" \\\\\n -D num.key.fields.for.partition=\\\"#{options[:partition_fields]}\\\" \\\\\n -D stream.num.map.output.key.fields=\\\"#{options[:sort_fields]}\\\" \\\\\n -D mapred.text.key.partitioner.options=\\\"-k1,#{options[:partition_fields]}\\\" \\\\\n -D stream.map.output.field.separator=\\\"'#{options[:field_separator]}'\\\" \\\\\n -D mapred.min.split.size=1000000000 \\\\\n -D mapred.reduce.tasks=#{options[:reduce_tasks]} \\\\\n -partitioner org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner \\\\\n -mapper \\\"/bin/cat\\\" \\\\\n -reducer \\\"/usr/bin/uniq\\\" \\\\\n -input \\\"#{inputs.join(',')}\\\" \\\\\n -output \\\"#{output}\\\"\"\n puts cmd\n system cmd\n end",
"def dist_merge inputs, output, options = {}\n options[:reduce_tasks] ||= 25\n options[:partition_fields] ||= 2\n options[:sort_fields] ||= 2\n options[:field_separator] ||= '/t'\n names = inputs.map{|inp| File.basename(inp)}.join(',')\n cmd = \"#{@hadoop_home}/bin/hadoop \\\\\n jar #{@hadoop_home}/contrib/streaming/hadoop-*streaming*.jar \\\\\n -D mapred.job.name=\\\"Swineherd Merge (#{names} -> #{output})\\\" \\\\\n -D num.key.fields.for.partition=\\\"#{options[:partition_fields]}\\\" \\\\\n -D stream.num.map.output.key.fields=\\\"#{options[:sort_fields]}\\\" \\\\\n -D mapred.text.key.partitioner.options=\\\"-k1,#{options[:partition_fields]}\\\" \\\\\n -D stream.map.output.field.separator=\\\"'#{options[:field_separator]}'\\\" \\\\\n -D mapred.min.split.size=1000000000 \\\\\n -D mapred.reduce.tasks=#{options[:reduce_tasks]} \\\\\n -partitioner org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner \\\\\n -mapper \\\"/bin/cat\\\" \\\\\n -reducer \\\"/usr/bin/uniq\\\" \\\\\n -input \\\"#{inputs.join(',')}\\\" \\\\\n -output \\\"#{output}\\\"\"\n puts cmd\n system cmd\n end",
"def test_alignment_works_in_single_thread\n assert_nothing_raised(\"Can't handle single threaded scenario\") do\n SEQUENCE_GROUPS[0..10].each do |sequence_group|\n align_group(sequence_group)\n end\n end\n end",
"def clustal_consensus_multi(seq_hash,open = 15, ext = 6.66, gap_treatment = 1)\n gapopen = open\n gapext = ext\n temp_dir = File.dirname($0)\n temp_file_in = temp_dir + \"/temp_sequence\"\n f = File.open(temp_file_in,'w')\n f.puts seq_hash.flatten\n f.close\n\n temp_file_out = temp_dir + \"/temp_out\"\n temp_screen_out = temp_dir + \"/temp_screen\"\n print `/applications/clustalw2 -infile=#{temp_file_in} -case=upper -outorder=input -output=gde -outfile=#{temp_file_out} >#{temp_screen_out} -gapopen=#{gapopen} -gapext=#{gapext}`\n h = {}\n File.open(temp_file_out,\"r\") do |file|\n n = 0\n file.readlines.each do |line|\n if line =~ /^\\#/\n n += 1\n h[n] = \"\"\n else\n h[n] += line.chomp\n end\n end\n end\n length = h[1].size\n consensus_bases = []\n (0..(length-1)).each do |n|\n bases = []\n h.values.each do |seq|\n bases << seq[n]\n end\n if gap_treatment == 1\n consensus_bases << creat_consensus_base_non_gap(bases)\n else\n consensus_bases << creat_consensus_base_gap(bases)\n end\n end\n File.unlink temp_file_in\n File.unlink temp_file_out\n File.unlink temp_screen_out\n Dir.chdir(temp_dir) do\n Dir.glob(\"*.dnd\") do |dnd|\n File.unlink(dnd)\n end\n end\n consensus_seq = consensus_bases.join('')\nend",
"def run_tests()\r\n Signal.trap(\"CLD\") {@process_counter += 1}\r\n for setting in @settings\r\n Process.wait if @process_counter <= 0\r\n @process_counter -= 1\r\n fork do\r\n temp_name, log = copy_and_edit(setting)\r\n puts \"Running: \" + String(setting[0][:materials]) + \" \" + String(setting[0][:lengths]) + \"cm \" + String(setting[0][:energy]) + \"MeV\"\r\n cmd = String(@output_dir) + \"Hadr06 \" + String(temp_name) + \" > \" + String(log)\r\n system(@output_dir + \"Hadr06 \" + temp_name + \" > \" + log)\r\n relocate(setting)\r\n clean()\r\n end\r\n end\r\nend",
"def run\n\t\t\t\tstart_flowcell\n\t\t\t\tdistributions = []\n\n\n\t\t\t\tunless @options[:no_distribute]\n\t\t\t\t\tdistributions = @flowcell.external_data.distributions_for @flowcell.id \n\t\t\t\tend\n\n\t\t\t\tsteps = @options[:steps]\n\t\t\t\tlogm \"running steps: #{steps.join(\", \")}\"\n\n\t\t\t\tif steps.include? \"setup\"\n\t\t\t\t\tcopy_sample_sheet\n\t\t\t\tend\n\n\t\t\t\tif steps.include? \"unaligned\"\n\t\t\t\t\t#process_unaligned_reads distributions\n\t\t\t\tend\n\n\t\t\t\tif steps.include?\n\n\n\t\t\tend\n\n\t\t\tdef logm message\n\t\t\t\tlog \"# #{message}\"\n\t\t\t\tSolexaLogger.log(@flowcell.paths.id, message) unless @options[:test]\n\t\t\tend\n\n\t\t\tdef copy_sample_sheet\n\t\t\t\tsource = File.join(@flowcell.paths.base_dir, \"SampleSheet.csv\")\n\t\t\t\tdestination = File.join(@flowcell.paths.unaligned_dir, \"SampleSheet.csv\")\n\t\t\t\tif !File.exists? source\n\t\t\t\t\tputs \"ERROR: cannot find SampleSheet at: #{source}\"\n\t\t\t\tend\n\n\t\t\t\texecute(\"cp #{source} #{destination}\")\n\t\t\tend\n\n\t\t\tdef process_unaligned_reads distributions\n\t\t\t\tstatus \"processing unaligned\"\n\t\t\t\tsteps = @options[:steps]\n\t\t\t\tfastq_groups = group_fastq_files(@flowcell.paths.unalinged_project_dir,\n\t\t\t\t\t @flowcell.paths.fastq_combine_dir)\n\t\t\t\t#unless @options[:only_distribute]\n\t\t\t\t#\tcat files fastq_groups\n\t\t\t\t#end\n\n\t\t\t\t###### LAST STOP\n\n\t\t\tend\n\n\n\t\t\t#\n # Helper method that executes a given string on the command line.\n # This should be used instead of calling system directly, as it also\n # deals with if we are in test mode or not.\n #\n def execute command\n log command\n system(command) unless @options[:test]\n end\n\n\n #\n # Gets grouping data for fastq.gz files\n #\n def group_fastq_files starting_path, output_path, options = {:prefix => \"L\", :suffix => \".fastq.gz\", :exclude_undetermined => true}\n execute \"mkdir -p #{output_path}\"\n fastq_groups = []\n \n fastq_files = Dir.glob(File.join(starting_path, fastq_search_path))\n if fastq_files.empty?\n log \"# ERROR: no fastq files found in #{starting_path}\" if fastq_files.empty?\n else\n log \"# #{fastq_files.size} fastq files found in #{starting_path}\"\n fastq_file_data = get_file_data fastq_files, \"\\.fastq\\.gz\"\n fastq_groups = group_files fastq_file_data, output_path, options\n end\n fastq_groups\n end\n\n #\n # Actually combines the related fastq files\n # using cat.\n #\n def cat_files file_groups\n file_groups.each do |group|\n check_exists(group[:paths])\n # this is the Illumina recommended approach to combining these fastq files.\n # See the Casava 1.8 Users Guide for proof\n files_list = group[:paths].join(\" \")\n command = \"cat #{files_list} > #{group[:path]}\"\n execute command\n end\n end\n\n\n\n #\n # Returns an array of hashes, one for each\n # new combined fastq file to be created\n # Each hash will have the name of the\n # combined fastq file and an Array of\n # paths that the group contains\n #\n def group_files file_data, output_path, options = {:prefix => \"L\", :suffix => \".fastq.gz\", :exclude_undetermined => true}\n\t\t\t\t# alternatively inherit the parent class and call super???? \n\t\t\t\t# super \n\t\t\t\t# \t\n groups = {}\n file_data.each do |data|\n if data[:barcode] == \"Undetermined\" and options[:exclude_undetermined]\n log \"# Undetermined sample lane: #{data[:lane]} - name: #{data[:sample_name]}. Skipping\"\n next\n end\n \n group_key = name_for_data data, options\n \n if groups.include? group_key\n if groups[group_key][:sample_name] != data[:sample_name]\n raise \"ERROR: sample names not matching #{group_key} - #{data[:path]}:#{data[:sample_name]}vs#{groups[group_key][:sample_name]}\"\n end\n if groups[group_key][:lane] != data[:lane]\n raise \"ERROR: lanes not matching #{group_key} - #{data[:path]}\"\n end\n groups[group_key][:files] << data\n else\n group_path = File.join(output_path, group_key)\n groups[group_key] = {:group_name => group_key,\n :path => group_path,\n :sample_name => data[:sample_name],\n :read => data[:read],\n :lane => data[:lane],\n :files => [data]\n }\n end\n end\n \n # sort based on read set\n groups.each do |key, group|\n group[:files] = group[:files].sort {|x,y| x[:set] <=> y[:set]}\n group[:paths] = group[:files].collect {|data| data[:path]}\n end\n groups.values\n end\n\n\n\n\tend",
"def run\n puts \"Starting a new map reduce instance.\"\n\n # MAPPING\n puts \"Setting up the mapping process:\"\n\n map_dist = Distributor.from_file @data, 65536\n map_exec = Executor.auto map_dist.work, 'Mapping'\n\n puts \" - Number of chunks: #{map_dist.chunk_count}\"\n puts \" - Size of chunks: #{map_dist.chunk_size}\"\n puts \" - Number of items: #{map_dist.item_count}\"\n\n mapped = map_exec.script { Shell::Python.new @mapper }\n File.open(@st_map, 'w') { |f| f.write(mapped.join)} if @st_map \n\n # SORTING\n sorted = mapped.group_by { |m| m.split(', ')[0] }\n\n if @st_sort\n File.open(@st_sort, 'w') { |f| f.write sorted.values.flatten.join }\n end\n\n # REDUCING\n puts \"Setting up the reducing process:\"\n\n red_dist = Distributor.from_list sorted, 65536\n red_exec = Executor.auto red_dist.work, 'Reducing'\n\n puts \" - Number of chunks: #{red_dist.chunk_count}\"\n puts \" - Size of chunks: #{red_dist.chunk_size}\"\n puts \" - Number of items: #{red_dist.item_count}\"\n\n reduced = red_exec.script { Shell::Python.new @reducer }\n File.open(@st_red, 'w') { |f| f.write(reduced.join)} if @st_red\n end",
"def exec_seq(seq,blast_query)\n\n $LOG.debug \"[#{self.class.to_s}, seq: #{seq.seq_name}]: searching sequence repeated at input file\" \n\n [email protected]_param('truncated_input_file')\n \n blast = BatchBlast.new(\"-db #{fasta_input}\" ,'blastn',\" -task blastn-short -searchsp #{SIZE_SEARCH_IN_IGNORE} -evalue #{@params.get_param('blast_evalue_ignore_repeated')} -perc_identity #{@params.get_param('blast_percent_ignore_repeated')}\") #get contaminants\n \n p_start = @params.get_param('piro_repeated_start').to_i\n p_length = @params.get_param('piro_repeated_length').to_i\n \n \n blast_table_results = blast.do_blast(seq.seq_fasta[p_start,p_length]) #rise seq to contaminants executing over blast\n \n #blast_table_results = BlastTableResult.new(res)\n \n \n type = \"ActionIgnoreRepeated\" \n \n # @stats[:rejected_seqs]={} \n \n actions=[] \n blast_table_results.querys.each do |query|\n \n # puts \"BLAST IGUALES:\"\n # puts res.join(\"\\n\") \n if query.size>1 \n names = query.hits.collect{ |h| \n if h.align_len > (p_length-2)\n h.subject_id\n end\n }\n \n names.compact! \n \n # puts \"IGUALES:\" + names.size.to_s \n # puts names.join(',') \n \n if !names.empty?\n names.sort!\n\t\t\t\t \n if (names[0] != seq.seq_name) # Add action when the sequence is repeated \n\t\t\t\t # if true \n\t\t\t\t a = seq.new_action(0,0,type)\n\t\t\t\t a.message = seq.seq_name + ' equal to ' + names[0] \n\t\t\t\t actions.push a\n\t\t\t\t seq.seq_rejected=true \n\t\t\t\t seq.seq_rejected_by_message='repeated'\n\t\t\t\t seq.seq_repeated=true \n\t\t\t\t \n # @stats[:rejected_seqs]={'rejected_seqs_by_repe' => 1} \n add_stats('rejected_seqs','rejected_seqs_by_repe') \n # puts \"#{names[0]} != #{seq.seq_name} >>>>>>\" \n\t\t\t\t end \n end\n \n end \n \n end \n \n seq.add_actions(actions)\n \n end",
"def parse_bam_to_intermediate_files(out_prefix)\n script=File.join(File.dirname(__FILE__),\"bam_to_insert_size_bed.awk\")\n cmd = @conf.cluster_cmd_prefix(free:1, max:12, sync:true, name:\"bed_prep_#{File.basename(@bam.path)}\") +\n %W(/bin/bash -o pipefail -o errexit -c)\n filt = \"samtools view #{@bam.path} | awk -f #{script} -vbase=#{out_prefix} -vendness=\"\n if @bam.paired?\n filt += \"pe\"\n else\n filt += \"se -vsize=#{@bam.fragment_size}\"\n end\n cmd << \"\\\"#{filt}\\\"\"\n puts cmd.join(\" \") if @conf.verbose\n unless system(*cmd)\n @errors << \"Failure prepping bedfiles for #{@bam} #{$?.exitstatus}\"\n return false\n end\n if @bam.paired?\n IO.foreach(out_prefix+FRAGMENT_SIZE_SUFFIX) do |line|\n @bam.fragment_size = line.chomp.to_i\n break\n end\n end\n IO.foreach(out_prefix+\"_num_alignments.txt\") do |line|\n @bam.num_alignments = line.chomp.to_i\n break\n end\n return true\n end",
"def run_blast_with_splitting evalue, threads, bin1, bin2\n # puts \"running blast by splitting input into #{threads} pieces\"\n if !File.exist?(@output1)\n blasts=[]\n files = split_input(@query, threads)\n threads = [threads, files.length].min\n files.threach(threads) do |thread|\n cmd1 = \"#{bin1} -query #{thread} -db #{@working_dir}/#{@target_name} \"\n cmd1 << \" -out #{thread}.blast -evalue #{evalue} \"\n cmd1 << \" -outfmt \\\"6 std qlen slen\\\" \"\n if bin1=~/blastn/\n cmd1 << \" -dust no \"\n elsif bin1=~/blastx/ or bin1=~/blastp/ or bin1=~/tblastn/\n cmd1 << \" -seg no \"\n end\n cmd1 << \" -soft_masking false \"\n cmd1 << \" -max_target_seqs 50 \"\n cmd1 << \" -num_threads 1\"\n if !File.exists?(\"#{thread}.blast\")\n blast1 = Cmd.new(cmd1)\n blast1.run\n if !blast1.status.success?\n raise RuntimeError.new(\"BLAST Error:\\n#{blast1.stderr}\")\n end\n end\n blasts << \"#{thread}.blast\"\n end\n cat_cmd = \"cat \"\n cat_cmd << blasts.join(\" \")\n cat_cmd << \" > #{@output1}\"\n catting = Cmd.new(cat_cmd)\n catting.run\n if !catting.status.success?\n raise RuntimeError.new(\"Problem catting files:\\n#{catting.stderr}\")\n end\n files.each do |file|\n File.delete(file) if File.exist?(file)\n end\n blasts.each do |b|\n File.delete(b) # delete intermediate blast output files\n end\n end\n\n if !File.exist?(@output2)\n blasts=[]\n files = split_input(@target, threads)\n threads = [threads, files.length].min\n files.threach(threads) do |thread|\n cmd2 = \"#{bin2} -query #{thread} -db #{@working_dir}/#{@query_name} \"\n cmd2 << \" -out #{thread}.blast -evalue #{evalue} \"\n cmd2 << \" -outfmt \\\"6 std qlen slen\\\" \"\n cmd2 << \" -max_target_seqs 50 \"\n cmd2 << \" -num_threads 1\"\n if !File.exists?(\"#{thread}.blast\")\n blast2 = Cmd.new(cmd2)\n blast2.run\n if !blast2.status.success?\n raise RuntimeError.new(\"BLAST Error:\\n#{blast2.stderr}\")\n end\n end\n blasts << \"#{thread}.blast\"\n end\n cat_cmd = \"cat \"\n cat_cmd << blasts.join(\" \")\n cat_cmd << \" > #{@output2}\"\n catting = Cmd.new(cat_cmd)\n catting.run\n if !catting.status.success?\n raise RuntimeError.new(\"Problem catting files:\\n#{catting.stderr}\")\n end\n files.each do |file|\n File.delete(file) if File.exist?(file)\n end\n blasts.each do |b|\n File.delete(b) # delete intermediate blast output files\n end\n end\n\n end",
"def start \n `killall gammu-smsd` && puts(\"Killing Daemons!\")\n puts \"Loading Daemons......\"\n @phones.values.each do |provider|\n fork do\n exec \"gammu-smsd -c #{@datafolder+provider} &\"\n end\n end\n end",
"def processFlowcell(fcName)\n puts \"Starting analysis for flowcell : \" + fcName.to_s\n currDir = Dir.pwd\n Dir::chdir(\"/stornext/snfs5/next-gen/Illumina/ipipe/lib\")\n cmd = \"ruby QseqGenerator.rb \" + fcName.to_s\n puts \"Running command : \" + cmd.to_s\n#=begin\n output = `#{cmd}`\n puts output\n#=end\n Dir::chdir(currDir)\n end",
"def processFlowcell(fcName)\n puts \"Starting analysis for flowcell : \" + fcName.to_s\n currDir = Dir.pwd\n Dir::chdir(\"/stornext/snfs5/next-gen/Illumina/ipipe/lib\")\n cmd = \"ruby QseqGenerator.rb \" + fcName.to_s\n puts \"Running command : \" + cmd.to_s\n#=begin\n output = `#{cmd}`\n puts output\n#=end\n Dir::chdir(currDir)\n end",
"def multistamp(primary_file, stamp_file, output); end",
"def bowtie_map1(bowtie_index, input_file, input_format, output_file)\n\t\tif input_format == 'fasta'\n\t\t\tstdin, stdout, stderr, t = Open3.popen3(\"bowtie2 -x #{bowtie_index} -f -U #{input_file} | samtools view -bS - > #{output_file}\")\n\t\telse\n\t\t\tstdin, stdout, stderr, t = Open3.popen3(\"bowtie2 -x #{bowtie_index} -q -U #{input_file} | samtools view -bS - > #{output_file}\")\n\t\tend\n\t\tsystem_exitcode(t, stderr, 'Bowtie2')\n\tend",
"def before_results(controller_params)\n @num_seqs = 0\n @header = []\n @aln_blocks = []\n \n resfile = File.join(job_dir, jobid+\".out\")\n raise(\"ERROR with resultfile!\") if !File.readable?(resfile) || !File.exists?(resfile) || File.zero?(resfile)\n res = IO.readlines(resfile).map {|line| line.chomp}\n \n sequencefile = File.join(job_dir, jobid+\".fasta\")\n seqs = IO.readlines(sequencefile).map {|line| line.chomp}\n \n hits = []\n res.each do |line|\n \thits << line.split(/ /)[0]\n end\n logger.debug \"Hits: #{hits.inspect}\"\n\n seqfile = File.join(job_dir, jobid+\".seq\")\n \n # write one sequencs of each cluster in seqfile\n check = false\n File.open(seqfile, 'w') do |file|\n seqs.each do |line|\n if (line =~ /^>(.*)$/)\n header = ($1.split(/ /))[0]\n check = false\n if (hits.include?(header) || (header =~ /gi\\|(\\d+)\\|/ && hits.include?($1)))\n file.write(line + \"\\n\")\n check = true\n end\n else\n if check\n file.write(line + \"\\n\")\n end\n end\n end\n end\n\n\n # read in sequences for output\n res = IO.readlines(seqfile).map {|line| line.chomp}\n\n seq = \"\"\n res.each do |line|\n if (line =~ /^>/)\n if (!seq.empty?) then @aln_blocks.push(seq) end\n @header.push(line)\n @num_seqs += 1\n seq = \"\"\n else\n seq += line + \"\\n\"\n end\n end\n if (!seq.empty?) then @aln_blocks.push(seq) end\n \n # write sequences in lines with 80 characters\n @aln_blocks.map! do |seq|\n \ti = 0\n \tnew_seq = \"\"\n \twhile (i+80 < seq.length)\n \t\tnew_seq += seq.slice(i...i+80) + \"\\n\"\n \t\ti += 80\n \tend\n \tnew_seq += seq.slice(i...i+80) + \"\\n\"\n end\n end",
"def run\n\t\t(1..100).each do |student|\n\t\t\t(1..100).each do |locker|\n\t\t\t\tputs \"#{student} at #{locker}\"\n\t\t\tend\n\t\tend\n\tend",
"def run_pasv_cli\n exit_status = nil\n # We need an outdir. The PASV CLI creates this dir so we can't create a tmpdir. Best we can do is try to give it a unique name.\n #\n # %24N yoctosecond (24 digits)\n date_fmt = \"%Y_%m_%d_%H_%M_%S_%L_%24N\"\n\n outdir = nil\n # Keep looping until you get a dirname that doesn't currently exist.\n loop do\n time = Time.new.strftime date_fmt\n token = SecureRandom.hex(64)\n\n # The chances of making a duplicate here from some other thread or OS operation should be LOW\n outdir = File.join Dir.tmpdir, \"#{token}_#{time}\"\n\n break unless Dir.exist? outdir\n end\n\n\n\n # First we need to write the files to some Tempfile\n # fsync\n\n\n # defaults\n\n if self.aligner == \"clustalo\"\n aln_params = '\\--threads 1'\n io_format_str = '\\-i %s \\-o %s'\n elsif self.aligner == \"mafft\"\n aln_params = '\\--thread 1 \\--quiet'\n io_format_str = '%s > %s'\n end\n\n p [aln_params, io_format_str]\n\n Tempfile.open do |ref_f|\n self.ref_file.download do |data|\n ref_f.puts data\n end\n\n # Ensure the data is actually written to file now.\n ref_f.fsync\n\n Tempfile.open do |query_f|\n self.query_file.download do |data|\n query_f.puts data\n end\n\n query_f.fsync\n\n # And now we build the PASV command while the tempfiles are still in scope.\n cmd = \"ruby #{PasvsHelper::PASV_EXE} --refs #{ref_f.path} --queries #{query_f.path} --aligner #{self.aligner} --alignment-parameters '#{aln_params}' --io-format-string '#{io_format_str}' --start #{self.roi_start} --end #{self.roi_end} --threads #{PasvsHelper::THREADS} --outdir #{outdir} --min-count #{PasvsHelper::MIN_COUNT} 500 501\"\n\n puts \"Command will be: #{cmd}\"\n\n PasvsHelper::RyaTime.time_it cmd, Rya::AbortIf.logger do\n exit_status = PasvsHelper::RyaProcess.run_it cmd\n end\n end\n end\n\n # If the exit_status is zero, we need to zip up the tmp folder and give it as a download.\n puts exit_status\n\n if exit_status.success?\n outdir\n end\n end",
"def streaming_statement cmd, hdfs, files\n puts 'Streaming statement:'\n stmt = \"#{@hadoop_cmd} jar #{@streaming_jar} \" <<\n \"-files #{files.map { |f| \"#{File.join @fs_default_name, hdfs, f}\" }.join ','} \" <<\n \"-input #{File.join @fs_default_name, hdfs, 'hadoop-samtools-streaming-input.txt'} \" <<\n \"-output \\\"#{File.join hdfs, 'hadoop-samtools-' + cmd.split(/\\s+/)[0] + '_' + Time.now.to_s.split(/\\s+/).first(2).join.chars.keep_if { |c| c=~ /\\d/ }.join}\\\" \" <<\n \"-mapper \\\"#{@samtools} #{cmd}\\\" \" <<\n \"-reducer NONE\"\n puts stmt\n stmt\n end",
"def run_program()\n final_words()\n segmented_output()\n end",
"def run_tests()\n Signal.trap(\"CLD\") {@process_counter += 1}\n for setting in @settings\n Process.wait if @process_counter <= 0\n @process_counter -= 1\n fork do\n temp_name, log = copy_and_edit(setting)\n puts \"Running: \" + setting[:material] + \" \" + setting[:length] + \"cm \" + setting[:energy] + \"MeV\"\n system(@output_dir + \"Hadr06 \" + temp_name + \" > \" + log)\n relocate(setting)\n clean()\n end\n end\nend",
"def make_blastdbs! fnames, cpus=4\n suffix = BLAST_DB_SUFFIX\n outfiles = fnames.map { |fname| fname + suffix }\n\n Parallel.each(fnames, in_processes: cpus) do |fname|\n cmd = \"diamond makedb --threads 1 --in #{fname} \" +\n \"--db #{fname}#{BLAST_DB_SUFFIX}\"\n\n Process.run_and_time_it! \"Make db\", cmd\n end\n\n outfiles\n end",
"def query_pairwise(seq1, seq2)\n tf = Tempfile.open('sim4')\n tf.print seq1.to_fasta('seq1', 70)\n tf.close(false)\n tf2 = Tempfile.open('seq2')\n tf2.print seq1.to_fasta('seq2', 70)\n tf2.close(false)\n r = exec_local(tf.path, tf2.path)\n tf.close(true)\n tf2.close(true)\n r\n end",
"def output_usage(out)\n out.puts <<-EOF\nanalyze_sequence_to_snps.rb -c PATH_TO_CONFIG.YML -o PATH_TO_BASE_OUTPUT_DIR SAMPLE_ID [SAMPLE_ID]\n\nOptions\n-h, --help Display this help message\n-v, --version Display the version information\n-V, --verbose Increased verbosity of output\n-d, --delay INT Delay a random between 0 & INT before submitting job. Default 30 seonds\n-c, --config FILE Specify the configuration yaml file of options for analysis\n-o, --output DIR Specify the output directory prefix, all results will be saved under this directory\n-l, --local Run the analyze script locally, not with initial SGE submit\n-q, --qsub OPTS Additional options given to each qsub call\n EOF\nend",
"def markDupCommand()\n cmd = \"time java \" + @heapSize + \" -jar \" + @picardPath + \"/MarkDuplicates.jar I=\" +\n @sortedBam + \" O=\" + @markedBam + \" \" + @picardTempDir + \" \" +\n \"MAX_RECORDS_IN_RAM=\" + @maxRecordsInRam.to_s + \" AS=true M=metrics.foo \" +\n @picardValStr \n return cmd\n end",
"def import_all_tab_files_parallel(tabs_list, dataset_id, task_id, root_url)\n max_parallelism = 10\n running_parallelism = 0\n wait_seconds = 10\n\n tabs_list.each { |tab_object|\n tab_file = tab_object[\"MzTab_file\"]\n\n running_parallelism += 1\n\n fork do\n #import_dataset_tab_psm_file(dataset_id, task_id, tab_file, root_url)\n import_tab_cmd = \"ruby ./populate_parallel_tab.rb \"\n import_tab_cmd += dataset_id + \" \"\n import_tab_cmd += task_id + \" \"\n import_tab_cmd += tab_file + \" \"\n import_tab_cmd += root_url\n\n puts import_tab_cmd\n `#{import_tab_cmd}`\n\n abort\n end\n\n sleep(wait_seconds)\n if running_parallelism == max_parallelism\n Process.waitall\n running_parallelism = 0\n end\n }\n\n Process.waitall\nend",
"def perform\n params_dump\n\n ### KEEPING FORMER ROUNDS\n #@commands << \"cp #{@outfile} #{@outfile}.former\" \n # Export variable needed for HHSuite\n #@commands << \"export HHLIB=#{HHLIB} \"\n #@commands << \"export PATH=$PATH:#{HHSUITE}\" \n \n # cmd for blast run\n @commands << \"source #{SETENV}\" \n @commands << \"echo 'Starting BLAST search' &> #{job.statuslog_path}\"\n @commands << \"#{CSBLAST}/bin/csblast -i #{@infile} -j #{@rounds} -h #{@e_thresh} -D #{CSBLAST}/data/K4000.crf #{@alignment} --blast-path #{BLAST}/bin -e #{@expect} -F #{@filter} -G #{@gapopen} -E #{@gapext} -v #{@descriptions} -b #{@alignments} -T T -o #{@outfile} -d \\\"#{@db_path}\\\" -I T -a 1 #{@other_advanced} >>#{job.statuslog_path}\"\n \n @commands << \"echo 'Finished BLAST search' >> #{job.statuslog_path}\"\n # run perl script to fix blast errors. TODO: Find out what script does \n @commands << \"echo 'Fixing BLAST errors' >> #{job.statuslog_path}\" \n @commands << \"#{UTILS}/fix_blast_errors.pl -i #{@outfile} &>#{@basename}.log_fix_errors\"\n # run perl script to visualize blast results. TODO: Find out what script does\n @commands << \"echo 'Visualizing BLAST Output' >> #{job.statuslog_path}\" \n @commands << \"#{UTILS}/blastviz.pl #{@outfile} #{job.jobid} #{job.job_dir} #{job.url_for_job_dir_abs} &> #{@basename}.blastvizlog\";\n # run perl script to process blast history. TODO: Find out what script does\n @commands << \"echo 'Generating Blast Histograms... ' >> #{job.statuslog_path}\"\n @commands << \"#{UTILS}/blasthisto.pl #{@outfile} #{job.jobid} #{job.job_dir} &> #{@basename}.blasthistolog\";\n \n # run perl script to create alignment\n @commands << \"echo 'Processing Alignments... ' >> #{job.statuslog_path}\"\n @commands << \"#{UTILS}/alignhits_html.pl #{@outfile} #{@basename}.align -fas -no_link -e #{@expect}\"\n # run perl script to reformat alignment TODO: Find out what script does\n @commands << \"reformat.pl fas fas #{@basename}.align #{@basename}.ralign -M first -r\"\n # TODO: Find out what script does\n @commands << \"if [ -s #{@basename}.ralign ]; then hhfilter -i #{@basename}.ralign -o #{@basename}.ralign -diff 50; fi\"\n # TODO: Find out what script does\n @commands << \"#{RUBY_UTILS}/parse_csiblast.rb -i #{@basename}.csblast -o #{@basename}.csblast\"\n # Generate Jalview Output from alignment data\n @commands << \"echo 'Creating Jalview Input... ' >> #{job.statuslog_path}\"\n @commands << \"#{RUBY_UTILS}/parse_jalview.rb -i #{@basename}.ralign -o #{@basename}.j.align\" \n # TODO: Find out what script does\n @commands << \"reformat.pl fas fas #{@basename}.j.align #{@basename}.j.align -r\"\n\n\n @commands << \"source #{UNSETENV}\" \n\n logger.debug \"Commands:\\n\"[email protected](\"\\n\")\n # Submit generated cmd list to queue\n queue.submit(@commands)\n\n end",
"def process(files, parallel, test, output_path)\n\n summaries = []\n files.each do |file|\n\n mediainfo = mediainfo(file)\n\n results = []\n tx_files = duplicate(file, output_path, parallel - 1)\n tx_files << file\n\n start_time = Time.now\n tx(tx_files, results, test, mediainfo, output_path)\n wait_for_completion\n end_time = Time.now\n\n summary = TestSummary.new(File.basename(file), results, start_time, end_time, mediainfo[:duration])\n summaries << summary\n end\n\n summaries\nend",
"def runAlgosLocally(algosToRun)\n\tfor algoToRun in algosToRun\n\t\trunalgo(algoToRun[0], algoToRun[1])\n\t\t#system \"ruby #{$script_dir_for_cluster}/runalgo.rb #{algoToRun[0]} #{algoToRun[1]}\"\n\tend\nend",
"def getFtsSequences\n @gb.each_cds do |ft|\n ftH = ft.to_hash\n loc = ft.locations\n loc = \"c#{ft.locations[0].to_s}\" if ft.locations[0].strand == -1\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n dna = getDna(ft,@gb.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{loc}|#{ftH[\"protein_id\"][0]}|#{gene[0]}|#{product[0]}|#{@org}\",60)\n puts seqout\n end\nend",
"def perform\n params_dump\n @commands << \"#{PEAKS} -f #{@infile} -s #{@size} -a #{@string} -o #{@outfile} &> #{job.statuslog_path}\"\n logger.debug \"Commands:\\n\"[email protected](\"\\n\")\n queue.submit(@commands)\n end",
"def buildAlignCommand(readFile, outputFile)\n cmd = \"time \" + @bwaPath + \" aln -t \" + @cpuCores.to_s + \" -I \" +\n @reference + \" \" + readFile + \" > \" + outputFile\n return cmd\n end",
"def bam2fastq(input_file, output_file, phred_quality)\n \t\tFile.open(output_file, 'w') do |output|\n\t\t\tinput_file.each do |line|\n \t\t\tline = line.strip.split(/\\s+/)\n \n \t\t\tflag = line[1].to_i\n \t\t\tflag & 0x40 > 0 ? mate = '1' : mate = '2'\n \t\t\t\n \t\t\tqname, sequence, quality = line[0], line[9], line[10] \n \t\t\toutput.puts \"@#{qname}/#{mate}\", sequence, '+', quality if Alignment.quality_ok?(quality, phred_quality)\n \t\tend\n \tend\n \t$logfile.puts \"#{Time.new.strftime(\"%c\")}: Converted unmapped reads into fastq-format.\"\t\n\tend",
"def by_lane_index(lane, index, output)\n dir = options.dir || Dir.pwd \n paired = options.paired\n append = options.append\n index_str = \"%03d\" % index\n strand_lambda = lambda do |dir, strand| #Forward\n strand_number = case strand \n when :forward then 1\n when :reverse then 2\n end \n invoke :by_file, [Dir[File.join(dir,\"#{index_str}/s_#{lane}_#{strand_number}_*_qseq.txt\")], \"#{output}_#{strand}\"], :paired => paired, :append => append, :dir => dir\n end\n\n forward_daemon_options = {\n :app_name => \"forward_#{lane}_#{index_str}\",\n :ARGV => ['start'],\n :log_output => true,\n :dir_mode => :normal,\n :dir => dir}\n forward_task = ::Daemons.run_proc(\"forward_#{lane}_#{index_str}\",forward_daemon_options ) do\n strand_lambda.call(dir,:forward) \n end #daemon1\n\n #Reverse\n if options.paired\n reverse_daemon_options = {\n :app_name => \"reverse_#{lane}_#{index_str}\",\n :ARGV => ['start'],\n :log_output => true,\n :dir_mode => :normal,\n :dir => dir} \n reverse_task = ::Daemons.run_proc(\"reverse_#{lane}_#{index_str}\",reverse_daemon_options) do\n strand_lambda.call(dir, :reverse)\n end #daemon2\n end #ifpaired\n end",
"def bam2fastq(input_file, output_file, phred_quality)\n \t\tFile.open(output_file, 'w') do |output|\n\t\t\tinput_file.each do |line|\n \t\t\tline = line.strip.split(/\\s+/)\n \n \t\t\tflag = line[1].to_i\n \t\t\tflag & 0x40 > 0 ? mate = '1' : mate = '2'\n \t\t\t\n \t\t\tqname, sequence, quality = line[0], line[9], line[10] \n \t\t\toutput.puts \"@#{qname}/#{mate}\", sequence, '+', quality if Alignment.quality_ok?(quality, phred_quality)\n \t\tend\n \tend\n \t$logfile.puts \"#{Time.new.strftime(\"%c\")}: Converted unmapped.bam into fastq-format.\"\t\n\tend",
"def start_consumer\n ConsumerCnt.times.collect do\n IO.popen(\"ruby lib/consumer.rb #{__id__}\", 'wb+')\n end\nend",
"def liftchain(outfile)\n #Future: Add option to recycle old chainfile #\n processes = CONFIG[:processes]\n blat_opts = CONFIG[:blat_opts]\n \n cp CONFIG[:source_fa], \"#{RUNDIR}/source.fa\"\n cp CONFIG[:target_fa], \"#{RUNDIR}/target.fa\"\n\n to_2bit \"#{RUNDIR}/source.fa\"\n to_2bit \"#{RUNDIR}/target.fa\"\n\n to_sizes \"#{RUNDIR}/source.2bit\"\n to_sizes \"#{RUNDIR}/target.2bit\"\n\n # Partition target assembly.\n sh \"faSplit sequence #{RUNDIR}/target.fa #{processes} #{RUNDIR}/chunk_\"\n\n parallel Dir[\"#{RUNDIR}/chunk_*.fa\"],\n 'faSplit -oneFile size %{this} 5000 %{this}.5k -lift=%{this}.lft &&' \\\n 'mv %{this}.5k.fa %{this}'\n\n # BLAT each chunk of the target assembly to the source assembly.\n parallel Dir[\"#{RUNDIR}/chunk_*.fa\"],\n \"blat -noHead #{blat_opts} #{RUNDIR}/source.fa %{this} %{this}.psl\"\n\n parallel Dir[\"#{RUNDIR}/chunk_*.fa\"],\n \"liftUp -type=.psl -pslQ -nohead\" \\\n \" %{this}.psl.lifted %{this}.lft warn %{this}.psl\"\n\n # Derive a chain file each from BLAT's .psl output files.\n parallel Dir[\"#{RUNDIR}/chunk_*.psl.lifted\"],\n 'axtChain -psl -linearGap=medium' \\\n \" %{this} #{RUNDIR}/source.2bit #{RUNDIR}/target.2bit %{this}.chn\"\n\n # Sort the chain files.\n parallel Dir[\"#{RUNDIR}/chunk_*.chn\"],\n 'chainSort %{this} %{this}.sorted'\n\n # Combine sorted chain files into a single sorted chain file.\n sh \"chainMergeSort #{RUNDIR}/*.chn.sorted | chainSplit #{RUNDIR} stdin -lump=1\"\n mv \"#{RUNDIR}/000.chain\", \"#{RUNDIR}/combined.chn.sorted\"\n\n # Derive net file from combined, sorted chain file.\n sh 'chainNet' \\\n \" #{RUNDIR}/combined.chn.sorted #{RUNDIR}/source.sizes #{RUNDIR}/target.sizes\" \\\n \" #{RUNDIR}/combined.chn.sorted.net /dev/null\"\n\n # Subset combined, sorted chain file.\n sh 'netChainSubset' \\\n \" #{RUNDIR}/combined.chn.sorted.net #{RUNDIR}/combined.chn.sorted\" \\\n \" #{RUNDIR}/liftover.chn\"\nend",
"def test_abcompare_convergence\n system \"cd #{ROOT_DIR} && RUBYLIB=lib ./exe/abcompare --fail-on-divergence --pvalue=0.05 --min-trials=20 --max-trials=20 --iters-per-trial=1 'echo bob' 'sleep 0.1' 2>&1 >> /dev/null\"\n assert $?.success?\n end",
"def run_demo(directory)\n # uses graphs passed to driver class when instantiated\n @graphs.each do |graph|\n before = Time.now\n vertex_states = self.send(@algorithm,graph,0)\n after = Time.now\n running_time = after - before\n n = graph.vertices.count\n end_vertex = n - 1\n # reconstructs the path from the processed vertex states\n path = construct_path(vertex_states,end_vertex)\n # get the cost from the last node in the graph\n total_cost = vertex_states[end_vertex].shortest_distance\n # write to file the path and cost\n output_to_file(directory,@algorithm, path, total_cost,end_vertex, running_time)\n end\n end",
"def move(pid, num_punters, map, claimed, rem, setup=false, tbl=nil)\n sites = map['sites']\n rivers = map['rivers']\n mines = map['mines']\n _format = \"\"\"\nInvoke C++ program with the following format:\nn m k pid np\ns_1 t_1 c_1\n...\ns_m t_m c_m (edges)\na_1 ... a_k (mines)\nmode\nextra\n\n0 <= s_i, t_i < m\n-1 <= c_i < np (-1: not claimed)\n0 <= a_i < n\n\n\nif mode == 'state'\n extra == ''\n The C++ program should return\n 'tbl (state)'\n where state is a string representing a state (without spaces)\nif mode == 'run'\n extra looks like:\ntbl\nai_kind\n The C++ program should return\n 'pass'\n or\n 'claim s t'\n in one line.\n \"\"\"\n n = sites.size\n m = rivers.size\n k = mines.size\n np = num_punters\n edges = []\n cl = {}\n for c in claimed\n cl[[c[1], c[2]]] = c[0]\n end\n for e in rivers\n col = -1\n if cl[[e['source'], e['target']]]\n col = cl[[e['source'], e['target']]]\n end\n edges << [e['source'], e['target'], col]\n end\n io = IO.popen(File.expand_path(File.dirname($0)) + '/core', 'r+')\n io.puts(\"#{n} #{m} #{k} #{pid} #{np} #{rem}\")\n for i in 0 ... m\n io.puts(edges[i].join(' '))\n end\n mine_ids = []\n for i in 0 ... k\n mine_ids << (mines[i]).to_s\n end\n io.puts(mine_ids.join(' '))\n ai_kind = @ai_kind\n if ai_kind == 'hybrid'\n # Choose AI type by np, size, and so on\n if np == 2\n ai_kind = 'two_player_minmax'\n elsif np >= 4\n ai_kind = 'mine_connect'\n else\n ai_kind = 'greedy'\n end\n end\n if setup\n io.puts('setup')\n else\n io.puts('run')\n io.puts(tbl)\n io.puts(ai_kind)\n end\n io.close_write\n eval = 0\n STDERR.puts(\"playing as punter #{pid} (total = #{num_punters})\")\n while answer = io.gets.chomp.split\n if answer[0] != 'info'\n break\n end\n # info eval (turns) (value)\n if answer[1] == 'eval'\n turns = answer[2].to_i\n eval = answer[3].to_i\n if turns >= 0\n STDERR.puts(\"evaluation: turns=#{turns}, value=#{eval}\")\n else\n STDERR.puts(\"full evaluation: value=#{eval}\")\n end\n end\n end\n if answer[0] == 'pass'\n return {'pass' => {'punter' => pid}}, eval\n end\n if answer[0] == 'claim'\n s = answer[1].to_i\n t = answer[2].to_i\n return {'claim' => {'punter' => pid, 'source' => s, 'target' => t}}, eval\n end\n if answer[0] == 'tbl'\n STDERR.puts(\"Got tbl (tbl size = #{answer[1].size})\")\n return answer[1]\n end\n end",
"def help()\n $stderr.puts \"Usage: ruby __.rb -x cross_match_output -r reference.fasta -o prefix_of_output [-m minscore -s max_substitution -g max_gap] [-c]\"\nend",
"def split_refseq\n # prepare output files\n system(%Q[cut -f4 #{$prepare_dir}/refseq_genes_result.tsv | cut -c1-5 | sort | uniq > #{$prepare_dir}/refp_prefix_list.txt ]) # get exist prefix list of protein_id\n FileUtils.mkdir_p(\"#{$prepare_dir}/refp\") unless File.exist?(\"#{$prepare_dir}/refp\")\n refp_output = {}\n File.open(\"#{$prepare_dir}/refp_prefix_list.txt\") do |f|\n f.each_line do |line|\n prefix = line.chomp.strip\n refp_output[prefix] = File.open(\"#{$prepare_dir}/refp/#{prefix}.dat\", \"w\")\n end\n end\n refp_output[\"no_protein_id\"] = File.open(\"#{$prepare_dir}/refp/no_protein_id.dat\", \"w\") # protein_id is optional\n\n File.open(\"#{$prepare_dir}/refseq_genes_result.tsv\") do |f|\n f.each_line do |line|\n columns = line.chomp.strip.split(\"\\t\")\n prefix = (columns[3].nil? || columns[3] == \"\") ? \"no_protein_id\" : columns[3][0..4] # protein_id is optional\n refp_output[prefix].puts line.chomp.strip\n end\n end\n refp_output.each do |k, v|\n v.flush\n v.close\n end\nend",
"def streaming_statement cmd, hdfs, files\n puts 'Streaming statement:'\n stmt = \"#{@hadoop_cmd} jar #{@streaming_jar} \" <<\n \"-files #{files.map { |f| \"#{File.join @fs_default_name, hdfs, f}\" }.join ','} \" <<\n \"-input #{File.join @fs_default_name, hdfs, 'hadoop-bcftools-streaming-input.txt'} \" <<\n \"-output \\\"#{File.join hdfs, 'hadoop-bcftools-' + cmd.split(/\\s+/)[0] + '_' + Time.now.to_s.split(/\\s+/).first(2).join.chars.keep_if { |c| c=~ /\\d/ }.join}\\\" \" <<\n \"-mapper \\\"#{@bcftools} #{cmd}\\\" \" <<\n \"-reducer NONE\"\n puts stmt\n stmt\n end",
"def print_hitnumdist(io, run)\n\n io.puts \"<h3>hit number distributions</h3>\"\n io.puts \"<div style=\\\"text-align: center;\\\">\"\n\n io.puts \"<table>\"\n (1..4).each { |row|\n io.puts \" <tr>\"\n (1..6).each { |col|\n ch = 48 + 6*(row-1) + (col-1)\n io.puts \" <td><a href=\\\"fig/#{run}/lehit#{ch}.gif\\\"><img src=\\\"fig/#{run}/thumb/lehit#{ch}.gif\\\" alt='' /></a></td>\"\n }\n io.puts \" </tr>\" \n }\n io.puts \"</table>\" \n\n io.puts \"<table>\"\n (1..$mod).each { |row|\n io.puts \" <tr>\"\n (1..$pad).each { |col|\n ch = $off + $pad*(row-1) + (col-1)\n io.puts \" <td><a href=\\\"fig/#{run}/tehit#{ch}.gif\\\"><img src=\\\"fig/#{run}/thumb/tehit#{ch}.gif\\\" alt='' /></a></td>\"\n }\n io.puts \" </tr>\" \n }\n io.puts \"</table>\" \n\n io.puts \"</div>\"\n\nend",
"def main \n settings = {}\n settings[\"--missing\"]=0.8\n settings[\"--mq\"]=20\n settings[\"--zmq\"]=0.4 # ((MQ0 / (1.0 * DP)) > $zmq \n settings[\"--freq\"] = -1 # default no filter\n settings[\"--ac\"] = 0 \n settings[\"--maxfreq\"]=1 # default no filter\n # ab=0.95 # allele balance\n settings[\"--qual\"]=50.0 # min qual\n# settings[\"--clusterWinSize\"]=10 # --clusterWindowSize = 10\n settings[\"--HRun\"]=5 # homopolymer\n settings[\"--qd\"]=5.0 # qual over depth cutoff \n settings[\"--sb\"]=-0.1 # strand bias\n settings[\"--minDP\"]=5 # average DP per sample, need to multiply by nsample\n \n optHash = getopt()\n vcf = optHash[\"--vcf\"]\n \n settings.keys.sort.each do |s|\n if optHash.key?(s)\n settings[s] = optHash[s].to_f\n end\n end\n \n# if optHash.key?(\"--indelMask\")\n# settings[\"--indelMask\"] = optHash[\"--indelMask\"]\n# end\n \n nsample=countSamples(vcf)\n \n filterVCF(vcf,settings,nsample) # gt: gene -> pos -> sample -> genotype, \n\nend",
"def before_perform \n # Init file vars \n\t @basename = File.join(job.job_dir, job.jobid)\n @infile = @basename+\".fasta\"\n @outfile = @basename+\".csblast\"\n \n # Save either the pasted Sequence from frontend or uploaded Sequence File to in file\n params_to_file(@infile, 'sequence_input', 'sequence_file')\n @informat = params['informat'] ? params['informat'] : 'fas'\n # Reformat the input sequence to match fasta format (perl script call)\n reformat(@informat, \"fas\", @infile)\n # necessary for resubmitting domains via slider\n\t File.copy(@infile, @basename+\".in\")\t\n \n # init cmd container\n @commands = []\n\n # init frontend params\n @inputmode = params['inputmode']\n @expect = params['evalue']\n @filter = params['filter'] ? 'T' : 'F'\n @mat_param = params['matrix']\n @other_advanced = params['otheradvanced']\n @descriptions = params['descr']\n @alignments = params['alignments']\n @db_path = params['std_dbs'].nil? ? \"\" : params['std_dbs'].join(' ')\n @db_path = params['user_dbs'].nil? ? @db_path : @db_path + ' ' + params['user_dbs'].join(' ')\n \n @ungapped_alignment = params['ungappedalign'] ? 'F' : 'T'\n @e_thresh = params['evalfirstit']\n @smith_wat = params['smithwat'] ? 'T' : 'F'\n @rounds = params['rounds']\n @fastmode = params['fastmode'] ? 'T' : 'F'\n @alignment = \"\"\n \n # init genome db parameter\n # getDBs is part of the GenomesModule\n gdbs = getDBs('pep')\n logger.debug(\"SELECTED GENOME DBS\\n\")\n logger.debug gdbs.join(\"\\n\")\n @db_path += ' ' + gdbs.join(' ')\n\n\n # Write confidence parameter to file in temp directory\n File.open(@basename + \".csiblast_conf\", \"w\") do |file|\n file.write(@e_thresh)\n end\n # set file rights ugo+rxw\n system(\"chmod 777 #{@basename}.csiblast_conf\")\n # if input is alignment call method process_alignment\n if (@inputmode == \"alignment\") then process_alignment end\n\n # set gapopen and gapextend costs depending on given matrix\n # default values\n @gapopen = 11\n @gapext = 1\n if (@mat_param =~ /BLOSUM80/i || @mat_param =~ /PAM70/i) then @gapopen = 10 end\n if (@mat_param =~ /PAM30/i) then @gapopen = 9 end\n if (@mat_param =~ /BLOSUM45/i) \n @gapopen = 15\n @gapext = 2\n end \n \n end",
"def tx(files, results, test, mediainfo, output_path)\n mutex = Mutex.new\n files.each do |src_file| \n t = Thread.new do\n puts \"Transcoding #{src_file}\"\n\n begin\n basename = File.basename(src_file.to_s, '.mov')\n filename = \"#{cleanup_filename(basename.to_s)}-#{test.filename}\"\n tx_command = process_command_line(test, mediainfo, src_file, File.join(output_path, filename))\n\n tx_start = Time.now\n success = run(tx_command, filename)\n tx_end = Time.now\n ensure\n if (@cleanup)\n File.unlink(filename)\n end\n end\n\n if success\n result = TestResult.new(tx_command, tx_start, tx_end)\n mutex.synchronize do\n results << result\n end\n end\n end\n end\nend",
"def process_alignment\n # init vars\n @names = []\n @seqs = []\n \n @alignment = \"-B #{@basename}.aln\"\n\n # import alignment file\n @content = IO.readlines(@infile).map {|line| line.chomp}\n \n #check alignment for gap-only columns\n remove_inserts\n \n #write query-file\n File.open(@infile, \"w\") do |file|\n file.write(\">#{@names[0]}\\n\")\n file.write(\"#{@seqs[0]}\\n\")\n end\n \n #write aln-file\n File.open(@basename + \".aln\", \"w\") do |file|\n @names.each_index do |num|\n file.write(\"Sequence#{num} \")\n file.write(\" \") if (num < 10)\n file.write(\" \") if (num < 100)\n file.write(\"#{@seqs[num]}\\n\")\n end\n end\n end",
"def test1\n \n peer1_pid = fork do\n exec(\"./ref_peer -p nodes.map -c A.chunks -f C.chunks -m 4 -i 1 -x 2 -d 0\")\n end \n \n\tparent_to_child_read, parent_to_child_write = IO.pipe\n\tpeer2_pid = fork do\n\t parent_to_child_write.close\n\n\t $stdin.reopen(parent_to_child_read) or\n\t\t\traise \"Unable to redirect STDIN\"\n\n\t exec(\"./peer -p nodes.map -c B.chunks -f C.chunks -m 4 -i 2 -d 0\") \n\tend\n\tparent_to_child_read.close\n\n\tsleep 1.0\n\t## send message to standard in of peer\n\twrite_to_peer = \"GET test1.chunks test1.tar\\n\"\n\tparent_to_child_write.write(write_to_peer)\n\tparent_to_child_write.flush\n\n\t## wait for our ref_peer binary to stop\n\tpid = Process.waitpid(peer1_pid)\n\treturn_code = $? >> 8;\n\n\tsleep 3.0\n\tif (return_code == 10) \n\n \t diff_pid = fork do\n \t\texec(\"diff A.tar test1.tar\")\n \t\t end \n\t\tProcess.waitpid(diff_pid)\n\t\treturn_code = $? >> 8;\n\t\tif (return_code == 0) \n\t\t\tputs \"########### Test 1 Passed! ###########\"\n\t\telse\n\t\t\tputs \"Files A.tar and test1.tar do not match\"\n\t\t\tputs \"########### Test 1 Failed ###########\"\n\t\tend\n\telse\n\t\tputs \"ref_peer exited with failure\"\n\t\tputs \"try setting debug level to 63 for lots more output\"\n\t\tputs \"########## Test 1 Failed #########\"\n\tend\n\n\tProcess.kill(\"SIGKILL\", peer2_pid);\nend",
"def test2\n \n peer1_pid = fork do\n exec(\"./peer -p nodes.map -c B.chunks -f C.chunks -m 4 -i 1 -d 0\")\n end \n \n\tparent_to_child_read, parent_to_child_write = IO.pipe\n\tpeer2_pid = fork do\n\t parent_to_child_write.close\n\n\t $stdin.reopen(parent_to_child_read) or\n\t\t\traise \"Unable to redirect STDIN\"\n\n\t exec(\"./ref_peer -p nodes.map -c A.chunks -f C.chunks -m 4 -i 2 -x 2 -d 0\") \n\tend\n\tparent_to_child_read.close\n\n\tsleep 1.0\n\t## send message to standard in of peer\n\twrite_to_peer = \"GET test2.chunks test2.tar\\n\"\n\tparent_to_child_write.write(write_to_peer)\n\tparent_to_child_write.flush\n\n\t## wait for our ref_peer binary to stop\n\tpid = Process.waitpid(peer2_pid)\n\treturn_code = $? >> 8;\n\n\tsleep 3.0\n\tif (return_code == 10) \n\n \t diff_pid = fork do\n \t\texec(\"diff B.tar test2.tar\")\n \t\t end \n\t\tProcess.waitpid(diff_pid)\n\t\treturn_code = $? >> 8;\n\t\tif (return_code == 0) \n\t\t\tputs \"########### Test 2 Passed! ###########\"\n\t\telse\n\t\t\tputs \"Files B.tar and test2.tar do not match\"\n\t\t\tputs \"########### Test 2 Failed ###########\"\n\t\tend\n\telse\n\t\tputs \"ref_peer exited with failure\"\n\t\tputs \"try setting debug level to 63 for lots more output\"\n\t\tputs \"########## Test 2 Failed #########\"\n\tend\n\n\tProcess.kill(\"SIGKILL\", peer1_pid);\nend",
"def print_totdist(io, run)\n\n io.puts \"<h3>ToT distributions</h3>\"\n io.puts \"<div style=\\\"text-align: center;\\\">\"\n io.puts \"<table>\"\n (1..$mod).each { |row|\n io.puts \" <tr>\"\n (1..$pad).each { |col|\n ch = $off + $pad*(row-1) + (col-1)\n io.puts \" <td><a href=\\\"fig/#{run}/tot#{ch}.gif\\\"><img src=\\\"fig/#{run}/thumb/tot#{ch}.gif\\\" alt='' /></a></td>\"\n }\n io.puts \" </tr>\" \n }\n io.puts \"</table>\" \n io.puts \"</div>\"\n\nend",
"def hadoop_commandline\n [\n hadoop_runner,\n \"jar #{hadoop_streaming_jar}\",\n hadoop_jobconf_options,\n \"-D mapred.job.name='#{job_name}'\",\n hadoop_files,\n hadoop_other_args,\n \"-mapper '#{mapper_commandline}'\",\n \"-reducer '#{reducer_commandline}'\",\n \"-input '#{input_paths}'\",\n \"-output '#{output_path}'\",\n io_formats,\n hadoop_recycle_env,\n ].flatten.compact.join(\" \\t\\\\\\n \")\n end",
"def sdrm_pr_bulk(sequences, cutoff = 0, temp_r_dir = File.dirname($0))\n region = \"PR\"\n rf_label = 0\n start_codon_number = 1\n n_seq = sequences.size\n mut = {}\n mut_com = []\n aa = {}\n point_mutation_list = []\n sequences.each do |name,seq|\n s = Sequence.new(name,seq)\n s.get_aa_array(rf_label)\n aa_seq = s.aa_array\n aa[name] = aa_seq.join(\"\")\n record = hiv_protease(aa_seq)\n mut_com << record\n record.each do |position,mutation|\n if mut[position]\n mut[position][1] << mutation[1]\n else\n mut[position] = [mutation[0],[]]\n mut[position][1] << mutation[1]\n end\n end\n end\n mut.each do |position,mutation|\n wt = mutation[0]\n mut_list = mutation[1]\n count_mut_list = count(mut_list)\n count_mut_list.each do |m,number|\n ci = r_binom_CI(number, n_seq, temp_r_dir)\n label = number < cutoff ? \"*\" : \"\"\n point_mutation_list << [region, n_seq, position, wt, m, number, (number/n_seq.to_f).round(5), ci[0], ci[1], label]\n end\n end\n point_mutation_list.sort_by! {|record| record[2]}\n\n link = count(mut_com)\n link2 = {}\n link.each do |k,v|\n pattern = []\n if k.size == 0\n pattern = ['WT']\n else\n k.each do |p,m|\n pattern << (m[0] + p.to_s + m[1])\n end\n end\n link2[pattern.join(\"+\")] = v\n end\n linkage_list = []\n link2.sort_by{|_key,value|value}.reverse.to_h.each do |k,v|\n ci = r_binom_CI(v, n_seq, temp_r_dir)\n label = v < cutoff ? \"*\" : \"\"\n linkage_list << [region, n_seq, k, v, (v/n_seq.to_f).round(5), ci[0], ci[1], label]\n end\n\n report_list = []\n\n div_aa = {}\n aa_start = start_codon_number\n\n aa_size = aa.values[0].size - 1\n\n (0..aa_size).to_a.each do |p|\n aas = []\n aa.values.each do |r1|\n aas << r1[p]\n end\n count_aas = count(aas)\n div_aa[aa_start] = count_aas.sort_by{|k,v|v}.reverse.to_h\n aa_start += 1\n end\n\n div_aa.each do |k,v|\n record = [region, k, n_seq]\n $amino_acid_list.each do |amino_acid|\n aa_count = v[amino_acid]\n record << (aa_count.to_f/n_seq*100).round(4)\n end\n report_list << record\n end\n\n return [point_mutation_list, linkage_list, report_list]\nend",
"def runProcsMultiThreaded(title, starttime, result, proc_array, spinningCursor)\n\n puts '####################################'\n puts title\n puts '####################################'\n\n proc_array.each { |proc|\n @threads << Thread.new { proc.call }\n }\n\n @waitThread = Thread.new { Proc.new { show_wait_cursor(result, spinningCursor) }.call }\n\n #Block till all threads complete\n @threads.each { |thr| thr.join }\n\n Thread.kill(@waitThread)\n\n endtime = Time.now\n puts \"\\n####################################\"\n puts \"#{title} complete\"\n puts \"Elapsed time: #{'%.2f' % (endtime - starttime)} secs - #{'%.2f' % ((endtime - starttime)/60)} min\"\n puts '####################################'\n\nend",
"def before_perform\n \n @basename = File.join(job.job_dir, job.jobid)\n @seqfile = @basename+\".in\"\n params_to_file(@seqfile, 'sequence_input', 'sequence_file')\n @commands = []\n @informat = params['informat'] ? params['informat'] : 'fas'\n reformat(@informat, \"fas\", @seqfile)\n @informat = \"fas\"\n\n @maxpsiblastit = params['maxpsiblastit']\n @maxhhblitsit = params['maxhhblitsit']\n @ss_scoring = \"-ssm \" + params[\"ss_scoring\"]\n @ptot = \"-T \" + params[\"ptot\"]\n @pself = \"-P \" + params[\"pself\"]\n @mergerounds = \"-mrgr \" + params[\"mergerounds\"]\n @mact = \"-mapt1 \" + params[\"mact\"] + \" -mapt2 \" + params[\"mact\"] + \" -mapt3 \" + params[\"mact\"]\n @domm = params[\"domm\"].nil? ? \"-domm 0\" : \"\" \n \n @maxlines = \"20\"\n @v = 1\n \n end",
"def bowtie_map2(bowtie_index, input_file, input_format, output_file)\n\t\tif input_format == 'fasta'\n\t\t\tstdin, stdout, stderr, t = Open3.popen3(\"bowtie2 -x #{bowtie_index} -f -U #{input_file} --no-unal | samtools view -bS - > #{output_file}\")\n\t\telse\n\t\t\tstdin, stdout, stderr, t = Open3.popen3(\"bowtie2 -x #{bowtie_index} -q -U #{input_file} --no-unal | samtools view -bS - > #{output_file}\")\n\t\tend\t\n\t\tsystem_exitcode(t, stderr, 'Bowtie2')\n\tend",
"def run\n warn_about_aliases if @cmd.to_s == @first\n generate_job\n end",
"def main \n settings = {}\n settings[\"--minAD\"] = 6 ## min # of reads carrying alternative allele for SNV\n settings[\"--minADIndel\"] = 8 ## min # of reads carrying alternative allele for indel\n settings[\"--minDP\"] = 12 # min depth in parents\n settings[\"--phenotype\"] = \"\"\n settings[\"--minPL\"] = 70\n settings[\"--minPLP\"] = 30\n settings[\"--minPLIndel\"] = 80\n settings[\"--maxAAF\"] = 0.015\n settings[\"--maxFreq\"] = 0.001\n settings[\"--maxAC\"] = 3\n\n optHash = getopt()\n vcf = optHash[\"--vcf\"]\n \n settings[\"--output\"] = vcf \n settings[\"--header\"] = vcf\n settings.keys.sort.each do |s|\n if optHash.key?(s) \n if s == \"--phenotype\" or s == \"--output\" or s == \"--header\"\n settings[s] = optHash[s]\n else\n settings[s] = optHash[s].to_f\n end\n end\n end\n \n\n samples=countSamples(settings[\"--phenotype\"], settings[\"--header\"])\n\n # $stderr.puts samples\n \n filterVCF(vcf,settings,samples) # gt: gene -> pos -> sample -> genotype, \n\nend",
"def find_hash(possible_words, known_anagram, known_md5s, start, n = 3)\n cpus = Parallel.processor_count\n puts \"Total number of iteration: #{possible_words.length**n}\"\n puts \"You got #{cpus} cores\"\n\n hash_table = get_hash_table(known_anagram)\n known_hash = get_hash(known_anagram, hash_table)\n\n Parallel.map(possible_words, in_processes: cpus) do |w1|\n possible_words.each do |w2|\n possible_words.each do |w3|\n # Print every ten million iteration\n phrase = \"#{w1} #{w2} #{w3}\"\n\n # Allow only equal size phrases\n next unless phrase.length == known_anagram.length\n\n # Allow only equal hash phrases\n hash = get_hash(phrase, hash_table)\n next unless hash == known_hash\n\n # All only equal md5 phrases\n md5 = Digest::MD5.hexdigest phrase\n next unless known_md5s.include?(md5)\n\n puts \"#{phrase} #{md5} (#{Time.now - start}s)\"\n end\n end\n end\nend",
"def run!\n options = setup_options\n drivers = ARGV\n while drivers.size >= 1 \n driver = drivers.shift\n run_with_logging File.basename(driver, File.extname(driver)), options do \n begin\n $Log.info \"Begin Pipelining #{driver} | #{Etc.getlogin} on #{`hostname`}\"\n run_pipe(options, driver)\n $Log.info \"Finished Pipelining #{driver}\"\n rescue StandardError => e\n $Log.error e\n end\n end\n end\nend",
"def generate_pid_fasta_file(dir=\"temp_data\")\n fasta_string=\"\"\n seq = Sequence.get(self.seq_id)\n pids = PercentIdentity.all(:seq1_id => self.seq_id, :percent_id.gte => 20, :order =>[:percent_id.desc],:unique=>true)\n fasta_string= Alignment.first(:alignment_name => self.alignment_name, :seq_id=>self.seq_id).fasta_alignment_string\n puts seq.abrev_name+\":\"+pids.count.to_s\n puts pids.map{|p| p.seq2_sequence.seq_name}.join(',')\n pids.each do |pid|\n if pid.seq2_id != seq.seq_id\n print Sequence.get(pid.seq2_id).abrev_name + \":\" + pid.percent_id.to_s + \",\"\n fasta_string = fasta_string + Alignment.first(:alignment_name=>pid.alignment_name, :seq_id=>pid.seq2_id).fasta_alignment_string(\"pid:#{pid.percent_id}\")\n end\n end\n puts \"\"\n filepath = \"#{dir}/\"+self.alignment_name+\"_\"+seq.abrev_name+\"_pid.fasta\"\n f = File.new(filepath, \"w+\")\n f.write(fasta_string)\n f.close\n filepath\n end",
"def gb_to_fasta(gb, fasta, seq_type=:nt, task_name=\"rast_annotate\")\n abort \"FATAL: Task #{task_name} requires specifying STRAIN_NAME\" unless STRAIN_NAME\n abort \"FATAL: gb_to_fasta called with invalid seq_type\" unless [:nt, :aa].include? seq_type\n system <<-SH\n module load python/2.7.6\n module load py_packages/2.7\n python #{REPO_DIR}/scripts/gb_to_fasta.py -i #{gb} -s #{seq_type} -o #{fasta}\n SH\nend",
"def by_file(first, output)\n qseq = Bio::Ngs::Converter::Qseq.new(options.paired ? :pe : :se)\n buffers = [first] if first.kind_of? String\n buffers = first if first.kind_of? Array\n buffers.each do |file_name|\n qseq.buffer = File.open(file_name,'r') #todo: dir is not used here it could be a bug\n fastq_file = File.open(File.join(options.dir,\"#{output}.fastq\"), (options.append ? 'a' : 'w'))\n qseq.to_fastq do |fastq|\n fastq_file.puts fastq if fastq\n end\n qseq.buffer.close\n fastq_file.close \n #Write the report\n File.open(File.join(options.dir,\"#{output}.stats\"), (options.append ? 'a' : 'w')) do |file|\n file.puts ({:file_name=>file_name, :stats=>qseq.stats}.to_yaml)\n end\n end #buffers\n # puts \"Done #{file_name}\"\n end",
"def run\n stime = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n\n sys(command, path: config[:bin], stdout: stdout, stderr: stderr)\n \n etime = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n\n ttime = etime-stime\n puts \"Query #{qfile} took #{ttime} seconds.\"\n\n done!\n rescue CommandFailed => e\n done! e.exitstatus\n end",
"def main\n ARGV.each do |arg|\n make_pdf arg\n end\nend",
"def launch_all_low(all_low_count,job_count)\n cmd = \"./control_delayed_jobs.rb --action launch --number \" + all_low_count + \" --job_count \" + job_count + \" --job_name all_low\\\"\"\n puts cmd\n `#{cmd}`\nend",
"def run_test(with_std)\n cmd = %W(#{BIN_PATH} -d #{BENCH_DURATION})\n cmd << \"-s\" if with_std\n cmd << TARGET_DIR\n\n IO\n .popen(cmd, err: %i(child out)) {|c| c.read }\n .scan(/(\\w+): (\\S+) ms/)\n .each_with_object({}) {|item, map| map[item[0]] = item[1] }\nend",
"def run\n create_log_folder\n \n in_tmp_dir do\n start_frame = tmp_path START_FRAME\n extract_start_transition_frame(start_frame) # 1.\n \n end_frame = tmp_path END_FRAME\n extract_end_transition_frame(end_frame) # 2.\n \n transitions = tmp_path TRANSITIONS\n Cmd::GenerateTransitionFrames.new(start_frame, end_frame, transitions, INNER_FRAMES_AMOUNT).run! *logs('3_generate_transition_frames') # 3.\n \n Queue.run *FORMATS.map{ |format| proc{ transition(format) } }, close_connection_before_execution: true # 4.\n end\n \n outputs\n end",
"def run_cmd(*cmds)\n command(cmds)\n read, write = IO.pipe\n system(*cmds, out: write, err: write).tap{|x| unless x; write.close; p cmds; puts read.read; end}.must_equal true\n write.close\n progress(read.read)\n read.close\n end",
"def merge_pairwise(aligns)\n ps = aligns.map do |align| \n seqs = []\n align.each do |bioseq|\n seqs << bioseq.to_s\n end\n seqs\n end\n template = []\n #m,x,n\n x = 2\n ftemp = ps.first.first\n nmax = ps.map {|pair| pair.first.size }.max\n mmax = ps.size\n mar = (0...mmax).to_a\n others = mar.map { [] }\n ns = mar.map { 0 }\n tn = 0\n on = 0\n (0...nmax).each do |n|\n (t_dsh, t_no_dsh) = mar.partition do |m| \n # this is RUBY 1.8 ONLY!!\n ps[m][0][ns[m]] == 45 # '-' is ascii 45\n end\n\n # if a template has a dash, all other off-templates need a dash\n if t_dsh.size > 0\n template[tn] = 45\n t_no_dsh.each do |m|\n # don't update these guys counter\n others[m][tn] = 45\n end\n t_dsh.each do |m|\n others[m][tn] = ps[m][1][ns[m]]\n ns[m] += 1\n end\n else # no dashes in the template\n t_no_dsh.each do |m|\n others[m][tn] = ps[m][1][ns[m]]\n end\n template[tn] = ps[0][0][ns[0]]\n ns.map!{|v| v+1 } \n end\n tn += 1\n end\n [cs_to_s(template), others.map! {|ar| cs_to_s(ar) } ]\n end",
"def run\n return if @files.empty?\n $stderr.write @files.inspect+\"\\n\"; $stderr.flush\n @cores.times do |c|\n @pipes << PipeDream.new\n @children << SafeFork.fork do\n Signal.trap(\"TERM\") { exit }\n Signal.trap(\"HUP\") { exit }\n pipe = @pipes.last\n pipe.identify_as_child\n pipe.write(\"[Worker #{c}] Booted\\n\")\n @result = Test::Unit::TestResult.new\n @result.add_listener(Test::Unit::TestResult::FAULT) do |value|\n $stderr.write value\n $stderr.write \"\\n\\n\"\n $stderr.flush\n end\n while !pipe.eof?\n file = pipe.gets.chomp\n begin\n pipe.write \"[Worker #{c} Starting: #{file}\\n\"\n start = Time.now\n\n klasses = Multitest.find_classes_in_file(file)\n klasses.each{|k| k.suite.run(@result){|status, name| ;}}\n \n finish = Time.now\n pipe.write \"[Worker #{c}] Completed: #{file} (#{finish-start})\\n\"\n rescue => ex\n pipe.write \"[Worker #{c}] Failed: #{file} - #{ex.to_s}\\n\"\n end\n end\n $stderr.write @result.to_s\n $stderr.write \"\\n\"\n $stderr.flush\n pipe.close\n end\n end\n\n total_files = @files.size\n @threads = []\n @pipes.each do |_p|\n @threads << Thread.new(_p) do |p|\n Signal.trap(\"TERM\") { exit }\n p.identify_as_parent\n # boot message\n p.gets\n while [email protected]? \n # puts \"#{total_files - @files.size}/#{total_files}\"\n # send a file\n p.write(\"#{@files.pop}\\n\")\n # print the start message\n msg = p.gets\n # $stdout.write msg; $stdout.flush\n # wait for the complete message\n msg = p.gets\n # print complete message\n if msg =~ /Completed/\n # $stdout.write msg; $stdout.flush\n else\n $stderr.write msg; $stderr.flush\n end\n end\n p.close\n end\n end\n\n Signal.trap(\"TERM\") do\n puts \"Exiting\"\n @children.each{|c| Process.kill(\"TERM\",c)}\n @threads.each{|t| Thread.kill(t)}\n end\n\n @threads.each{|t| t.join}\n @children.each{|c| Process.wait(c)}\n end",
"def runAnalyzer(num_samples,inhash)\n # select profile for run\n show do \n title \"Select #{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]}\" # this is just a profile name, should be ok for other polymerases\n note \"Click <b>Back to Wizard</b> if previous data is displayed.\"\n check \"Under <b>Process -> Process Profile</b>, make sure <b>#{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]}</b> is selected.\"\n end\n \n # select alignment marker\n ref_marker = (inhash[:sampleTypes] == 'DNA') ? REF_MARKERS[inhash[:type_ind]][inhash[:cutoff_ind]] : REF_MARKERS[inhash[:type_ind] ]\n show do \n title \"Select alignment marker\"\n check \"Under <b>Marker</b>, in the <b>Reference Marker </b> drop-down, select <b>#{ref_marker}</b>. A green dot should appear to the right of the drop-down.\"\n end\n \n # empty rows\n if inhash[:sampleTypes] == 'RNA'\n num_samples = num_samples + 1 # Include the ladder in the first well of the first stripwell\n nonempty_rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n (num_samples % WELLS_PER_STRIPWELL) > 0 ? nonempty_rows + 1 : nonempty_rows\n else\n nonempty_rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n end\n show do \n title \"Deselect empty rows\"\n check \"Under <b>Sample selection</b>, deselect all rows but the first #{nonempty_rows}.\"\n end\n \n # check \n show do \n title \"Perform final check before running analysis\"\n note \"Under <b>Run Check</b>, manually confirm the following:\"\n check \"Selected rows contain samples.\"\n check \"Alignment marker is loaded (changed every few weeks).\"\n end\n \n # run and ask tech for remaining number of runs\n run_data = show do \n title \"Run analysis\"\n note \"If you can't click <b>Run</b>, and there is an error that reads <b>The pressure is too low. Replace the nitrogen cylinder or check the external nitrogen source</b>, close the software, and reopen it. Then restart at title - <b>Select #{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]} </b>\"\n check \"Otherwise, click <b>Run</b>\"\n note \"Estimated time of experiment is given at the bottom of the screen\"\n get \"number\", var: \"runs_left\", label: \"Enter the number of <b>Remaining Runs</b> left in this cartridge\", default: 0\n #image \"frag_an_run\"\n end\n \n # return\n run_data[:runs_left]\n \n end",
"def run_scenario(benchmarks, log_all = true)\n # Outputs = \"<total # running>/<specific combination>/<benchmark>/*.csv\"\n log_directory = OUTPUT_DIRECTORY + benchmarks.size.to_s + \"/\"\n names = benchmarks.map{|b| b.name}\n combo = names.sort.each_with_object(Hash.new(0)) {|v, h| h[v] += 1}\n combo = combo.to_a.sort{|a, b| a[0] <=> b[0]}\n combo = combo.map{|v| v[1].to_s + \"_\" + v[0]}.join(\"_\")\n puts \"Running scenario #{combo}\"\n log_directory += combo + \"/\"\n cpu_count = `nproc`.to_i\n cpu_core = 1\n benchmark_count = Hash.new(1)\n pids = []\n to_return = []\n benchmarks.each do |benchmark|\n # Determine the log directory and create it if it doesn't exist.\n log_location = log_directory + benchmark.name + \"/\"\n `mkdir -p #{log_location}`\n log_location += benchmark_count[benchmark].to_s + \".csv\"\n if !log_all && (benchmark_count[benchmark] > 1)\n log_location = \"/dev/null\"\n to_return << \"\"\n else\n to_return << log_location\n end\n # Spawn new processes for each benchmark.\n # TODO: Run vmstat before and after each benchmark program.\n puts \" Running #{benchmark.executable} on CPU #{cpu_core.to_s}\"\n pids << Process.fork do\n # Set the CPU core for this process and its children.\n `taskset -c -p #{cpu_core.to_s} $$`\n # Execute the command, redirecting to the log, skipping OS buffering\n `stdbuf -oL #{benchmark.command()} > #{log_location}`\n end\n cpu_core = (cpu_core + 1) % cpu_count\n benchmark_count[benchmark] += 1\n end\n pids.each {|pid| Process.wait(pid)}\n to_return\nend",
"def gen_highlights_for_multi_sessions(session_count, video_dir, txt_dir, dst_video)\n mpg_videos = []\n seg_filenames = []\n k = 1\n (1..session_count).each do |i|\n src_video = File.join(video_dir, \"session#{i}.mp4\")\n txt_file = File.join(txt_dir, \"session#{i}.txt\")\n pairs = get_time_pairs(txt_file)\n pairs.each do |pair|\n outmp4 = File.join($tmp_folder, \"#{k}.mp4\")\n outmpg = File.join($tmp_folder, \"#{k}.mpg\")\n seg_filenames << outmpg\n cmd_str = \"#{$ffmpeg} -ss #{pair[0]} -t #{pair[1] - pair[0] + 2} -i \\\"#{src_video}\\\" #{outmp4}\"\n p cmd_str\n system(cmd_str) unless File.exists? outmp4\n cmd_str = \"#{$ffmpeg} -i #{outmp4} -qscale:v 1 #{outmpg}\"\n p cmd_str\n system(cmd_str) unless File.exists? outmpg\n k = k + 1\n end\n end\n all_segs = seg_filenames.join('|')\n mpg_all = File.join($tmp_folder, 'all.mpg')\n cmd_str = \"#{$ffmpeg} -i \\\"concat:#{all_segs}\\\" -c copy #{mpg_all}\"\n p cmd_str\n system(cmd_str) unless File.exists? mpg_all\n cmd_str = \"#{$ffmpeg} -i #{mpg_all} -qscale:v 1 #{dst_video}\"\n p cmd_str\n system(cmd_str)\nend",
"def run_specs(globs, spec_cmd='spec', run_opts = \"-c -f s\")\n require \"optparse\"\n require \"spec\"\n globs = globs.is_a?(Array) ? globs : [globs]\n examples, failures, errors, pending = 0, 0, 0, 0\n\n time = Benchmark.measure do\n globs.each do |glob|\n Dir[glob].each do |spec|\n response = Open3.popen3(\"#{spec_cmd} #{File.expand_path(spec)} #{run_opts}\") do |i,o,e|\n while out = o.gets\n STDOUT.puts out\n STDOUT.flush\n if out =~ /\\d+ example/\n e, f, p = out.match(/(\\d+) examples?, (\\d+) failures?(?:, (\\d+) pending?)?/)[1..-1]\n examples += e.to_i; failures += f.to_i; pending += p.to_i\n end\n end\n errors += 1 if e.is_a?(IO)\n STDOUT.puts e.read if e.is_a?(IO)\n end\n end\n end\n end\n\n puts\n puts \"*** TOTALS ***\"\n if failures == 0\n print \"\\e[32m\"\n else\n print \"\\e[31m\"\n end\n puts \"#{examples} examples, #{failures} failures, #{errors} errors, #{pending} pending, #{sprintf(\"suite run in %3.3f seconds\", time.real)}\"\n # TODO: we need to report pending examples all together\n print \"\\e[0m\"\nend",
"def sortmerna(input_dir, samples_h)\n\n samples, labels = [], []\n rrna_5s_a, rrna_5_8s_a, rrna_18s_a, rrna_28s_a, rrna_all = [], [], [], [], []\n\n if File.exist?(\"#{input_dir}/#{samples_h.keys[0]}_aligned.log\")\n puts \"\\t\\tRun SortMeRna Statistics...\"\n\n samples_h.each do |sample, label|\n samples.push(sample)\n labels.push(label)\n read = false\n all = 0\n File.open(\"#{input_dir}/#{sample}_aligned.log\",'r').each do |line|\n read = true if line.include?('By database:')\n if read\n if line.include?('rfam-5s-database-id98.fasta')\n value = line.split(\"\\t\")[2].chomp.sub('%','').to_f\n rrna_5s_a.push(value)\n all += value\n end\n if line.include?('rfam-5.8s-database-id98.fasta')\n value = line.split(\"\\t\")[2].chomp.sub('%','').to_f\n rrna_5_8s_a.push(value)\n all += value\n end\n if line.include?('silva-euk-18s-id95.fasta')\n value = line.split(\"\\t\")[2].chomp.sub('%','').to_f\n rrna_18s_a.push(value)\n all += value\n end\n if line.include?('silva-euk-28s-id98.fasta')\n value = line.split(\"\\t\")[2].chomp.sub('%','').to_f\n rrna_28s_a.push(value)\n all += value\n end\n end\n end\n rrna_all.push(all.round(2))\n end\n df = Nyaplot::DataFrame.new({:sample => samples, :label => labels, :rrna_5s => rrna_5s_a, :rrna_5_8s => rrna_5_8s_a, :rrna_18s => rrna_18s_a, :rrna_28s => rrna_28s_a, :all_rrna => rrna_all })\n df = Nyaplot::DataFrame.new({:label => %w(5s 5.8s 18s 28s all), :rrna => rrna_5s_a+rrna_5_8s_a+rrna_18s_a+rrna_28s_a+rrna_all })\n\n colors = Nyaplot::Colors.qual\n frame = Nyaplot::Frame.new\n\n #[:all_rrna, :rrna_5s, :rrna_5_8s, :rrna_18s, :rrna_28s].each do |rrna|\n plot = Nyaplot::Plot.new\n plot.configure do\n x_label('rRNA type')\n y_label(\"% rRNA\")\n yrange([0,100])\n legend(true)\n end\n #bar = plot.add_with_df(df, :bar, :label, rrna) # x-> column :label, y-> column :rrna\n bar = plot.add_with_df(df, :bar, :label, :rrna)\n bar.color(colors)\n frame.add(plot)\n\n frame.export_html(\"#{$out_dir}/sortmerna.html\")\n frame_html = File.open(\"#{$out_dir}/sortmerna.html\",'a')\n frame_html << \"\\n\\n<p>\\n#{df_to_html_table(df.to_html)}\\n</p>\\n\\n\"\n frame_html.close\n end\n end"
] | [
"0.6300588",
"0.6162396",
"0.60683596",
"0.5817398",
"0.5784051",
"0.57587767",
"0.5755168",
"0.5717495",
"0.5697194",
"0.5686249",
"0.5679784",
"0.56323355",
"0.5626766",
"0.55453444",
"0.55391115",
"0.5514224",
"0.54895353",
"0.54724365",
"0.54600847",
"0.54364926",
"0.5399843",
"0.5394872",
"0.53868157",
"0.5382937",
"0.5344833",
"0.5343605",
"0.5343605",
"0.53203225",
"0.5280257",
"0.52588046",
"0.5247981",
"0.52295387",
"0.52243733",
"0.52213174",
"0.5217207",
"0.5216443",
"0.5203318",
"0.5203318",
"0.5201857",
"0.5197863",
"0.5193461",
"0.5186239",
"0.5179194",
"0.51695925",
"0.5164081",
"0.51635474",
"0.51530325",
"0.5152752",
"0.51407695",
"0.51399064",
"0.5126468",
"0.51165104",
"0.51143813",
"0.5107265",
"0.5091992",
"0.50913",
"0.5086011",
"0.50699073",
"0.5063469",
"0.5051097",
"0.5029756",
"0.50296295",
"0.50296044",
"0.50286597",
"0.5019995",
"0.50127524",
"0.5008358",
"0.5007763",
"0.50046134",
"0.5001834",
"0.500059",
"0.49765566",
"0.4975097",
"0.49690726",
"0.49672318",
"0.49574286",
"0.49573097",
"0.49544963",
"0.49415675",
"0.49379367",
"0.49353865",
"0.493069",
"0.49249694",
"0.49214935",
"0.49180305",
"0.49132174",
"0.49103373",
"0.4888802",
"0.48852783",
"0.48802623",
"0.48754478",
"0.48740757",
"0.48645386",
"0.48642874",
"0.4863556",
"0.48623732",
"0.48556653",
"0.48551413",
"0.48545247",
"0.48524964",
"0.48520932"
] | 0.0 | -1 |
runs sql commands within a file. Useful for running external scripts such as importing data | def run_sql_file(file, &block)
sql = clean_sql(File.read(file))
split_sql_commands(sql).map do |cmd|
run_cmd(cmd).tap do |result|
block.call(cmd, result) if block
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_sql_file(path, connection = ApplicationRecord.connection)\n connection.execute(IO.read(path))\nend",
"def query(sql, file)\n return if sql.nil? || file.nil?\n sql.strip!\n get_copy_data(sql.chomp(';'), file)\n end",
"def run_sql_script(path, adapter = dss, ctx = {})\n sql = ErbHelper.new.process(path, ctx)\n puts sql\n adapter.run sql\n end",
"def source_sql\n system \"psql -d #{@base_name} -f #{@sql_path}\"\n end",
"def execute(sql, name = nil) \n # Only skip select statements from logging \n unless /^(select|show|begin|commit)/i.match(sql.strip) \n\t\tFile.open( File.join(RAILS_ROOT, 'db', 'ddl.sql'),'a') {|f|\n\t\t\ttemp_sql = sql.gsub(\"\\n\",\"\") \n\t\t\ttemp_sql = temp_sql + ';' if adapter_name != 'IBM_DB2' or adapter_name != 'IBM_DB'\n\t\t\tf.puts temp_sql\n\t\t}\n end\n\t old_execute sql, name\n end",
"def exec_sql_script_in_db(db_name, db_user, db_pass, sql_script)\n # connecting to the given database\n conn = PG.connect(\n :dbname => db_name,\n :user => db_user,\n :password => db_pass)\n\n # actually executing the script\n conn.exec(sql_script)\nend",
"def execute_migration(name, filepath)\n @log.info \"executing migration #{filepath}\"\n\n statements = @sql_reader.load_migration(filepath)\n if statements.length == 0\n raise 'no statements found in migration #{filepath}'\n end\n run_migration(name, statements)\n end",
"def execute(sql, name = nil)\n # check for some DDL and DML statements\n puts \"Running sql? #{RUN_SQL}\"\n\n if /(create |alter |drop |insert |delete |update )/i.match sql.squish\n File.open(SQL_FILENAME, 'a') { |f| f.puts \"#{sql};\\n\" }\n puts \"Rails.env: #{Rails.env} - #{ENV['FPHS_POSTGRESQL_SCHEMA']}\"\n old_execute sql, name if RUN_SQL\n else\n # pass everything else to the aliased execute\n puts \"------------- (#{name}) ---------------\"\n puts sql || ''\n puts \"------------- ---------------\"\n old_execute sql, name if RUN_SQL\n end\n end",
"def query\n rdr = PostgresReader.new(@options)\n query = File.open(@sql_file, 'r', &:read)\n File.open(@output_file, 'w') do |file|\n rdr.query(query, file)\n end\n end",
"def run_sql(query)\n raw_run_sql(query)\n end",
"def execute_sql(sql_code)\n done = system \"sh db_execute.sh \\\"#{sql_code}\\\"\"\n raise Exception.new(\"Issue executing sql code: #{sql_code}\") unless done\nend",
"def sql( command, options = {})\n @sql ||= OraUtils::Sql.new(options)\n sid = options.fetch(:sid) { fail \"SID must be present\"}\n Puppet.debug \"Executing: #{command} on database #{sid}\"\n csv_string = execute_sql(command, options)\n add_sid_to(convert_csv_data_to_hash(csv_string, [], :converters=> lambda {|f| f ? f.strip : nil}),sid)\n end",
"def execute sql\n db[sql]\n end",
"def execute_script(filename)\n\tif File.exist?(filename) \n\t\t execute_query File.read(filename),\n\t\t\t{ :db_name => @properties[\"ml.content-db\"] }\t\t\t\n\t\t\tlogger.info \"Executed script #{filename} successfully\"\n\telse\n\t\tlogger.info \"#{filename} does not exist\"\t\n\tend\n end",
"def record_as_run!(filename)\n Preconditions.check_state(filename.match(/^\\d\\d\\d\\d\\d\\d+\\-\\d\\d\\d\\d\\d\\d\\.sql$/),\n \"Invalid filename[#{filename}]. Must be like: 20120503-173242.sql\")\n command = \"insert into %s.%s (filename) select '%s' where not exists (select 1 from %s.%s where filename = '%s')\" % [Db.schema_name, @table_name, filename, Db.schema_name, @table_name, filename]\n @db.psql_command(command)\n end",
"def query_script(example, sql, log_name=nil)\n log_name ||= 'Run SQL Script'\n\n debuggable_sql = SqlPreprocessor.debuggable_sql(sql)\n executable_sql = SqlPreprocessor.executable_sql(sql, example)\n\n example.metadata[:sql] += ((example.metadata[:sql] == '' ? '' : \"\\n\\n\") + \"-- #{log_name.split(/\\r\\n|\\n/).join(\"\\n-- \")}\\n#{debuggable_sql}\")\n application.query_script(executable_sql)\n end",
"def sql sql\n @master.puts \"#{sql};\"\n end",
"def execute\n ActiveRecord::Base.connection.execute(source)\n end",
"def run_sql(sql)\n\tdb = PG.connect(dbname: 'address_book', host: 'localhost')\n\tresult = db.exec(sql)\n\tdb.close\n\tresult\nend",
"def execute(sql)\n @database_handle.execute(sql)\n end",
"def sql(dsn, sql_name)\n sql_file = File.join(@sql_dir, \"#{dsn}.sql\")\n sql = YAML.load_file(sql_file)[sql_name]\n $logger.debug sql\n sql\n rescue\n fail \"Error reading from #{sql_file}.\"\n end",
"def execute_sql(query, db_name, ctrl)\n cmd = shell_out(sql_command_string(query, db_name, ctrl),\n user: 'root')\n if cmd.exitstatus != 0\n Chef::Log.fatal(\"mysql failed executing this SQL statement:\\n#{query}\")\n Chef::Log.fatal(cmd.stderr)\n raise 'SQL ERROR'\n end\n cmd.stdout\n end",
"def execute_file( filename )\n text = File.read(filename)\n execute(text)\n end",
"def exec(sql)\n Logging.with_logged_query self, sql do\n raw_connection.exec sql\n end\n end",
"def run_sql(sql_query)\n begin\n CONNECTION.execute(sql_query)\n rescue Exception => msg\n msg\n end\n end",
"def load_infile_sql(path, columns, options={})\n replacement = opts[:insert_ignore] ? :ignore : :replace\n options = {:update => replacement}.merge(options)\n LoadDataInfileExpression.new(path, \n opts[:from].first, \n columns, \n options).\n to_sql(db)\n end",
"def load_sql(sql_user, sql_pwd, rules_file, error_file = nil, abort_on_error = false, &block)\n reject_count = 0\n instrument \"load_data\", :sql_user => sql_user,\n :rules_file => rules_file, :error_file => error_file,\n :abort_on_error => abort_on_error do |payload|\n rejects = try { @cube.load_data(IEssOlapFileObject.TYPE_RULES, rules_file,\n # IEssOlapFileObject does not define a constant for TYPE_SQL (16384)\n 16384, \"\", abort_on_error, sql_user, sql_pwd) }\n reject_count = payload[:rejects] = process_rejects(rejects, error_file, &block)\n end\n reject_count\n end",
"def generate_sql\n @sql_path = \"#{File.dirname(@file_path)}/#{@base_name}.geoloader.sql\"\n system \"shp2pgsql #{@file_path} > #{@sql_path}\"\n end",
"def execute(sql)\n tmp = Digest::MD5.hexdigest(sql)\n tmp_path = \"#{TMP_DIR}/#{tmp}\"\n File.write tmp_path, sql \n scp_upload! tmp_path, tmp_path \n result = C.exec! \"psql -A -t -d #{TMP_DB} -f #{tmp_path}\"\n C.exec! \"rm #{tmp_path}\"\n File.delete tmp_path\n result\nend",
"def run_sql(sql)\n\tconn = PG.connect(dbname: \"video_store\", host: 'localhost')\n\tresult = conn.exec(sql)\n\tconn.close\n\tresult \nend",
"def addSQL(statement)\n \n if (@count % 250000 == 0)\n @filecount += 1\n self.clearSQL(@filecount)\n puts \"Now writing to insert-#{@filecount}.sql\"\n end\n\n File.open(\"data/insert-#{@filecount}.sql\", 'a') do |file|\n file.puts(statement)\n @count += 1\n end\n end",
"def run_sql(sql)\n db = PG.connect(:dbname => 'movies', :host => 'localhost')\n result = db.exec(sql)\n db.close\n result\n end",
"def sql! sql=nil\n require 'niceql'\n puts Niceql::Prettifier.prettify_sql sql || $last_sql_command\n end",
"def execute(cmd)\n RawDB.execute(db, cmd)\n end",
"def run_sql(sql)\n db = PG.connect(dbname: 'goodfoodhunting')\n results = db.exec(sql)\n db.close\n results\nend",
"def mysql_lines\n File.open(file_name, \"r\") do |line|\n #File.open('./lib/databasers/fibered_files_output.txt') do |line|\n line.each do |x|\n puts \"('\" + \"#{x.strip}\" + \"')\"\n end\n end\n end",
"def generate2sql(w)\n File.open(@filename_target, 'w') {|file| file.write(w)}\nend",
"def execute(sql)\n begin\n db = SQLite3::Database.new(@@db_file)\n @@_set_db_handler.call(db)\n if block_given?\n db.execute(sql) do |row|\n yield row\n end\n else\n return db.execute(sql)\n end\n ensure\n db.close\n end\n end",
"def exec(sql, rescue_exception = true)\n debug(sql) if $DBG\n exec_statement(sql)\n rescue Object => ex\n if rescue_exception\n handle_sql_exception(ex, sql)\n else\n raise\n end\n end",
"def jump_sql\n \n FileUtils.cd(@app_path+\"/lib/tasks\",:verbose => true)\n if File.directory? @d\n puts \"Directory #{@d} exists\"\n else\n FileUtils.mkdir @d, :mode => 0700, :verbose => true\n end\n \n FileUtils.cd(@d,:verbose => true)\n @n = Time.now.strftime(\"%H%M%S\")\n @h = File.open(@n,\"a+\")\n @h.write(\"\\n#{@sql}\\n\")\n \n end",
"def import\n check_dependencies('mysql', '/bin/sh')\n source = args.shift or raise CommandFailed, \"You must specify a file to import from\"\n File.readable?(source) or raise CommandFailed, \"#{source.inspect} is not readable\"\n command = case source\n when /\\.bz2$/\n check_dependencies('bzcat')\n 'bzcat'\n when /\\.gz$/\n check_dependencies('gunzip')\n 'gunzip -c'\n else\n check_dependencies('cat')\n 'cat'\n end\n\n display \"This will replace the #{app} database with #{source}!\"\n exit unless dangerous_prompt\n\n exec('/bin/sh', '-c',\n \"#{command} #{args_to_s(source)}\" +\n pv_pipe +\n %{| mysql --compress } + args_to_s(mysql_args(database_uri)))\n end",
"def sql( command, parameters = {})\n sid = parameters.fetch(:sid) {\n oratab.first[:sid] # For now if no sid is given always use the first one\n }\n Puppet.info \"Executing: #{command} on database #{sid}\"\n csv_string = execute_sql(command, :sid => sid)\n convert_csv_data_to_hash(csv_string, [], :converters=> lambda {|f| f ? f.strip : nil})\n end",
"def raw_run_sql(query)\n vprint_status \"{SQLi} Executing (#{query})\"\n if @hex_encode_strings\n query = hex_encode_strings(query)\n vprint_status \"{SQLi} Encoded to (#{query})\"\n end\n @query_proc.call(query)\n end",
"def query(sql)\n database.execute2(sql)\n end",
"def run_sql(sql)\n conn = PG.connect(dbname: \"memetube\", host: \"localhost\")\n begin\n result = conn.exec(sql)\n ensure\n conn.close\n end\n result\nend",
"def run_commands_from_file(commands)\n\t\tcommands.each do |command|\n\t\t\trun_command(command)\n\t\tend\n\n\tend",
"def execute(sql)\n @logger.debug(\"SQL: #{sql}\") if @logger\n retrieve_connection.query(sql)\n end",
"def run_sql(sql)\n conn = PG.connect(dbname: 'movies')\n result = conn.exec(sql)\n conn.close\n result\nend",
"def execute(sql)\n @db.send(:_execute, self, sql, :log=>false) \n end",
"def exec__psql_cli_or_db_queries psql_db, db_queries=[nil]\n batch = psql_db_batch__cli_or_queries psql_db, db_queries\n batch_commands batch\n end",
"def _execute(sql, name = nil)\n @connection.execute(sql)\n end",
"def run_sql(sql)\n connection = PG.connect(dbname: \"facebook_lab\", host: \"localhost\")\n result = connection.exec(sql)\n connection.close\n result\nend",
"def run_sql(sql_query)\n\tconn = PG.connect(dbname: 'first_crud_app')\n\tresult = conn.exec(sql_query)\n\tconn.close\n\tresult\nend",
"def do_execute(sql, name = 'SQL')\n log(sql, name) { raw_connection_do(sql) }\n end",
"def run_sql(sql_query)\n begin\n CONNECTION.execute(sql_query)\n rescue Exception => msg\n @errors << msg\n false\n end\n end",
"def run_sql(sql)\n conn = PG.connect(dbname: 'goodfoodhunting')\n result = conn.exec(sql)\n conn.close\n return result\nend",
"def __run(requester_file, arguments)\n exit(\"Missing schema file argument\", true) unless arguments.size == 1\n unless File.exists?(schema_file = arguments.shift)\n exit(\"Unable to find #{schema_file}\") \n end\n Rubyrel::parse_ddl_file(schema_file)\n end",
"def execute_inner! work_dir, script\n\n exe = path_to(@opts.get(:exe), work_dir)\n parameters = @opts.get(:parameters)\n parameters.add(\"-i#{script.gsub('/','\\\\')}\")\n \n cmd = Albacore::Sql::Cmd.new(work_dir, exe, parameters)\n\n cmd.execute\n\n fail \"SqlCmd.exe is not installed.\\nPlease download and install Microsoft SQL Server 2012 Command Line Utilities: https://www.microsoft.com/en-gb/download/confirmation.aspx?id=29065\\nAnd add the location of SqlCmd.exe to the PATH system varible.\" unless exe\n\n end",
"def execute(sql)\r\n\t\[email protected](sql)\r\n\tend",
"def run_sql(sql)\n #connect to the|db|\n conn = PG.connect(:dbname => 'rogbloll')\n\n\n #execute the db in the argument\n res = conn.exec(sql)\n\n #now close the db\n conn.close\n\n #now return the result of the query...\n res\n\n\n \n end",
"def run\n basecmd = []\n basecmd << command(:psql)\n basecmd << \"-U\" unless @resource[:role].nil?\n basecmd << \"#{@resource[:role]}\" unless @resource[:role].nil?\n basecmd << \"-d\" unless @resource[:database].nil?\n basecmd << \"#{@resource[:database]}\" unless @resource[:database].nil?\n \n # We execute by default.\n execute = true\n unless @resource[:query].nil?\n cmd = basecmd\n cmd << '-qAtc'\n \n sqlcmd = \"#{@resource[:query]}\"\n \n cmd << sqlcmd\n \n raw, status = Puppet::Util::SUIDManager.run_and_capture(cmd, 'postgres')\n if status == 0\n execute = false # Got an ok result, so we'll evaluate.\n\n if ! @resource[:rows].nil?\n target_rows = Integer(@resource[:rows].gsub(/[^\\d]/,''))\n operand = @resource[:rows].gsub(/[\\d]/,'').chomp.downcase\n returned_rows = (raw.length <= 0 ? 0 : raw.lines.count)\n if operand.match(/lte|less than or equal|<=/)\n execute = true if returned_rows <= target_rows\n elsif operand.match(/gte|greater than or equal|>=/)\n execute = true if returned_rows >= target_rows\n elsif operand.match(/lt|less than|</)\n execute = true if returned_rows < target_rows \n elsif operand.match(/gt|greater than|>/)\n execute = true if returned_rows > target_rows\n else\n execute = true if returned_rows == target_rows\n end\n end\n else\n # We stop an execution if rows or result params are set\n # on the assumption that if you want to evaluate against criteria like those\n # you want to actually do so.\n execute = false if (! @resource[:rows].nil? or ! @resource[:result].nil?)\n end\n end\n \n unless execute == false\n cmd = basecmd\n if ! @resource[:command].nil?\n cmd << '-qAtc'\n \n sqlcmd = \"#{@resource[:command]}\"\n \n cmd << sqlcmd \n elsif ! @resource[:file].nil?\n cmd << '-qAtf'\n \n sqlcmd = \"#{@resource[:file]}\"\n \n cmd << sqlcmd\n else\n # Right now we send a warning. This should still trigger a refresh if you\n # want to use queries to conditionally do things for some insane reason.\n self.warning(\"Nothing to do.\")\n end\n \n raw, status = Puppet::Util::SUIDManager.run_and_capture(cmd, 'postgres')\n if status != 0\n self.fail(\"Error executing SQL - result #{raw}\")\n else\n @ran = true\n end\n else\n self.fail(\"Execution criteria failed. Failing to prevent dependant resources from executing.\")\n end\n end",
"def exec__psql_db_batch__cli_or_apply_dumps *args\n psql_db = psql_db__sample_example\n db_dumps = db_dumps__sample_example\n batch = psql_db_batch__cli_or_apply_dumps psql_db, db_dumps, \"ON_ERROR_STOP=off\"\n batch_commands batch\n end",
"def process\n create, insert, table = extract_sql #Extract mysql create/insert statements from the dump file\n raise \"Couldn't extract create syntax from MySql Dump File\" if create.nil?\n create = escape_create_string(create)\n begin\n @connection.execute(\"DROP TABLE #{table}\") rescue ''#Drop existing table first\n @connection.execute(create) #Recreate the table \n if insert && @import_data\n values = row_values(insert) \n values.each do |val|\n sql = \"INSERT INTO #{table} VALUES #{val}\"\n begin\n @connection.execute(sql) #Insert rows\n rescue Exception => e\n puts e.message\n puts sql\n puts \"table #{table}\"\n end\n end\n else\n puts \"There's no records to be added\" if @import_data && !insert\n end\n rescue Exception => e\n puts e.message\n puts \"table #{table}\"\n end\n end",
"def load_schema\n File.read(File.expand_path(\"fixtures/db_definitions/sqlite.sql\", __dir__)).split(\";\").each do |sql|\n ActiveRecord::Base.connection.execute(sql) unless sql.blank?\n end\n end",
"def execute(sql, name = nil) #:nodoc:\n log(sql, name) { @connection.exec sql }\n end",
"def do_bulk_load(file, table_name, options={})\n q = \"COPY #{table_name} \"\n q << \"(#{options[:columns].join(',')}) \" if options[:columns]\n q << \"FROM '#{File.expand_path(file)}' \"\n if options[:fields]\n q << \"WITH \"\n q << \"DELIMITER '#{options[:fields][:delimited_by]}' \" if options[:fields][:delimited_by]\n q << \"NULL '#{options[:fields][:null_string]}'\" if options[:fields][:null_string]\n if options[:fields][:enclosed_by] || options[:ignore] && options[:ignore] > 0\n q << \"CSV \"\n q << \"HEADER \" if options[:ignore] && options[:ignore] > 0\n q << \"QUOTE '#{options[:fields][:enclosed_by]}' \" if options[:fields][:enclosed_by]\n end\n end\n \n execute(q)\n end",
"def clearSQL(fc)\n File.open(\"data/insert-#{fc}.sql\", 'w') do |file|\n file.puts(\"\")\n end\n end",
"def execute(sql)\n raise(ArgumentError, \"Bad sql parameter\") unless sql.kind_of?(String)\n\n client = ensure_connected\n\n Pod4.logger.debug(__FILE__){ \"execute: #{sql}\" }\n r = client.execute(sql)\n\n r.do\n r\n\n rescue => e\n handle_error(e)\n end",
"def execute *operations\n results = operations.map do |op|\n if tables.include? op.table\n op.execute @db[op.table]\n end\n end\n results.grep(Spinoza::ReadResult)\n end",
"def do_bulk_load(file, table_name, options={})\r\n env_name = options[:env] || RAILS_ENV\r\n config = ActiveRecord::Base.configurations[env_name]\r\n puts \"Loading table \\\"#{table_name}\\\" from file \\\"#{filename}\\\"\"\r\n cmd = \"bcp \\\"#{config['database']}.dbo.#{table_name}\\\" in \" +\r\n \"\\\"#{filename}\\\" -S \\\"#{config['host']}\\\" -c \" +\r\n \"-t \\\"#{options[:delimited_by]}\\\" -b10000 -a8192 -q -E -U \\\"#{config['username']}\\\" \" +\r\n \"-P \\\"#{config['password']}\\\" -e \\\"#{filename}.in.errors\\\"\"\r\n `#{cmd}`\r\n end",
"def execute(sql, *args, &block)\n @db.execute(rewrite_table_names(sql), *args, &block)\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n execute(sql, name, binds)\n end",
"def execute(db_client)\n query_file = @query_options['file']\n query_file_path = \"./config/queries/#{query_file}\"\n query_content = File.read(query_file_path)\n\n if @query_options.has_key?('params') || @params\n query_params = @query_options['params'] ? @query_options['params'] : @params.split(',')\n query_params.each_with_index do |p, i|\n query_content = query_content.gsub(/@@#{i}@@/, p)\n end\n end\n\n return db_client.query(query_content)\n end",
"def execute_ddl(sql, opts=OPTS)\n _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}}\n nil\n end",
"def run_sqlite_scipt(path, adapter = dss, ctx = {})\n raise 'Not implemented yet!'\n end",
"def OLDview_data db, sql, options\n outputfile = options[:output_to]\n formatting = options[:formatting]\n headers = options[:headers]\n #str = db.get_data sql\n rs = db.execute_query sql\n str = rs.content\n columns = rs.columns\n #puts \"SQL: #{sql}.\\nstr: #{str.size}\"\n data = []\n if headers\n data << columns.join(\"\\t\")\n end\n str.each {|line| data << line.join(\"\\t\"); }\n #puts \"Rows: #{data.size}\"\n require 'tempfile'\n tmpfile = Tempfile.new('SQL.XXXXXX')\n filename = tmpfile.path\n filename = Shellwords.escape(filename)\n #puts \"Writing to #{filename}\"\n tmpfile.write(data.join(\"\\n\"))\n tmpfile.close # need to flush, otherwise write is buffered\n headerstr=nil\n if formatting\n headerstr = \"-H\" unless headers\n # sometimes this can be slow, and it can fault on UTF-8 chars\n system(\"cat #{filename} | term-table.rb #{headerstr} | sponge #{filename}\")\n end\n if outputfile\n #puts \"comes here\"\n system(\"cp #{filename} #{outputfile}\")\n filename = outputfile\n end\n system \"wc -l #{filename}\" if $opt_debug\n \n #system \"$EDITOR #{filename}\"\n system \"vim -c ':set nowrap' #{filename}\"\n tmpfile.close\n tmpfile.unlink\nend",
"def parse_ddl_file(file)\n Rubyrel::DDL.schema(File.basename(file, '.rel'), file)\n end",
"def safe_load_sql(sql_path_string)\n sql_path = OpenStudio::Path.new(sql_path_string)\n if OpenStudio::exists(sql_path)\n sql = OpenStudio::SqlFile.new(sql_path)\n else\n puts \"#{sql_path} couldn't be found\"\n exit\n end\n return sql\n end",
"def run_migration_file partial_filename, direction=:up\n id = get_migration_id partial_filename\n \"rake db:migrate:#{direction.to_s} VERSION=#{id}\"\n end",
"def run_sql(statement, params)\n @low_card_model.connection.execute(@low_card_model.send(:sanitize_sql, [ statement, params ]))\n end",
"def load_data_infile(file, options = {})\n sql = \"LOAD DATA LOCAL INFILE '#{file}' \"\n sql << \"#{options[:insert_method]} \" if options[:insert_method]\n sql << \"INTO TABLE #{quoted_table_name} \"\n sql << \"CHARACTER SET #{options[:charset_name]} \" if options[:charset_name]\n \n fields = \"\"\n fields << \"TERMINATED BY '#{options[:fields_terminated_by]}' \" if options[:fields_terminated_by]\n fields << \"OPTIONALLY ENCLOSED BY '#{options[:fields_optionally_enclosed_by]}' \" if options[:fields_optionally_enclosed_by]\n fields << \"ESCAPED BY '#{options[:fields_escaped_by]}' \" if options[:fields_escaped_by]\n\n sql << \"FIELDS #{fields} \" unless fields.empty?\n sql << \"LINES TERMINATED BY '#{options[:lines_terminated_by]}' \" if options[:lines_terminated_by]\n sql << \"IGNORE #{options[:ignore_lines]} LINES \" if options[:ignore_lines]\n sql << \"(\" + options[:columns].join(', ') + \") \" if options[:columns]\n if options[:mapping]\n mappings = []\n options[:mapping].each_pair do |column, mapping|\n mappings << \"#{column} = #{mapping}\"\n end\n sql << \"SET #{mappings.join(', ')} \" if mappings.size > 0\n end\n sql << \";\"\n connection.execute(sql)\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|conn| check_database_errors{_execute(conn, sql, opts, &block)}}\n end",
"def run_from_file_command(command)\n if logger.debug?\n debug(\"Creating exec script for #{instance_name} (#{exec_script_file})\")\n debug(\"Executing #{exec_script_file}\")\n end\n File.open(exec_script_file, \"wb\") { |file| file.write(command) }\n %{powershell -file \"#{exec_script_file}\"}\n end",
"def process(statements); end",
"def transaction(*sqls)\n begin\n db = SQLite3::Database.new(@@db_file)\n @@_set_db_handler.call(db)\n db.transaction do\n sqls.each do |sql|\n db.execute(sql)\n end\n end\n ensure\n db.close\n end\n end",
"def exec_file(file)\n exec \"#{file}\"\n end",
"def cti_execute_sql(sql)\n return execute(sql) if sql.is_a?(String)\n sql.map do |query|\n execute(query)\n end\n end",
"def run_query(query_file , exp , o = {})\n index_path = o[:index_path] || @index_path\n cmd = fwrite('cmd_galago_run_query.log' , \"#{$galago_path}/bin/galago batch-search --index=#{index_path} #{o[:param_query]} \\\n #{to_path(query_file)} |grep -e ^[0-9] > #{to_path(exp+'.res')}\" , :mode=>'a')\n `#{cmd}`\n end",
"def prep_sql_for_run\n self.sql = sql.strip\n self.sql = sql[0..-2] if sql.last == ';'\n self.sql = sql.dup\n end",
"def process db\n #verify if table exists\n table = EMMConfig[\"DB_TABLE_#{$opts[:table]}\"]\n sql=\"UPDATE #{table} SET processed=1 WHERE file_name IN \"\n sql << \"(\" << $files.map{ |k| \"'#{File.basename(k)}'\" }.join(',') << \");\"\n puts sql if $opts[:v]\n db.query(sql)\nend",
"def raw_sql_insert\r\n client = self.connect\r\n dataset = client[:fleet]\r\n \r\n db_str = \"LOAD DATA INFILE '/home/user/fleet.csv' \" +\r\n \"INTO TABLE fleet \" +\r\n \"FIELDS TERMINATED BY '\\t' \" +\r\n \"IGNORE 1 LINES \" +\r\n \"(@dummy, name, description);\"\r\n \r\n # raw mysql query.\r\n client.run(db_str)\r\n \r\n # cleanup\r\n puts \"raw sql insert\"\r\n client.disconnect\r\n \r\n return true\r\n end",
"def execute_batch(sql, *args, &block)\n @db.execute_batch(rewrite_table_names(sql), *args, &block)\n end",
"def import\n raise \"Could not find #{@opts.exec} in your PATH\" unless system(\"which #{opts.exec} > /dev/null\")\n\n file = File.join(@path, \"#{@name}.json\")\n cmd = \"#{opts.exec} --host #{opts.host} --port #{opts.port} --drop --db #{opts.db} --collection #{opts.collection} #{file}\"\n `#{cmd}`\n end",
"def db_command(user, pass, host, database, command)\n ENV['PGUSER'] = user\n ENV['PGPASSWORD'] = pass\n ENV['PGHOST'] = host\n ENV['PGDATABASE'] = database\n puts \"Running: #{command}\"\n `psql -c \"#{command}\"`\nend",
"def execute(sql)\n stmt = IBM_DB.exec(@conn, sql)\n raise Error.new(error_msg, error_sqlstate) unless stmt\n Statement.new(stmt)\n end",
"def sql\n @parser.sql\n end",
"def sql\n @parser.sql\n end",
"def execute(sql, name = nil)\n exec_no_cache(sql, name, nil)\n end",
"def write_food_group_table()\n puts <<SQL\ndrop table if exists FOOD_GROUP;\ncreate table FOOD_GROUP(\n id char(5) not null,\n description varchar(60) not null,\n primary key(id)\n);\nSQL\n\n read_data('FD_GROUP.txt') do |fields|\n puts make_insert_statement('FOOD_GROUP', fields, 'id', 'description')\n end\nend",
"def scripts_previously_run(scripts)\n if scripts.empty? || [email protected]_schema_evolution_manager_exists?\n []\n else\n sql = \"select filename from %s.%s where filename in (%s)\" % [Db.schema_name, @table_name, \"'\" + scripts.join(\"', '\") + \"'\"]\n @db.psql_command(sql).strip.split\n end\n end"
] | [
"0.7691078",
"0.705187",
"0.7034006",
"0.6773791",
"0.6603297",
"0.65852493",
"0.6580585",
"0.657862",
"0.64328474",
"0.6422488",
"0.6384859",
"0.632344",
"0.62999606",
"0.62642056",
"0.62631977",
"0.62557673",
"0.62017816",
"0.6195048",
"0.61868215",
"0.61494285",
"0.61089027",
"0.6081001",
"0.6071021",
"0.6059371",
"0.604172",
"0.6030428",
"0.6009169",
"0.59934103",
"0.5960217",
"0.59418166",
"0.59361255",
"0.5932178",
"0.59278536",
"0.58828753",
"0.5868386",
"0.58601177",
"0.5846257",
"0.5836865",
"0.58340424",
"0.58279544",
"0.5771383",
"0.5767628",
"0.57571054",
"0.57570815",
"0.57412857",
"0.5740597",
"0.57120425",
"0.5703613",
"0.569987",
"0.5682948",
"0.5681963",
"0.566396",
"0.5656402",
"0.5656308",
"0.5638663",
"0.5637727",
"0.5634456",
"0.5622347",
"0.562029",
"0.5613815",
"0.55925846",
"0.55822605",
"0.5557974",
"0.554366",
"0.55372125",
"0.55200696",
"0.551677",
"0.5503315",
"0.5495622",
"0.5490273",
"0.547811",
"0.54673296",
"0.54619956",
"0.5458197",
"0.5444921",
"0.5439748",
"0.5426085",
"0.5414363",
"0.5408711",
"0.54079247",
"0.5407253",
"0.5406983",
"0.5406147",
"0.53770256",
"0.5375435",
"0.5358945",
"0.5355716",
"0.53506225",
"0.5341223",
"0.5337103",
"0.53210807",
"0.5311148",
"0.5309766",
"0.5309171",
"0.53065526",
"0.53035897",
"0.53035897",
"0.52995926",
"0.52884465",
"0.5287333"
] | 0.78862566 | 0 |
the main method used when running user's code | def run_sql(limit: 100, cmds: $sql_commands, print: true, label: 'SELECT Results', collapsed: false, &block)
Display.status("Running sql commands...")
cmds = [cmds] if cmds.is_a? String
results = cmds.map do |cmd|
dataset = run_cmd(cmd) || []
if dataset.count > 0
lbl = label
lbl += " (Top #{limit} of #{dataset.count})" if dataset.count > limit
lbl = "-" + lbl if collapsed
block.call(dataset, lbl) if block
Display.table(dataset.to_a.take(limit), label: lbl, allow_preview: true) if print
end
dataset
end
results.select! {|r| r.count > 0 }
if results.length > 1
$sql_multi = true
$sql_results = results
else
$sql_multi = false
$sql_results = results.first || []
end
rescue Sequel::DatabaseError => ex
msg = ex.message.gsub("SQLite3::SQLException: ", "");
puts Display.print("ERROR", "There was an error with the SQL query:\n\n#{msg.strip}")
[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main; end",
"def main\n end",
"def main\n\n end",
"def run_main\n end",
"def main\n\nend",
"def program; end",
"def main(argv)\n # override this; no default action in main\n end",
"def main\n puts \"computor\"\nend",
"def execute\n setup\n begin\n data = main\n rescue ArgumentError => e\n warn e.message\n exit 1\n end\n puts format_data(data)\n end",
"def program() @program end",
"def main\n @workspace.main\n end",
"def main()\n puts(\"Hello, Ruby.\")\n\nend",
"def main_run\n raise NotImplementedError\n end",
"def main\n @app.main\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def main\n self\n end",
"def run\n puts \"Hello world\"\n end",
"def main\n\n # test\n\n # Console.new\n console_start\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def main(*args)\n #puts self.class # TODO: fix help\n raise NoCommandError\n end",
"def run() end",
"def run\n end",
"def run\n \n end",
"def run\n \n end",
"def runner; end",
"def main_end ; end",
"def main_run\n\n reset = true #flag to now if you want to exit or not\n\n while reset\n\n puts 'Welcome to CS Air.'\n\n @num_to_command.each {|num,cmd| puts \"Type #{num} for #{cmd}\"}\n command = gets.chomp.to_i\n\n while not @num_to_command.has_key?(command)\n puts 'Please try again'\n command = gets.chomp.to_i\n end\n\n case\n when command == 1\n reset = false #user wants to exit\n next\n when command == 2\n @ui_lib.print_city_list #print out list of all the cities\n next\n when command == 3\n city_specific_run #city specific details\n next\n when command == 4\n statistic_run #CS Air statistic details\n next\n when command == 5\n system('open', @ui_lib.query.get_map_url)\n next\n end\n end\n end",
"def run(_); end",
"def run(_); end",
"def main\n include GameStatus\n the_user = User.new\n\n if the_user.prompt_start.downcase.eql? 'y'\n #game continues to begin\n else\n puts(Colors.colorize('Why not tho?', 'cyan_b'))\n exit(0)\n end\n\n Output.print_intro\n the_secret_code = SecretCode.new\n the_user.take_input\n the_user.give_feedback\nend",
"def run_program()\n final_words()\n segmented_output()\n end",
"def run()\n end",
"def main\n @main ||= RubyPython.import \"__main__\"\n end",
"def perform\n\tcheck_if_user_gave_input\n\tcreate_folder(get_folder_name)\n\t\n\tDir.chdir(\"#{get_folder_name}\")\n\t\n\tgemfile_creation\n\tgit_init\n\tdotenv_gitignore\n\tlib\n\trspec\n\treadme\n\n\tprint 'enter the title of your main ruby file : '\n\tmain_dot_rb = STDIN.gets.chomp\n\tputs ''\n\n\tDir.chdir('lib') do\n\t\tcreate_main_dot_rb(main_dot_rb)\n\t\tcreate_template_dot_rb\n\tend\n\n\tDir.chdir('spec') do\n\t\tcreate_main_spec_dot_rb(main_dot_rb)\n\t\tcreate_template_spec_dot_rb\n\t\tsystem(\"subl #{main_dot_rb}_spec.rb\")\t\n\tend\nend",
"def run\n code = 0\n opt = OptionParser.new\n define_options(opt)\n default_options(opt)\n define_exit_codes(opt)\n argv = opt.parse!\n\n if @help\n puts_msg(opt.help)\n\n else\n begin\n main(argv)\n rescue Exception => e\n arr = @@exit_code_map[e.class]\n code = arr ? arr[0] : 1\n puts_err e.to_s\n puts_err \"[ERROR]\"\n end\n end\n\n exit(code)\n end",
"def run\n raise \"Not implemented yet.\"\n end",
"def launch!\n\t\tintroduction\n\t\t\taction = nil\n\t\t\tuntil action == :quit\n\t\t\t# action loop\n\t\t\t# what do you want to do? (list, find, add, quit)\n\t\t\tprint \"> \"\n\t\t\tuser_response = gets.downcase.strip!.split(' ')\n\t\t\t# do that action\n\t\t\taction,args = do_action(user_response[0],user_response[1])\n\t\tend\n\t\tconclusion\n\tend",
"def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\" if @options.verbose\n output_options if @options.verbose # [Optional]\n process_arguments\n # add parameters\n args = {}\n # TODO: use correct syntax for set\n args[:verbose] = @options.verbose if @options.verbose\n args[:input] = @options.input if @options.input\n args[:output] = @options.output if @options.output\n args[:map_name] = @options.map_name if @options.map_name\n args[:not_installed] = @options.cwd if @options.cwd\n \n program = Guy.new args\n program.work\n puts \"Finished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end \n end",
"def run\n greet\n menu\n end",
"def run\n end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def main()\n\n\twhile(line = STDIN.gets())\n\t\tputs \"\\t\\t#{line.chomp} @#{$clock}\"\n\t\tline = line.strip()\n\t\tarr = line.split(' ')\n\t\tcmd = arr[0]\n\t\targs = arr[1..-1]\n\t\tcase cmd\n\t\twhen \"EDGEB\"; edgeb(args)\n\t\twhen \"EDGED\"; edged(args)\n\t\twhen \"EDGEU\"; edgeu(args)\n\t\twhen \"DUMPTABLE\"; dumptable(args)\n\t\twhen \"SHUTDOWN\"; shutdown(args)\n\t\twhen \"STATUS\"; status()\n\t\twhen \"SENDMSG\"; sendmsg(args)\n\t\twhen \"PING\"; ping(args)\n\t\twhen \"TRACEROUTE\"; traceroute(args)\n\t\twhen \"FTP\"; ftp(args);\n\t\twhen \"CIRCUIT\"; circuit(args);\n\t\telse STDERR.puts \"ERROR: INVALID COMMAND \\\"#{cmd}\\\"\"\n\t\tend\n\tend\nend",
"def run\n puts \"\"\n puts Rainbow(\"Please Enter:\").orange\n print Rainbow(\"'All'\").green \n puts \"----- for a list of all SpaceX flights\"\n print Rainbow(\"'Year'\").green \n puts \"---- to see flights by a given year\"\n print Rainbow(\"'Rocket'\").green \n puts \"-- to see all flights with a given rocket type\"\n print Rainbow(\"'Success'\").green \n puts \"- to see all successful or unsuccessful flights\"\n print Rainbow(\"'Number'\").green \n puts \"-- to search a specific flight number\"\n print Rainbow(\"'Mission'\").green \n puts \"- to search by mission name\"\n print Rainbow(\"'Random'\").green \n puts \"-- to see a random launch\"\n print Rainbow(\"Typing \").orange\n print Rainbow('Main ').green\n puts Rainbow(\"at any point will return to this menu\").orange\n get_input_main\n end",
"def run\r\n return puts(\"usage example: glimmer run tictactoe\") unless @name\r\n # Search for the filename (and add the .rb extension if not provided), and run it\r\n if File.exist?(\"#{@name}#{'.rb' unless @name =~ /.rb$/}\")\r\n command = \"#{JRUBY_COMMAND} \\\"#{@name.gsub(/\\\\/, '/')}#{'.rb' unless @name =~ /.rb$/}\\\"\"\r\n else\r\n # Search for all installed samples and try to run of those\r\n command = \"#{JRUBY_COMMAND} \\\"#{SAMPLES_PATH}/#{fetch_app(@name)}.rb\\\"\"\r\n end\r\n puts \"Starting the application with following command:\"\r\n puts command\r\n system command\r\n end",
"def exec; end",
"def exec; end",
"def run\n puts \"#{@name} is running.\"\n end",
"def script; end",
"def script; end",
"def main\r\n\r\n\tname = read_string('What is your name?')\r\n\tputs 'Your name is ' + name + '!'\r\n\tfamily_name = read_string('What is your family name?')\r\n\tputs 'Your family name is: ' + family_name + '!'\r\n\tyear_born = read_integer('What year were you born?')\r\n\tage = Date.today.year - year_born\r\n\tputs 'So you are ' + age.to_s + ' years old'\r\n\tvalue = read_float('Enter your height in metres (i.e as a float): ')\r\n\tvalue = value * INCHES\r\n\tputs 'Your height in inches is: '\r\n\tputs value.to_s\r\n\tputs 'Finished'\r\n\tcontinue = read_boolean('Do you want to continue?')\r\n\tif (continue)\r\n\t\tputs 'Ok, lets continue'\r\n\telse\r\n\t\tputs 'ok, goodbye'\r\n\tend\r\nend",
"def run(args)\n raise \"not implemented\"\n end",
"def run\n # Change the working directory to the directory of this script.\n Dir.chdir(File.dirname(__FILE__)) \n\n # if LIST_TECHNIQUES is true, just output available evasion techniques.\n if datastore['LIST_TECHNIQUES'] == true\n print_available_techniques()\n else\n payload = datastore['PAYLOAD']\n payload_options = datastore['PAYLOAD_OPTIONS']\n output_directory = datastore['OUTPUT_DIRECTORY']\n executable_name = datastore['EXECUTABLE_NAME']\n evasion_stack = datastore['EVASION_STACK']\n msfvenom_path = datastore['MSFVENOM_PATH']\n\n if payload == nil\n print_error(\"PAYLOAD must be set.\")\n return \n end\n if output_directory == nil \n print_error(\"OUTPUT_DIRECTORY must be set.\")\n return\n end\n if executable_name == nil \n print_error(\"EXECUTABLE_NAME must be set.\") \n return\n end\n if msfvenom_path == \"\"\n # Guess at path to msfvenom\n msfvenom_path = Dir.pwd[0..(Dir.pwd.index(\"pro\")+3)]+\"msf3/msfvenom\"\n print_status(\"MSFVENOM_PATH not specified. Hoping msfvenom can be found at \"+msfvenom_path+\".\")\n end\n\n binary_generated = generate_binary(msfvenom_path, payload, payload_options)\n if binary_generated\n print_status(\"Payload binary generated successfully.\")\n print_status(\"Generating evasive source from generated binary.\")\n\n generate_evasive_source(evasion_stack)\n\n executable_generated = generate_executable(output_directory+\"/\"+executable_name)\n\n if executable_generated\n print_status(\"Executable successfully generated.\")\n else\n print_error(\"Unable to generate executable.\")\n end\n else\n print_error(\"Payload generation with msfvenom failed.\")\n end\n\n print_status(\"Cleaning up temporary files.\")\n\n if File.exist?('tmp/bin'+self.uuid+'.c')\n File.delete('tmp/bin'+self.uuid+'.c')\n end\n if File.exist?('tmp/evasive'+self.uuid+'.c')\n File.delete('tmp/evasive'+self.uuid+'.c')\n end\n\n end\n end",
"def run(*args)\n end",
"def start_run; end",
"def start_program\n load_questions\n say_hello\n program_loop\nend",
"def run(name); end",
"def run(*args)\n end",
"def main\n print \" ruby> \"\n input = gets\n puts eval(input)\n main\nend",
"def main\n if ARGV.empty?\n puts \"Usage: ruby #{File.basename($0)} EPUBFILE [EPUBFILE ...]\"\n exit 1\n end\n\n puts make_catalog(ARGV)\nend",
"def introduction # def opens a function/ method\n\tputs \"This is an introduction program to ruby.\" # puts includes \\n newline before displaying a string\n\tputs \"If you entered this from the command line it would have looked something like this...\"\n\tputs \"\\n\\t$\\t#{$0}\" # \"#{$0}\"\" displays the script ran from the command line. \nend",
"def main\r\n puts \"Welcome to the music player\"\r\n\talbums = read_albums()\r\n\tprint_albums(albums)\r\nend",
"def argv; end",
"def main\r\n operations.make\r\n \r\n intro\r\n \r\n # Prepares tubes, buffers, and other equiptment to extract RNA either mechanical/enzymaticall and takes into account the RNA kit used(RNeasy/miRNeasy)\r\n rna_extraction_prepartion(INPUT, OUTPUT, METHOD, CELL_LYSIS)\r\n \r\n # Fresh overnights/cells need to be quenched and pelleted before extraction\r\n over_ops = operations.select { |op| op.input(INPUT).object_type.name == 'Yeast Overnight Suspension'}\r\n (!over_ops.empty?) ? quenching(over_ops, INPUT) : nil\r\n \r\n # Assumption is that samples that are not overnights will be in the -80 freezer - this gathers the remaining samples that will be processed in this experiment\r\n remaining_ops = operations.select { |op| op.input(INPUT).object_type.name != 'Yeast Overnight Suspension'}\r\n \r\n # Retrieves the remaining operations that are NOT overnights\r\n (!remaining_ops.empty?) ? show {warning \"<b> If you are gathering your samples from the freezer, keep them on ice from this step until noted.</b>\"} : nil\r\n (!remaining_ops.empty?) ? (take remaining_ops.map {|op| op.input(INPUT).item}, interactive: true): nil\r\n \r\n # Groups operations by cell lysing method and processes them by method\r\n group_by_lysis = operations.map.group_by {|op| op.input(CELL_LYSIS).val}.sort\r\n group_by_lysis.each {|lys_arr| cell_lysis(lys_arr) }\r\n \r\n # Return chemicals back to appropriate storage\r\n clean_fumehood\r\n \r\n # Directs tech to use Qiagen kits - Once cell have been processed to lysates \r\n qiagen_kit\r\n \r\n delete_input_items \r\n \r\n nanodrop_rna_extracts(INPUT, OUTPUT)\r\n \r\n delete_input_items\r\n \r\n operations.store\r\n return {}\r\n end",
"def main \n\tsolar_system = SolarSystem.new('Sol')\n\n\tearth = Planet.new('Earth', 'blue-green', 5.972e24, 4.769e9, 'Only planet known to support life')\n\tsolar_system.add_planet(earth)\n\n\tvenus = Planet.new('Venus', 'White', 6.392e24, 2.982e9, 'Sister planet to Earth')\n\tsolar_system.add_planet(venus)\n\n\tputs \"What action would you like to take?\"\n\tuser_control = gets.chomp.downcase\n\t\n\t# Prompts user for options until they choose to exit\n\tuntil user_control == 'exit'\n\t\tcase user_control\n\t\twhen 'list planets'\n\t\t\tputs solar_system.list_planets\n\t\twhen 'planet details'\n\t\t\tdisplay(solar_system)\n\t\twhen 'add planet'\n\t\t\tuser_create_planet(solar_system)\n\t\twhen 'find distance'\n\t\t\tdisplay_distance_between(solar_system)\n\t\telse\n\t\t\tputs \"Please enter a valid option.\"\n\t\tend\n\t\t\n\t\tputs \"What action would you like to take next?\"\n\t\tuser_control = gets.chomp.downcase\n\tend\n\nend",
"def main\n\tputs 'Starting GGT Home Script'\n\t#puts 'Please enter \"ruby ggt_home.rb about\" to learn more about this script'\n\n\tdirectory = '/var/www/ggt_testing/ggt'\n\n\t## make sure the 'ggt' directory is present in this directory\n\tunless check_server directory\n\t\tputs 'Quitting'\n\t\treturn false\n\tend\n\t## Ask the user for a password, validate\n\tkey = get_key;\n\n\t#encrypt and move the files\n\tencrypt_move(directory, key)\n\n\tputs 'GGT Home Script finished'\nend",
"def main\n\tconsume = ARGV[0] == '-c'\n\tgenerate = ARGV[0] == '-g'\n\tARGV.shift\n\tARGV.shift\n\tinteractive = ! (consume or generate)\n\tif generate\n\t\tgenerate_forever\n\telsif consume\n\t\tcheck_forever\n\telse\n\t\t# interactive mode\n\t\tinteractive_loop\n\tend\nend",
"def main\n Cabar::Main.current\n end",
"def main\n\n\n operations.running.retrieve interactive: false\n save_user operations\n debug_setup(operations) if debug\n \n if KIT_NAME == \"uw kit\"\n if debug\n labels = \"ABCDEF\".split('')\n operations.each.with_index do |op, i|\n op.input(INPUT).item.associate(SAMPLE_KEY, labels[i]) \n op.input(INPUT).item.associate(COMPONENT_KEY, \"\") \n end\n end\n end\n \n save_temporary_input_values(operations, INPUT)\n operations.each do |op|\n op.temporary[:pack_hash] = PACK_HASH\n end\n save_temporary_output_values(operations)\n \n # reassign labels to sample numbers if uw kit\n if KIT_NAME == \"uw kit\"\n operations.each do |op|\n op.temporary[:output_sample] = {\"A\"=>1, \"B\"=>2}[op.temporary[:output_sample]]\n end \n end\n \n run_checks operations\n if KIT_NAME == \"uw kit\"\n uw_kit_introduction operations.running\n else\n kenya_kit_introduction operations.running\n end\n area_preparation \"pre-PCR\", MATERIALS, POST_PCR\n get_pcr_packages operations.running\n open_pcr_packages operations.running\n debug_table operations.running\n check_for_tube_defects sorted_ops.running\n # nuttada thaw\n # nuttada needs vortex + centrigure\n centrifuge_samples sorted_ops.running\n resuspend_pcr_mix sorted_ops.running\n add_template_to_master_mix sorted_ops.running\n cleanup sorted_ops\n start_thermocycler sorted_ops.running\n conclusion sorted_ops\n return {}\n end",
"def start\n return if initialized\n puts copyright\n argv = ARGV\n ARGV.clear\n IRB.start\n ARGV.replace(argv)\n end",
"def run\n begin\n raise TooManyArgumentsError.new(@arguments) if @arguments.length > 1\n \n print_version if @options.version?\n scan if @options.scan?\n rename_given_file unless @arguments.empty?\n run_gui if @arguments.empty?\n \n raise Error\n rescue => e\n puts e.to_s\n \n exit(1)\n end\n end",
"def run\n require_relative File.join(absolute_path, 'main')\n Gamefic::Tty::Engine.run\n end",
"def main\n operations.each do |op|\n op.temporary[:pack_hash] = PACK_HASH\n end\n save_user operations\n operations.running.retrieve interactive: false\n debug_setup operations\n save_temporary_input_values(operations, INPUT)\n save_temporary_output_values(operations)\n introduction operations.running\n area_preparation POST_PCR, MATERIALS, PRE_PCR\n get_detection_packages operations.running\n open_detection_packages operations.running\n rehydrate_stop_solution sorted_ops.running\n wait_for_pcr sorted_ops.running\n stop_ligation_product sorted_ops.running\n # short_timer\n rehydrate_gold_solution sorted_ops.running\n display_detection_strip_diagram\n add_ligation_product_to_strips sorted_ops.running\n add_gold_solution sorted_ops.running\n read_from_scanner sorted_ops.running\n # if KIT_NAME == \"uw kit\"\n # run_image_analysis operations.running \n # end\n cleanup sorted_ops\n conclusion sorted_ops\n return {\"Ok\" => 1}\n end",
"def run\n if arguments = parse_arguments\n begin\n process(arguments)\n rescue RuntimeError => ex\n Console.puts ex.message, :red\n exit 1\n end\n else\n if show_help?\n show_help(nil, Console.width).each do |line|\n Console.puts line, :cyan\n end\n else\n show_usage(nil, Console.width).each do |line|\n Console.puts line, :yellow\n end\n end\n exit 2\n end\n end",
"def launch!\n\t\tintroduction\n\n\t\tresult = nil\n\t\tuntil result == :quit\n\t\t\tprint \"> Choose one of these options: List, Sort, Find or Add.\\n\\n\"\n\t\t\tuser_response = gets.chomp\n\t\t\tresult = do_action(user_response)\n\t\tend\n\t\tconclusion\n\tend",
"def main()\n\n\twhile(line = STDIN.gets())\n\t\tline = line.strip()\n\t\tarr = line.split(' ')\n\t\tcmd = arr[0]\n\t\targs = arr[1..-1]\n\t\tcase cmd\n\t\twhen \"EDGEB\"; edgeb(args)\n\t\twhen \"EDGED\"; edged(args)\n\t\twhen \"EDGEU\"; edgeu(args)\n\t\twhen \"DUMPTABLE\"; dumptable(args)\n\t\twhen \"SHUTDOWN\"; shutdown(args)\n\t\twhen \"STATUS\"; status()\n\t\twhen \"SENDMSG\"; sendmsg(args)\n\t\twhen \"PING\"; req_ping(args)\n\t\twhen \"TRACEROUTE\"; traceroute(args)\n\t\twhen \"FTP\"; ftp(args);\n\t\twhen \"CIRCUIT\"; circuit(args);\n\t\telse STDERR.puts \"ERROR: INVALID COMMAND \\\"#{cmd}\\\"\"\n\t\tend\n\tend\n\nend",
"def main()\n\n\twhile(line = STDIN.gets())\n\t\tline = line.strip()\n\t\tarr = line.split(' ')\n\t\tcmd = arr[0]\n\t\targs = arr[1..-1]\n\t\tcase cmd\n\t\twhen \"EDGEB\"; edgeb(args)\n\t\twhen \"EDGED\"; edged(args)\n\t\twhen \"EDGEW\"; edgew(args)\n\t\twhen \"DUMPTABLE\"; dumptable(args)\n\t\twhen \"SHUTDOWN\"; shutdown(args)\n\t\twhen \"STATUS\"; status()\n\t\twhen \"SENDMSG\"; sendmsg(args)\n\t\twhen \"PING\"; ping(args)\n\t\twhen \"TRACEROUTE\"; traceroute(args)\n\t\twhen \"FTP\"; ftp(args)\n\t\twhen \"CIRCUIT\"; circuit(args)\n\t\telse STDERR.puts \"ERROR: INVALID COMMAND \\\"#{cmd}\\\"\"\n\t\tend\n\tend\n\nend",
"def main\n# He's going to be runnin' this here operation\n\t\n\t# Retrieving that shiny input file\n\tinput_file = File.new(ARGV[0])\n\t\n\t# Sortin' out them good lines from the bad\n\tinput_file = IO.readlines(input_file)\n\t\n\tif input_file.length == 0\n\t\traise BlankFileError\n\tend\n\n\tputs \"===================================================================\"\n\tputs \"This is the captain speaking. Welcome to the 03-K64 Compiler, and now if you'll excuse me for a minute it's time to burn atmo and get this ship in the air.\"\n\t\n\t# Lexer it!\n\tputs \"\\nBeginnin' the Lexing process now...\\n\"\n\ttoken_stream = lexer(input_file)\n\t\n\tputs \"\\nLexing completed successfully, all tokens have been smuggled into the system\\n\\nToken Stream (in order):\\n\"\n\t\n\t# print out the received tokens\n\tfor i in token_stream\n\t\tprint i.type\n\t\tif i.type != \"T_EOFSIGN\"\n\t\t\tprint \", \"\n\t\telse\n\t\t\tputs \"\\n\\n\"\n\t\tend\n\tend\n\t\n\t# Parse it!\n\tputs \"\\nNow we're gonna begin the parsin'...\"\n\tparser(token_stream)\n\tputs \"\\n\\nParsing successful. We've got ourselves a nice parse stream and symbol table now.\\n\\n\"\n\t\n\t$cst.printout\n\tputs \"\\n\\n\\n\"\n\t\n\tputs \"Now we're doin' some calculations and conversions, trying to change that CST to a nice AST...\\n\\n\"\n\t\n\tconvert_cst\n\t\n\tputs \"Printing out that AST now\"\n\t$ast.printout\n\tputs \"\\n\\n\"\n\t\n\tputs \"We're gonna begin the semantic analysis now.\\n\\n\"\n\t\n\tsemantic_analysis\n\tputs \"\\n\\n\"\n\t$symbol_table.printout\n\tputs \"\\n\\n\"\n\t$symbol_table.analysis($symbol_table.root)\n\tputs \"\\n\\n\"\n\tputs \"And now we're on to Code Generation. Here we might experience some turbulence, and possibly explode. So strap in!\\n\\n\"\n\tcode_gen\n\t\nend"
] | [
"0.8578571",
"0.8496346",
"0.8463617",
"0.8413922",
"0.8062536",
"0.79373",
"0.7746156",
"0.76237535",
"0.758176",
"0.74220675",
"0.7372789",
"0.73050517",
"0.723203",
"0.719297",
"0.7119105",
"0.7119105",
"0.7119105",
"0.7119105",
"0.7119105",
"0.7119105",
"0.7119105",
"0.7114597",
"0.7114597",
"0.7114597",
"0.7114597",
"0.7114597",
"0.7114597",
"0.7114597",
"0.7114597",
"0.7114597",
"0.70977217",
"0.7085549",
"0.70585525",
"0.7050988",
"0.7050988",
"0.7020897",
"0.6953141",
"0.6929872",
"0.6926671",
"0.6917712",
"0.6917712",
"0.69088763",
"0.69037765",
"0.6897871",
"0.6887997",
"0.6887997",
"0.68787754",
"0.68638325",
"0.68264234",
"0.6823061",
"0.68143255",
"0.679038",
"0.6747952",
"0.66842616",
"0.66838515",
"0.6683367",
"0.66749126",
"0.66712904",
"0.66712904",
"0.66712904",
"0.66712904",
"0.66712904",
"0.66712904",
"0.66712904",
"0.66712904",
"0.6656578",
"0.6621584",
"0.66187286",
"0.661019",
"0.661019",
"0.65915775",
"0.65720993",
"0.65720993",
"0.6570102",
"0.65522987",
"0.65178776",
"0.65116745",
"0.65018284",
"0.6472921",
"0.64657736",
"0.64395696",
"0.6435665",
"0.64312166",
"0.64277947",
"0.642224",
"0.6388061",
"0.63858473",
"0.6385795",
"0.6379181",
"0.6377414",
"0.6374053",
"0.6357634",
"0.63554794",
"0.63502413",
"0.6346077",
"0.633766",
"0.6336726",
"0.63317454",
"0.63205844",
"0.63098294",
"0.6308065"
] | 0.0 | -1 |
useful helper for finding a specific record and wrapping it in a Hashie::Mash | def find_record(table, id)
result = DB[table].where(id: id).first
result ? Hashie::Mash.new(result) : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find hash\n field, value = hash.first\n if index(field).unique\n if id = redis.get(colon(name, field, value))\n new id\n end\n else\n raise \"no unique index on #{field}\"\n end\n end",
"def find_record(item, no_raise: false, meth: nil, **opt)\n return item if item.nil? || item.is_a?(record_class)\n meth ||= __method__\n record = error = id = sid = nil\n id_key = opt.key?(:id_key) ? opt[:id_key] : id_column\n sid_key = opt.key?(:sid_key) ? opt[:sid_key] : sid_column\n if id_key || sid_key\n opt.merge!(item) if item.is_a?(Hash)\n opt.reverse_merge!(id_term(item, **opt))\n id = id_key && (opt[id_key] || opt[alt_id_key(opt)])\n sid = sid_key && opt[sid_key]\n if valid_sid?(id)\n if sid && (id != sid)\n Log.warn { \"#{meth}: id: #{id.inspect}, but sid: #{sid.inspect}\" }\n end\n id, sid = [nil, id]\n elsif id && sid\n Log.debug do\n \"#{meth}: choosing id: #{id.inspect} over sid: #{sid.inspect}\"\n end\n end\n if id && (id_key == id_column)\n record = record_class.find(id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif id\n record = record_class.find_by(id_key => id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif sid\n record = record_class.find_by(sid_key => sid)\n error = \"for #{sid_key} #{sid.inspect}\" unless record\n else\n error = '%s value given' % [id_key, sid_key].compact.join(' or ')\n end\n error &&= \"No #{record_name} #{error}\"\n else\n error = \"#{record_name}: both :id_key and :sid_key set to nil\"\n end\n if record\n record\n elsif !id && !sid\n Log.info { \"#{meth}: #{error} (no record specified)\" }\n raise_failure(:file_id) unless no_raise\n elsif no_raise\n # noinspection RubyMismatchedReturnType\n Log.warn { \"#{meth}: #{error} (skipping)\" }\n else\n Log.error { \"#{meth}: #{error}\" }\n raise_failure(:find, item) unless no_raise\n end\n end",
"def get_key(record)\n get(self.by, record)\n end",
"def find_record(item, no_raise: false, meth: nil, **opt)\n # noinspection RubyMismatchedReturnType\n return item if item.nil? || item.is_a?(record_class)\n meth ||= __method__\n record = error = id = nil\n\n id_key = opt.key?(:id_key) ? opt[:id_key] : id_column\n if id_key\n opt.merge!(item) if item.is_a?(Hash)\n opt.reverse_merge!(id_term(item, **opt))\n id = opt[id_key] || opt[alt_id_key(opt)]\n if id && (id_key == id_column)\n record = record_class.find(id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif id\n record = record_class.find_by(id_key => id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n else\n error = \"#{id_key} value given\"\n end\n error &&= \"No #{record_name} #{error}\"\n else\n error = \"#{record_name}: :id_key set to nil\"\n end\n\n if record\n record\n elsif !id\n Log.info { \"#{meth}: #{error} (no record specified)\" }\n raise_failure(:file_id) unless no_raise\n elsif no_raise\n # noinspection RubyMismatchedReturnType\n Log.warn { \"#{meth}: #{error} (skipping)\" }\n else\n Log.error { \"#{meth}: #{error}\" }\n raise_failure(:find, item) unless no_raise\n end\n end",
"def find_one(&block)\r\n copy_and_return(@records.find(&block))\r\n end",
"def get_key record\n record\n end",
"def find_record\n record_id = params[:record_id] || params[:id]\n @record = Record.where(medical_record_number: record_id).first\n not_found if @record.nil?\n end",
"def find_single_record zone, name, content, type = 'A'\n get_records(zone, name).values.each do |rec|\n if rec['zone_name'] == zone \\\n && rec['display_name'] == name \\\n && rec['content'] == content \\\n && rec['type'] == type\n return rec\n end\n end\n nil\n end",
"def get_record(item, **opt)\n find_by(**id_term(item, **opt))\n end",
"def find_by_reference_key(class_name, record_id)\n find_by_reference_keys [class_name, record_id]\n end",
"def get_record\n recordset = self.get_recordset\n find_by_fields = self.get_find_by_fields\n find_by_key = self.get_model.primary_key\n\n # Find by another column if it's permitted.\n if find_by_query_param && params[find_by_query_param].in?(find_by_fields)\n find_by_key = params[find_by_query_param]\n end\n\n # Filter recordset, if configured.\n if self.filter_recordset_before_find\n recordset = self.get_filtered_data(recordset)\n end\n\n # Return the record.\n if find_by_value = params[:id] # Route key is always :id by Rails convention.\n return self.get_recordset.find_by!(find_by_key => find_by_value)\n end\n return nil\n end",
"def find_existing_record\n @record = record_class.find(@locator)\n end",
"def find_existing_record\n @record = record_class.find(@locator)\n end",
"def find_record\n @record = reply_address.record\n end",
"def find(record_id)\n results = CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\")\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects.first \n end",
"def find_record\n @record ||= model.find_by_id(params[:id])\n end",
"def record_hash(record, fieldset, params = {})\n if cached\n record_hash = Rails.cache.fetch(record.cache_key, expires_in: cache_length, race_condition_ttl: race_condition_ttl) do\n temp_hash = id_hash(id_from_record(record), record_type, true)\n temp_hash = temp_hash.merge(attributes_hash(record, fieldset, params)) if attributes_to_serialize.present?\n temp_hash[:relationships] = {}\n temp_hash[:relationships] = relationships_hash(record, cachable_relationships_to_serialize, fieldset, params) if cachable_relationships_to_serialize.present?\n temp_hash[:links] = links_hash(record, params) if data_links.present?\n temp_hash\n end\n record_hash[:relationships] = record_hash[:relationships].merge(relationships_hash(record, uncachable_relationships_to_serialize, fieldset, params)) if uncachable_relationships_to_serialize.present?\n record_hash[:meta] = meta_hash(record, params) if meta_to_serialize.present?\n record_hash\n else\n record_hash = id_hash(id_from_record(record), record_type, true)\n record_hash = record_hash.merge(attributes_hash(record, fieldset, params)) if attributes_to_serialize.present?\n record_hash[:relationships] = relationships_hash(record, nil, fieldset, params) if relationships_to_serialize.present?\n record_hash[:links] = links_hash(record, params) if data_links.present?\n record_hash[:meta] = meta_hash(record, params) if meta_to_serialize.present?\n record_hash\n end\n end",
"def get_record(identifier)\n find_by(**id_term(identifier))\n end",
"def hash_record_low_mem! set, rec, duplicate_type\n key = make_key rec, duplicate_type\n\n set << key\nend",
"def find(record_id) \n result = CONNECTION.execute(\"SELECT * FROM #{self.table_name} WHERE id = #{record_id}\").first\n \n self.new(result)\n end",
"def record_key_for_dom_id(record); end",
"def find_record(relation = nil)\n if locate_id.nil? || (locate_id.is_a?(::Numeric) && locate_id == 0) || (locate_id.to_s == '')\n return -1\n end\n\n dataset = load_records(relation, false)\n return -1 if dataset.blank?\n\n first_item = dataset.first\n klass = first_item.class\n\n id_field = klass.respond_to?('primary_key') ? klass.primary_key : nil\n id_field ||= first_item.respond_to?('id') ? 'id' : nil\n\n return -1 unless id_field\n if locate_id.is_a?(::Numeric)\n dataset.index{|item| item.send(id_field) == locate_id} || -1\n else\n loc_id = locate_id.to_s.downcase\n dataset.index{|item| item.send(id_field).to_s.downcase == loc_id} || -1\n end\n\n end",
"def find(record_id)\n result = DATABASE.execute(\"SELECT * FROM #{table} WHERE id = #{record_id}\").first\n\n self.new(result)\n end",
"def find_by_attributes\n Hash[@ucrm_local_id_field, id]\n end",
"def hash_record! ht, rec, duplicate_type\n case duplicate_type\n when 1 # whole header match\n unless ht.has_key? rec.header\n ht[rec.header] = rec\n end\n when 2 # header ID match\n unless ht.has_key? rec.id\n ht[rec.id] = rec\n end\n when 3 # whole seq match\n unless ht.has_key? rec.seq\n ht[rec.seq] = rec\n end\n when 4 # whole seq + whole header\n key = \"#{rec.header}#{rec.seq}\"\n unless ht.has_key? key\n ht[key] = rec\n end\n when 5 # whole seq + hedaer ID\n key = \"#{rec.id}#{rec.seq}\"\n unless ht.has_key? key\n ht[key] = rec\n end\n end\nend",
"def get_note(obj, id)\n obj['notes'].find {|n| n['persistent_id'] == id}\nend",
"def find_record\n record_id = params[:record_id] || params[:id]\n @record = Record.where(medical_record_number: record_id).first\n raise RequestError.new(404) if @record.nil?\n end",
"def find_by_id(input, value)\n hash = nil\n input.each do |input|\n if input[:id] == value\n hash = input\n end\n end\n hash\nend",
"def _find_record(options)\n if options && options[:lock]\n self.class.preload(strict_loaded_associations).lock(options[:lock]).find_by!(hid: hid)\n else\n self.class.preload(strict_loaded_associations).find_by!(hid: hid)\n end\n end",
"def find(record_id)\n self.new(CONNECTION.execute(\"SELECT * FROM #{get_table_name} WHERE id = #{record_id}\").first)\n end",
"def find(id); end",
"def find(id); end",
"def find(id)\n @candidates.each do | candidate |\n if candidate[:id] == id\n return candidate \n end\n end\nend",
"def find_one(params, field = :_id)\n return nil if params.nil? #to avoid mistakes \n return self.find(params).first if params.is_a? Hash\n\n find_one((field.to_s) => params)\n end",
"def find(record_id)\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results= CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\")\n if results.empty? \n return nil\n else \n result=results.first\n self.new(result)\n end\n end",
"def get_key_for_record (record:, record_class:)\n if record.is_a?(Hash)\n record_id = record[:id] || record[:_id]\n else\n record_id = record.id\n end\n raise RuntimeError, 'missing record_id' if record_id == nil\n record_class ||= record.class.name\n raise RuntimeError, 'missing record_class' if ['', nil, 'Hash'].include?(record_class)\n key = [record_class, record_id.to_s].join(':')\n return key\n end",
"def find(id)\n # takes single candidate as id :\n @candidates.each do | candidate |\n if candidate[:id] == id \n\n return candidate\n else \n nil\n end\n end\nend",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id] \n return candidate\n end\nend\n\n nil\nend",
"def find(uuid, options = {})\n if uuid.nil?\n # Should we raise an ArgumentError, instead?\n raise NotFound, \"can't find a record with nil identifier\"\n end\n\n uri = uuid =~ /^http/ ? uuid : member_path(uuid)\n attributes = @records[uri] || raise(NotFound, \"No #{self.name} found with uuid = #{uuid}\")\n from_storage(attributes)\n end",
"def find_record\n if record\n self.new_session = false\n return record\n end\n \n find_with.each do |find_method|\n if send(\"valid_#{find_method}?\")\n self.new_session = false\n return record\n end\n end\n nil\n end",
"def find(record_id) \n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n results = QUIZ.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\").first\n self.new(results)\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend",
"def find_by_key(val)\n find(:first, :conditions => {:key => prepare_key(val)})\n end",
"def get_key(record)\n case record\n when Class then record\n when Array then record.map { |i| get_key(i) }\n when Symbol then record\n when String then record\n else record.class\n end\n end",
"def student_details(s_name)\n #code here\n @students.find {|n| n[:name] == s_name} [:email]\nend",
"def find_record #:nodoc:\r\n if @tables.size == 1\r\n @record = @tables.first[0].find(params[:id])\r\n else\r\n rec = @tables.first[0].find(@ids.first) # top most record\r\n 1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids\r\n @record = rec.send(@tables.last[1].pluralize).find(params[:id]) # record to edit\r\n end\r\nend",
"def find_record #:nodoc:\r\n if @tables.size == 1\r\n @record = @tables.first[0].find(params[:id])\r\n else\r\n rec = @tables.first[0].find(@ids.first) # top most record\r\n 1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids\r\n @record = rec.send(@tables.last[1].pluralize).find(params[:id]) # record to edit\r\n end\r\nend",
"def harvest_single_record(company_id, record_id, cookies, keyword=nil)\n page = request_page(\"/BC.xhtml?&nextURL=http://www.jigsaw.com/SearchContact.xhtml?companyId=#{company_id}&contactId=#{record_id}\", cookies)\n record = {\n 'firstname' => '',\n 'lastname' => '',\n 'title' => '',\n 'company' => '',\n 'city' => '',\n 'state' => '',\n 'ID' => ''\n }\n record['ID'] = record_id\n values = page.body.split('id=')\n values.each do |value|\n case\n when value.include?('firstname')\n record['firstname'] = clean_line(value)\n when value.include?('lastname')\n record['lastname'] = clean_line(value)\n when value.include?('\"title\" title=\"')\n record['title'] = clean_line(value)\n when value.include?('city\">')\n record['city'] = clean_line(value)\n when value.include?('state\">')\n record['state'] = clean_line(value)\n when value.include?('_company.xhtml\">')\n record['company'] = value.split('company.xhtml\">')[1].split('<')[0].to_s\n end\t\n end\n case keyword\n when nil\n return record\n else\n return record if record['title'].downcase.include? keyword.downcase\n end\nend",
"def get_record(fqdn, type)\n matches = find_match(@dnss.records, fqdn, true)\n if matches != nil\n record = nil\n matches.each do |record|\n Puppet.debug \"inspecting #{record.hash_type} == #{type}\"\n if record.hash_type.to_s == type.to_s\n Puppet.notice \"found dns record : #{fqdn}, #{type}\"\n return record\n end\n end\n else\n Puppet.debug \"match found no record : #{fqdn}, #{type}\"\n end\n Puppet.debug \"record not found : #{fqdn}, #{type}\"\n return nil\n end",
"def id_from_record(record)\n f907 = record.find {|f| f.tag == \"907\"}\n f907.subfields.find {|s| s.code == \"a\"}.value\nend",
"def find(*args, &block)\n if args.first.is_a?(Hash)\n super(*args, &block)\n else\n super(id: args)\n end\n end",
"def cache_key(record)\n record.object_id\n end",
"def cache_key(record)\n record.object_id\n end",
"def find(id)\n @records.find { |record| record.id == id }\n end",
"def find(id)\n found = nil\n @candidates.each do |candidate|\n if candidate[:id] == id\n found = candidate\n end\n end\n found\nend",
"def find_record\n if @zone.nil?\n if @resource[:zoneid] != 'absent' then\n @zone = zone_by_id @resource[:zoneid]\n if @zone.nil? then\n self.fail \"No zone with id: #{@resource[:zoneid]}\"\n end\n else\n @zone = zone_by_name @resource[:zone]\n if @zone.nil? then\n self.fail \"No such zone: #{@resource[:zone]}\"\n end\n end\n end\n @records = @zone.records\n @records.each do |record|\n if record.name == @resource[:record]\n return record\n end\n end\n return nil\n end",
"def hash\n __record_id.hash\n end",
"def find _key\n _object = store.transaction(:read_only) { |s| s[prepare_key(_key)] }\n _object.send(:after_load) if _object\n _object\n end",
"def cache_key(record)\n record.object_id\n end",
"def find_id(id)\n @candidates.find {|candidate| candidate if candidate[:id] == id}\nend",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find_by_key(key)\n find_by_id(key) # backlog method looks exactly the same except for the parameter type\n end",
"def find(id)\[email protected] {|candidate| candidate[:id] == id}\nend",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n \tif candidate[:id] == id\n \t return candidate\n \tend\n end\n return nil\nend",
"def find_single_item(hash,lookup)\n if hash[lookup]==nil\n return nil\n else\n return hash[lookup][:item]\n end\nend",
"def get!(key)\n model = get(key)\n return model if model\n\n raise ActiveRecord::ShardFor::RecordNotFound\n end",
"def find(id)\n # Your code Here\n # puts \"you are looking for id: #{id}\"\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n return nil\nend",
"def find(id)\n @candidates.find {|h| h[:id] == id}\nend",
"def find_record\n if @zone.nil?\n if @resource[:zoneid] != 'absent' then\n @zone = @resource[:zoneid]\n else\n @zone = zone_by_name @resource[:zone]\n if @zone.nil? then\n self.fail \"No such zone: #{@resource[:zone]}\"\n end\n end\n end\n connection.list_resource_record_sets(hosted_zone_id: @zone, start_record_name: @resource[:record], start_record_type: @resource[:type]).resource_record_sets.each do |record|\n if record.name == @resource[:record] && record.type == @resource[:type]\n return record\n end\n end\n return nil\n end",
"def find(id)\r\n find_one do |record|\r\n record.id == id\r\n end\r\n end",
"def find(model, id)\n key = model.primary_key\n condition = {\"#{key}\" => id}\n data = store.read(condition, table: table_name).first\n fail RecordNotFound.new(condition, table_name) unless data\n\n model.new data\n end",
"def replicate_find_existing_record(attributes)\n return if replicate_natural_key.empty?\n conditions = {}\n replicate_natural_key.each do |attribute_name|\n conditions[attribute_name] = attributes[attribute_name.to_s]\n end\n if ::ActiveRecord::VERSION::MAJOR >= 4\n where(conditions).first\n else\n find(:first, :conditions => conditions)\n end\n end",
"def find(id)\n @candidates.each do |person|\n if person[:id] === id\n return person\n end\n end\n return nil\nend",
"def find_entry\n ms = model_scope\n result = nil\n if params[:id]\n # Requests that retrieve existing records (e.g. show, edit, update, destroy) set an 'id' param\n # The +find+ method raises ActiveRecord::RecordNotFound if no database item has this primary key\n result = ms.find(params[:id])\n elsif params[ms.primary_key]\n # Primary key is a single value provided in the params hash\n # This modification allows the create action to succeed even if the item already exists\n # The +where...first+ methods returns the item from the database or nil if not found\n result = ms.where(ms.primary_key => params[ms.primary_key]).first\n elsif ms.primary_key.instance_of? CompositePrimaryKeys::CompositeKeys\n # primary key is composed of multiple values\n if (ms.primary_key - params.keys).empty?\n # param values are present for all the primary keys\n pk_values = ms.primary_key.map{|k| params[k]}\n result = ms.find(pk_values)\n end\n end\n result\n end",
"def primary_key_lookup(pk)\n ck = cache_key(pk)\n unless obj = cache_get(ck)\n if obj = super(pk)\n cache_set(ck, obj)\n end\n end \n obj\n end",
"def find_existing_record_after_reassociating(klass, obj_hash)\n obj_hash_clone = update_association_fields(klass, obj_hash.clone)\n existing_record = find_record_by_unique_index(klass, obj_hash_clone)\n if existing_record\n # Since existing_record was found, update original obj_hash\n update_association_fields(klass, obj_hash)\n existing_record\n end\n end",
"def find(id)\n @data[id]\n end",
"def find_by_id(rid)\n return nil unless rooms.keys.include?(rid)\n rooms[rid]\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if id == candidate[:id]\n return candidate\n end\n end\n\n nil\nend",
"def get_by_ued_from_memcache(user_extended_detail_id)\n memcache_key_object = self.get_by_ued_memcache_key_object\n\n Memcache.get_set_memcached(memcache_key_object.key_template % {\n user_extended_detail_id: user_extended_detail_id,\n shard_identifier: self.shard_identifier\n }, memcache_key_object.expiry) do\n self.where(user_extended_detail_id: user_extended_detail_id).first\n end\n end",
"def [](x)\n case x\n when self\n x\n when Hash\n find_by_hash(:first, x)\n when nil, Symbol\n find(:first, :conditions => [ 'code = ?', (x || '_').to_s ])\n when String\n find(:first, :conditions => [ 'uuid = ? OR code = ?', (x || '').to_s, (x || '_').to_s ])\n when Integer\n find(:first, :conditions => [ 'id = ?', x ])\n end\n end",
"def record(record_id, params = {})\n Record.new(record_id, params).get\n end",
"def record(record_id, params = {})\n Record.new(record_id, params).get\n end",
"def find(id)\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n return nil\n end\n end\nend",
"def find_existing_record(klass, obj_hash, importer: nil)\n if klass == User\n # The index for css_id has an odd column name plus find_by_css_id is faster.\n User.find_by_css_id(obj_hash[\"css_id\"])\n elsif klass == Organization\n # The url may need to be converted into a clean url\n Organization.unscoped.find_by_url(obj_hash[\"url\"])\n elsif klass == Appeal\n # uuid is not a uniq index, so can't rely on importer to do it automatically\n Appeal.find_by(uuid: obj_hash[\"uuid\"])\n elsif [Organization, Veteran, Person].include?(klass)\n # Let importer find it using the fallback: klass.unscoped.find_by(unique_field: obj_hash[unique_field])\n nil\n end\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n return nil\nend",
"def get_record(key)\n fields = get(key)[:record]\n MemoryRecord.new.init(key,fields) if fields\n end",
"def find_record_from_identifier(entity)\n model = entity.model\n user_token = request.headers[\"X-#{model.to_s.upcase}-TOKEN\"]\n super if model != User || user_token.blank?\n model.find_by authentication_token: user_token\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id]==id\n end\n nil\nend",
"def find_record(xero_id)\n raise_must_override\n end",
"def find_in_object(obj, key, singleton: true)\n assert_respond_to(obj, :fetch)\n\n default = singleton ? nil : []\n result = obj.fetch(key.to_s, default)\n singleton ? Wgit::Utils.process_str(result) : Wgit::Utils.process_arr(result)\n\n if block_given?\n new_result = yield(result, :object)\n result = new_result if new_result\n end\n\n result\n end",
"def find(id)\n\nreturn candidates.detect{|candidate| candidate[:id]==id }\n\nend",
"def find(id)\n @candidates.each do |item|\n if item[:id]==id\n @result = item\n end\n end\n @result\nend",
"def find(id)\n binding.pry\n candidate.each do |candidate|\n if @candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def primary_key_lookup(pk)\n cache[pk]\n end",
"def map_record(record)\n context = Context.new(:source_record => record, :settings => settings)\n map_to_context!(context)\n return context.output_hash\n end",
"def map_record(record)\n context = Context.new(:source_record => record, :settings => settings)\n map_to_context!(context)\n return context.output_hash\n end",
"def find(id)\n puts id\n @candidates.each do |c|\n if c[:id] == id\n puts c\n return c\n end\n end\nend",
"def find(*args)\n if args.empty? || !args.first.respond_to?(:search)\n raise NoDefaultStoreError unless StrokeDB.default_store\n \n args = args.unshift(StrokeDB.default_store) \n end\n\n unless args.size == 1 || args.size == 2\n raise ArgumentError, \"Invalid arguments for find\"\n end\n\n store = args[0]\n opt = { :meta => @metas.map {|m| m.document(store)} }\n\n case args[1]\n when String\n raise ArgumentError, \"Invalid UUID\" unless args[1].match(UUID_RE)\n\n store.search(opt.merge({ :uuid => args[1] })).first\n when Hash\n store.search opt.merge(args[1])\n when nil\n store.search opt\n else\n raise ArgumentError, \"Invalid search criteria for find\"\n end\n end"
] | [
"0.6404742",
"0.6362594",
"0.6355808",
"0.6352963",
"0.63056916",
"0.6195487",
"0.6142753",
"0.6138917",
"0.6133673",
"0.6085911",
"0.60740435",
"0.6068127",
"0.6068127",
"0.60568583",
"0.6047444",
"0.6046035",
"0.6030505",
"0.602891",
"0.5956645",
"0.59502757",
"0.5940312",
"0.59183097",
"0.5902657",
"0.5834772",
"0.58320624",
"0.5831288",
"0.58175725",
"0.58098537",
"0.5804345",
"0.579228",
"0.57413393",
"0.57413393",
"0.57248217",
"0.5712194",
"0.5700433",
"0.57000715",
"0.5691824",
"0.568789",
"0.568625",
"0.5685438",
"0.5681892",
"0.5680572",
"0.5674902",
"0.56713456",
"0.56662005",
"0.5647709",
"0.5647709",
"0.56420183",
"0.56411666",
"0.5639301",
"0.56317264",
"0.561613",
"0.561613",
"0.5614025",
"0.5599464",
"0.5597324",
"0.5593945",
"0.5593308",
"0.5590504",
"0.55797285",
"0.55755115",
"0.55755115",
"0.5569702",
"0.55612063",
"0.555746",
"0.5547794",
"0.5545035",
"0.552376",
"0.55231756",
"0.55225134",
"0.55191046",
"0.5516532",
"0.5515829",
"0.5509504",
"0.5505922",
"0.5499584",
"0.549534",
"0.5494801",
"0.54904115",
"0.5488065",
"0.548384",
"0.5476925",
"0.5464413",
"0.5464413",
"0.5463446",
"0.5461358",
"0.5455892",
"0.54491764",
"0.54491556",
"0.54452187",
"0.5444273",
"0.54438275",
"0.54389924",
"0.5433058",
"0.5429437",
"0.54231405",
"0.541784",
"0.541784",
"0.5417311",
"0.5414786"
] | 0.71577936 | 0 |
helper method for returning the last queried dataset | def last_results
$sql_multi ? $sql_results.last : $sql_results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_data\n get_current['data']\n end",
"def last\n result ? all.last : limit(1).descending.all.last\n end",
"def get_last\r\n return nil unless @head\r\n cursor = @head\r\n while cursor.next\r\n cursor = cursor.next\r\n end\r\n return cursor.data\r\n end",
"def stored_data_last\n stored_data[stored_data_last_key] || nil\n end",
"def last\n self.all.last\n end",
"def last\r\n\t\[email protected]\r\n\tend",
"def last\n @adapter.last(collection)\n end",
"def get_last\n return @tail ? @tail.data : nil\n end",
"def last\n all.last\n end",
"def get_head\n @data.last\n end",
"def get_head\n @data.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last!\n last or raise RecordNotFound\n end",
"def last\n model.last\n end",
"def get_last\r\n return unless @head\r\n \r\n last = @head\r\n last = last.next until last.next.nil?\r\n last.data\r\n end",
"def last() end",
"def last\n\t\t\t@last\n\t\tend",
"def get_last\n return nil if @head.nil?\n return get_last_helper(@head)\n end",
"def last!\n last || raise_record_not_found_exception!\n end",
"def this\n @this ||= dataset.filter(pk_hash).limit(1).naked\n end",
"def last_row\n @data.length - 1\n end",
"def last\n order(:id).reverse.limit(1)\n end",
"def last\n tail.data\n end",
"def last(*vars)\n result = Query.get params(:from => count-1, :size => 1), *vars\n docs = result.get_docs\n docs.is_a?(Array) ? docs.first : docs\n end",
"def last\n end",
"def last\n @enumerable.last\n end",
"def get_last_pglist_data\n return @last_parsed_pglist_data\n end",
"def last\n find(:first, :conditions => {}, :sort => [[:_id, :asc]])\n end",
"def last\n return sync { @last }\n end",
"def get_last\n return nil if @head.nil?\n current = @head\n until current.next.nil?\n current = current.next\n end\n return current.data\n end",
"def last; end",
"def last; end",
"def last; end",
"def select_last\n select(@data.index(@last_item.object) || 0)\n end",
"def last\r\n self[-1]\r\n end",
"def top()\n @data.last\n end",
"def get_last\n return nil if @head.nil?\n\n current = @head\n\n until current.next.nil?\n current = current.next\n end\n\n return current.data\n end",
"def last\n self[-1]\n end",
"def stored_data_last_key\n stored_data.keys.sort.last || nil\n end",
"def get_last\n # return nil unless @head\n if @head == nil\n return nil\n end\n current = @head\n while !current.next.nil?\n current = current.next\n end\n \n return current.data\n end",
"def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end",
"def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end",
"def get_last\n return if @head == nil\n\n current = @head\n\n until current.next.nil?\n current = current.next\n end\n\n return current.data\n end",
"def get_last\n raise NotImplementedError, \"Please implement get_last\"\n end",
"def get_last\n return nil unless @head\n current = @head\n\n while current.next\n current = current.next\n end\n\n return current.data\n end",
"def get_last\n return nil if @head.nil?\n return last_node.data\n end",
"def last\n @values.last\n end",
"def lastID\r\n self.conn_exec do |driver|\r\n return driver.lastID\r\n end\r\n end",
"def last\n asc(:id).last\n end",
"def last\n self.slice(self.size - 1)\n end",
"def last\n @items.last\n end",
"def last?; end",
"def get_last\n return nil if @head.nil? \n pointer = @head\n\n until pointer.next.nil?\n pointer = pointer.next\n end\n return pointer.data\n end",
"def last\n to_a.last\n end",
"def last_row\n row( maxrow )\n end",
"def last\n all[all.size - 1]\n end",
"def get_last\n return nil if !@head\n current = @head\n while current.next\n current = current.next\n end\n return current.data\n end",
"def last\n return each\n end",
"def last\n items.compact.last\n end",
"def get_last\n if length == 0\n return nil?\n elsif length == 1\n return @head.data\n else\n current = @head\n (length - 1).times do\n current = current.next\n end\n return current.data\n end\n end",
"def last\n out = nil\n\n each {|i| out = i }\n\n out\n end",
"def get_last_temp(name)\n today = @dataset[name].keys.sort.last\n #raise \"Do not have data for today #{today}\" \n return \"n/a\" if today != Date.today\n @dataset[name][today].reverse.each do |record|\n return record[:temp] if record[:count] > 0\n end\n end",
"def last\n self[-1]\n end",
"def last_date_s\r\n last_date = $db.execute(\"SELECT day FROM prices ORDER BY day_i DESC LIMIT 1\")\r\n last_date = last_date[0][0]\r\n return last_date\r\nend",
"def last(limit=1)\n limit(limit).reverse_order.load.first\n end",
"def get_last\n # return nil unless @head\n if @head == nil\n return nil\n end\n current = @head\n while current.next != nil \n current = current.next\n end\n return current.data\n end",
"def get_last\n return nil if @head.nil? \n pointer = @head \n while !pointer.next.nil?\n pointer = pointer.next\n end\n return pointer.data\n end",
"def get_last\r\n return nil if !@head\r\n\r\n prev = nil\r\n curr = @head \r\n\r\n while curr \r\n if curr.next \r\n prev = curr\r\n curr = curr.next \r\n else \r\n return curr.data\r\n end\r\n end\r\n\r\n end",
"def last\n at(-1)\n end",
"def last\n @features.last\n end",
"def get_last_entry\n @entry = FeedEntry.find(:first, :conditions => {:person_id => self.id})\n end",
"def last\n graph.first_object(subject: last_subject, predicate: RDF.first)\n end",
"def last_for_value\n self.form_field_value.queries.last\n end",
"def last **args\n query( **( { order: {\"@rid\" => 'desc'} , limit: 1 }.merge args)).execute(reduce: true)\n\tend",
"def last(options={})\r\n find(:last, options)\r\n end",
"def last\n opts = process_options\n sorting = opts[:sort]\n sorting = [[:_id, :asc]] unless sorting\n opts[:sort] = sorting.collect { |option| [ option[0], option[1].invert ] }\n attributes = klass.collection.find_one(selector, opts)\n attributes ? Mongoid::Factory.from_db(klass, attributes) : nil\n end",
"def last\n @locations.last\n end",
"def current\n all.last\n end",
"def last\n self.invert_order.all.first\n end",
"def last\n last_mgmt_query ||= MgmtQuery.find_by_device_id( device_id.to_i, :conditions => [\"id < ?\", id], :order => \"timestamp_server DESC\", :limit => 2) unless device_id.blank? || device_id.to_i.zero?\n end",
"def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end",
"def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end",
"def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end",
"def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end",
"def using_last(array)\n array.last\nend",
"def using_last(array)\n array.last\nend",
"def last_day_i\r\n last_date = $db.execute(\"SELECT day_i FROM prices ORDER BY day_i DESC LIMIT 1\")\r\n last_date = last_date[0][0]\r\n return last_date\r\nend",
"def last(&block)\n use_device(all.last, &block)\n end",
"def last(options={})\n get(\"last\", options)\n end",
"def last\n \tbegin\n \t raise ArgumentError, \"Empty LinkedList\" if @size <= 0\n \t return @last.prev.data\n \t rescue\n \t puts \"Empty\" \t\t \n\t\t end\n \tend",
"def using_last(array)\narray.last\nend",
"def last(num = nil)\n return @all.last num if num\n @all.last\n end",
"def get_last\r\n # return nil if the linked list is empty\r\n if @head.nil?\r\n return nil\r\n end\r\n \r\n # otherwise, go to end of list ...\r\n current = @head\r\n until current.next.nil?\r\n # ... until 'current' is the last node ...\r\n current = current.next\r\n end\r\n \r\n # ... and return data from last node\r\n return current.data\r\n \r\n end",
"def get_last\n return @head if @head.nil?\n current_node = @head\n\n until current_node.next.nil?\n current_node = current_node.next\n end\n return current_node.data\n end"
] | [
"0.7100028",
"0.70508283",
"0.7015582",
"0.69888574",
"0.6978995",
"0.6947397",
"0.69471025",
"0.68313754",
"0.67654467",
"0.6763334",
"0.6763334",
"0.6760208",
"0.6760208",
"0.6760208",
"0.6760208",
"0.67437077",
"0.67138016",
"0.67138016",
"0.66860956",
"0.6643272",
"0.66410756",
"0.6629988",
"0.66241276",
"0.6602149",
"0.6591066",
"0.65490407",
"0.65249395",
"0.6520473",
"0.65018207",
"0.64855623",
"0.64584345",
"0.6424427",
"0.640541",
"0.64046156",
"0.64011663",
"0.6396874",
"0.63939524",
"0.63939524",
"0.63939524",
"0.638807",
"0.63725185",
"0.6366472",
"0.6360647",
"0.63581705",
"0.63551795",
"0.6329338",
"0.6326896",
"0.6326896",
"0.6326376",
"0.63261783",
"0.6318317",
"0.6305632",
"0.63018405",
"0.62771803",
"0.6271946",
"0.6265495",
"0.6253778",
"0.6251991",
"0.62418807",
"0.6239313",
"0.6235645",
"0.622851",
"0.6218104",
"0.6216904",
"0.6211502",
"0.6209208",
"0.6203863",
"0.61997885",
"0.619756",
"0.6194997",
"0.6186795",
"0.61837035",
"0.61771905",
"0.6169874",
"0.6163092",
"0.61522764",
"0.6144695",
"0.61417323",
"0.61331064",
"0.61321354",
"0.61272746",
"0.6121755",
"0.6112546",
"0.6105703",
"0.60977757",
"0.6093263",
"0.60795563",
"0.60795563",
"0.60795563",
"0.60795563",
"0.60630804",
"0.60630804",
"0.60584104",
"0.6056803",
"0.60437095",
"0.6035956",
"0.60358316",
"0.6033338",
"0.6009744",
"0.6007754"
] | 0.70065767 | 3 |
loops through each sql result and returns the row as a Hashie::Mash. If multiple results were returned, the last result set will be used | def each_result(results = last_results, &block)
results.each do |result|
block.call(Hashie::Mash.new(result))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_rows(sql)\n execute(sql) do |r|\n i = -1\n cps = db.conversion_procs\n cols = r.fetch_fields.map do |f| \n # Pretend tinyint is another integer type if its length is not 1, to\n # avoid casting to boolean if convert_tinyint_to_bool is set.\n type_proc = f.type == 1 && cast_tinyint_integer?(f) ? cps[2] : cps[f.type]\n [output_identifier(f.name), type_proc, i+=1]\n end\n self.columns = cols.map(&:first)\n if opts[:split_multiple_result_sets]\n s = []\n yield_rows(r, cols){|h| s << h}\n yield s\n else\n yield_rows(r, cols){|h| yield h}\n end\n end\n self\n end",
"def fetch_rows(sql)\n execute(sql) do |stmt|\n columns = []\n convert = convert_smallint_to_bool\n cps = db.conversion_procs\n stmt.num_fields.times do |i|\n k = stmt.field_name i\n key = output_identifier(k)\n type = stmt.field_type(i).downcase.to_sym\n # decide if it is a smallint from precision\n type = :boolean if type == :int && convert && stmt.field_precision(i) < 8\n type = :blob if type == :clob && db.use_clob_as_blob\n columns << [key, cps[type]]\n end\n cols = columns.map{|c| c[0]}\n self.columns = cols\n\n while res = stmt.fetch_array\n row = {}\n res.zip(columns).each do |v, (k, pr)|\n row[k] = ((pr ? pr.call(v) : v) if v)\n end\n yield row\n end\n end\n self\n end",
"def fetch_rows(sql)\n execute(sql) do |stmt|\n self.columns = cols = stmt.result_fields.map{|c| output_identifier(c)}\n col_count = cols.size\n stmt.each do |result|\n row = {}\n col_count.times{|i| row[cols[i]] = result[i]}\n yield row\n end\n end\n end",
"def fetch_rows(sql)\n execute(sql) do |res|\n columns = set_columns(res)\n yield_hash_rows(res, columns) {|h| yield h}\n end\n end",
"def resultset; end",
"def fetch_rows(sql)\n return cursor_fetch_rows(sql){|h| yield h} if @opts[:cursor]\n execute(sql){|res| yield_hash_rows(res, fetch_rows_set_cols(res)){|h| yield h}}\n end",
"def rows\n @rows ||= if ActiveRecord::Base.connection.adapter_name == \"PostgreSQL\"\n result.entries\n else\n [].tap do |row_hashes|\n result.entries.map do |row|\n hash = {}\n result.fields.each do |field|\n hash[field] = row[result.fields.index(field)]\n end\n row_hashes << hash\n end\n end\n end\n end",
"def run(result)\r\n\t\t\r\n\t\tcolumn_names = Array.new #store the column names\r\n\t\tfields = result.fetch_fields #get all the fields\r\n\t\tfields.each do |field|\r\n\t\t\tcolumn_names << field.name #push a field into the coumn_names\r\n\t\tend\r\n\t\t\r\n\t\trow_count = result.num_rows #get the number of rows in the Mysql::Result\r\n\t\tinitial_data = Array.new #payload holder\r\n\t\t\r\n\t\tresult.data_seek(0) #Seek the cursor to the beginning of the data\r\n\t\twhile row = result.fetch_row\r\n\t\t\tinitial_data << row # add a row to the payload\r\n\t\tend\r\n\t\t\t\t\r\n\t\tasrecordset = ASRecordset.new(row_count,column_names,initial_data)\r\n\t\tresult = asrecordset\r\n\t\treturn result\r\n\tend",
"def exec_raw(sql, options = {})\n cursor = $connection.exec(sql)\n if(options[:return_hash])\n recordset, = pack_cursor(cursor, :return => \"hash\")\n return recordset\n else\n return_data = []\n while current_row = cursor.fetch()\n return_data.push(current_row)\n end\n return return_data\n end\n end",
"def fetch_rows(sql, &block)\n execute(sql) do |r|\n r.each(:symbolize_keys => true, &block)\n end\n self\n end",
"def run(results)\n columns_names = rows.first.inject([]) {|m, kv| m << kv[0]; m}\n row_count = rows.size\n initial_data = results.all.map {|r| columns.map {|c| r[c]}}\n asrecordset = ASRecordset.new(row_count,column_names,initial_data)\n \tresult = asrecordset\n \treturn result\n end",
"def run(result)\t\t\n\t\tcolumn_names = result.fields #store the column names\n\t\trow_count = result.num_tuples #get the number of rows in the result\n\t\tinitial_data = Array.new #payload holder\n result.each do |item|\n intial_data << item.to_ary\n end\t\t\n\t\tasrecordset = ASRecordset.new(row_count,column_names,initial_data)\n\t\tresult = asrecordset\n\t\tresults\n\tend",
"def oracle_sql_results(sql, conn = VACOLS::Case.connection)\n result = conn.execute(sql)\n output = []\n while r = result.fetch_hash\n output << r\n end\n output\nend",
"def fetch_row(sql)\n # Run the query\n results = query(sql)\n\n # Check result counts\n if results.count == 0\n check.critical(\"Expected to receive a single row, but result set is empty\", \"SQL: #{sql}\")\n end\n if results.count > 1\n check.critical(\"Expected to receive a single row, but result has #{results.count} lines\", \"SQL: #{sql}\")\n end\n\n # Get the first and only row\n return results.first\n end",
"def result\n ActiveRecord::Base.connection.select_all(sql).entries\n end",
"def resultset_to_hash(resultset)\n meta = resultset.meta_data\n rows = []\n\n while resultset.next\n row = {}\n\n (1..meta.column_count).each do |i|\n name = meta.column_name i\n row[name] = case meta.column_type(i)\n when -6, -5, 5, 4\n # TINYINT, BIGINT, INTEGER\n resultset.get_int(i).to_i\n when 41\n # Date\n resultset.get_date(i)\n when 92\n # Time\n resultset.get_time(i).to_i\n when 93\n # Timestamp\n resultset.get_timestamp(i)\n when 2, 3, 6\n # NUMERIC, DECIMAL, FLOAT\n case meta.scale(i)\n when 0\n resultset.get_long(i).to_i\n else\n BigDecimal.new(resultset.get_string(i).to_s)\n end\n when 1, -15, -9, 12\n # CHAR, NCHAR, NVARCHAR, VARCHAR\n resultset.get_string(i).to_s\n else\n resultset.get_string(i).to_s\n end\n end\n\n rows << row\n end\n rows\nend",
"def fetch_rows(sql, opts=OPTS, &block)\n db.execute(sql){|result| process_result_set(result, opts, &block)}\n self\n end",
"def each_row(the_query, &block)\n begin\n query(the_query, { as: :array, cache_rows: false })\n unless @result.nil?\n if block_given?\n @affected_rows = @result.count # This is non-zero is we do a select, and get results.\n @result.each(&block)\n else\n result = []\n @result.each { |row| result << row }\n return result\n end\n end\n rescue Mysql2::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end",
"def each_row(the_query, &block)\n begin\n query(the_query)\n unless @result.nil?\n @affected_rows = @result.num_rows # This is non-zero is we do a select, and get results.\n if block_given?\n @result.each(&block)\n else\n result = []\n @result.each { |row| result << row }\n return result\n end\n end\n rescue Mysql::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end",
"def each\n @pool.with do |conn|\n conn.send_query @sql\n conn.set_single_row_mode\n loop do\n res = conn.get_result\n break unless res\n res.check\n res.stream_each { |row| yield row }\n end\n end\n end",
"def fetch\n row = @result.fetch\n return row unless @bind_result\n row.zip(@bind_result).map do |col, type|\n if col.nil?\n nil\n elsif [Numeric, Integer, Fixnum].include? type\n col.to_i\n elsif type == String\n col.to_s\n elsif type == Float && !col.is_a?(Float)\n col.to_i.to_f\n elsif type == Mysql::Time && !col.is_a?(Mysql::Time)\n if col.to_s =~ /\\A\\d+\\z/\n i = col.to_s.to_i\n if i < 100000000\n y = i/10000\n m = i/100%100\n d = i%100\n h, mm, s = 0\n else\n y = i/10000000000\n m = i/100000000%100\n d = i/1000000%100\n h = i/10000%100\n mm= i/100%100\n s = i%100\n end\n if y < 70\n y += 2000\n elsif y < 100\n y += 1900\n end\n Mysql::Time.new(y, m, d, h, mm, s)\n else\n Mysql::Time.new\n end\n else\n col\n end\n end\n end",
"def select_one(sql)\n result = execute(sql)\n result.fetch_hash\n end",
"def synchronize_resultset; end",
"def each\n return unless @result\n\n @result.each(as: :hash, symbolize_keys: true) do |row|\n next unless row # This sometimes happens when streaming results...\n row = Hash[row.map { |k, v| [k, v.to_s] }] if @type_translation == :string\n yield row\n end\n end",
"def process_result_set(result, opts=OPTS)\n meta = result.getMetaData\n if fetch_size = opts[:fetch_size]\n result.setFetchSize(fetch_size)\n end\n\n converters = []\n self.columns = meta.getColumnCount.times.map do |i|\n col = i + 1\n converters << TypeConverter::MAP[meta.getColumnType(col)]\n meta.getColumnLabel(col)\n end\n\n fetch_as_array = opts[:as] == :array\n while result.next\n row = fetch_as_array ? [] : {}\n _columns.each_with_index do |column, i|\n k = fetch_as_array ? i : column\n col = i+1\n row[k] = converters[i].call(result, col, opts)\n end\n yield row\n end\n ensure\n result.close\n end",
"def next_row\n row = []\n case rc = @stmt_api.step\n when ResultCode::ROW\n result_meta.each_with_index do |col, idx|\n value = nil\n column_type = @stmt_api.column_type( idx )\n case column_type\n when DataType::TEXT\n value = @stmt_api.column_text( idx )\n when DataType::FLOAT\n value = @stmt_api.column_double( idx )\n when DataType::INTEGER\n value = @stmt_api.column_int64( idx )\n when DataType::NULL\n value = nil\n when DataType::BLOB\n # if the rowid column is encountered, then we can use an incremental\n # blob api, otherwise we have to use the all at once version.\n if using_rowid_column? then\n value = Amalgalite::Blob.new( :db_blob => SQLite3::Blob.new( db.api,\n col.schema.db,\n col.schema.table,\n col.schema.name,\n @stmt_api.column_int64( @rowid_index ),\n \"r\"),\n :column => col.schema)\n else\n value = Amalgalite::Blob.new( :string => @stmt_api.column_blob( idx ), :column => col.schema )\n end\n else\n raise ::Amalgalite::Error, \"BUG! : Unknown SQLite column type of #{column_type}\"\n end\n\n row << db.type_map.result_value_of( col.schema.declared_data_type, value )\n end\n row.fields = result_fields\n when ResultCode::DONE\n row = nil\n write_blobs\n else\n self.close # must close so that the error message is guaranteed to be pushed into the database handler\n # and we can can call last_error_message on it\n msg = \"SQLITE ERROR #{rc} (#{Amalgalite::SQLite3::Constants::ResultCode.name_from_value( rc )}) : #{@db.api.last_error_message}\"\n raise Amalgalite::SQLite3::Error, msg\n end\n return row\n end",
"def fetch\n row = @results[@index += 1]\n return unless row\n\n if @types\n row.map!.with_index { |value, index| translate_type(value, @types[index]) } if @types\n elsif @type_translation == :string\n row.map!(&:to_s)\n end\n\n Hash[*@columns.zip(row).flatten]\n end",
"def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n # TODO put these lines back in and create another method to turn results_as_objects array of \n # objects in to array of hashes!!!!!!!\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end",
"def hash_query(sql, name = nil, binds = [])\n \n return if sql.nil?\n #sql = modify_limit_offset(sql)\n\n # ActiveRecord allows a query to return TOP 0. SQL Anywhere requires that the TOP value is a positive integer.\n return Array.new() if sql =~ /TOP 0/i\n\n stmt = SA.instance.api.sqlany_prepare(@connection, sql)\n \n # sql may contain unbounded params\n \n i = 0\n binds.map do |col, val|\n result, param = SA.instance.api.sqlany_describe_bind_param(stmt, i)\n param.set_value(type_cast(val, col)) if result\n result = SA.instance.api.sqlany_bind_param(stmt, i, param) if param\n i = i + 1\n end\n \n # Executes the query, iterates through the results, and builds an array of hashes.\n # rs = SA.instance.api.sqlany_execute_direct(@connection, sql)\n return [] if stmt.nil?\n result = SA.instance.api.sqlany_execute(stmt)\n if result.nil?\n result, errstr = SA.instance.api.sqlany_error(@connection)\n raise SQLAnywhereException.new(errstr, result, sql)\n end\n \n record = []\n if( SA.instance.api.sqlany_num_cols(stmt) > 0 ) \n while SA.instance.api.sqlany_fetch_next(stmt) == 1\n max_cols = SA.instance.api.sqlany_num_cols(stmt)\n result = Hash.new()\n max_cols.times do |cols|\n result[SA.instance.api.sqlany_get_column_info(stmt, cols)[2]] = SA.instance.api.sqlany_get_column(stmt, cols)[1]\n end\n record << result\n end\n @affected_rows = 0\n else\n @affected_rows = SA.instance.api.sqlany_affected_rows(stmt)\n end \n SA.instance.api.sqlany_free_stmt(stmt)\n\n SA.instance.api.sqlany_commit(@connection)\n \n return record\n end",
"def get_data sql\n #$log.debug \"SQL: #{sql} \"\n columns, *rows = @db.execute2(sql)\n #$log.debug \"XXX COLUMNS #{sql}, #{rows.count} \"\n content = rows\n return content\n end",
"def resultset\n @resultset ||= parse_resultset(stored_data)\n end",
"def each_row(q, options = {}, &block)\n current_row = 0\n # repeatedly fetch results, starting from current_row\n # invoke the block on each one, then grab next page if there is one\n # it'll terminate when res has no 'rows' key or when we've done enough rows\n # perform query...\n res = query(q, options)\n job_id = res['jobReference']['jobId']\n # call the block on the first page of results\n if( res && res['rows'] )\n res['rows'].each(&block)\n current_row += res['rows'].size\n end\n # keep grabbing pages from the API and calling the block on each row\n while( current_row < res['totalRows'].to_i && ( res = get_query_results(job_id, :startIndex => current_row) ) && res['rows'] ) do\n res['rows'].each(&block)\n current_row += res['rows'].size\n end\n end",
"def each_hash(the_query, with_table_names = false, &block)\n begin\n query(the_query)\n unless @result.nil?\n @affected_rows = @result.num_rows # This is non-zero is we do a select, and get results.\n if block_given?\n @result.each_hash(with_table_names, &block)\n else\n result = []\n @result.each_hash(with_table_names) { |row| result << row }\n return result\n end\n end\n rescue Mysql::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end",
"def sql_select_first_row(sql)\n result = sql_select_all(sql)\n return nil if result.empty?\n result[0].extend SelectHashHelper # Erweitern Hash um Methodenzugriff auf Elemente\n end",
"def rows rows_results = nil\n res = rows_results || results\n\n if res.blank?\n body_content << \"<td>#{FOUND_NO_DATABASE_ISSUES}</td>\" << \"\\n\"\n return\n end\n\n res.each do |object|\n row object, *yield(object)\n end\n end",
"def reformat_query_results(results)\n return embed_table_in_results results\n end",
"def select_rows(sql, name = nil)\r\n rs = ADS.instance.api.ads_execute_direct(@connection, sql)\r\n raise ActiveRecord::StatementInvalid.new(\"#{ADS.instance.api.ads_error(@connection)}:#{sql}\") if rs.nil?\r\n record = []\r\n while ADS.instance.api.ads_fetch_next(rs) == 1\r\n max_cols = ADS.instance.api.ads_num_cols(rs)\r\n result = Array.new(max_cols)\r\n max_cols.times do |cols|\r\n result[cols] = ADS.instance.api.ads_get_column(rs, cols)[1]\r\n end\r\n record << result\r\n end\r\n ADS.instance.api.ads_free_stmt(rs)\r\n return record\r\n end",
"def results_with_rows\n load_from_rows(@dataset.all, true)\n end",
"def fetch_rows(sql, &block)\n raise NotImplementedError, NOTIMPL_MSG\n end",
"def next\n return nil if @eof\n\n @stmt.must_be_open!\n\n unless @first_row\n result = @driver.step( @stmt.handle )\n check result\n end\n\n @first_row = false\n\n unless @eof\n row = []\n @driver.data_count( @stmt.handle ).times do |column|\n case @driver.column_type( @stmt.handle, column )\n when Constants::ColumnType::NULL then\n row << nil\n when Constants::ColumnType::BLOB then\n row << @driver.column_blob( @stmt.handle, column )\n else\n row << @driver.column_text( @stmt.handle, column )\n end\n end\n\n if @db.type_translation\n row = @stmt.types.zip( row ).map do |type, value|\n @db.translator.translate( type, value )\n end\n end\n\n if @db.results_as_hash\n new_row = Hash[ *( @stmt.columns.zip( row ).flatten ) ]\n row.each_with_index { |value,idx| new_row[idx] = value }\n row = new_row\n else\n row.extend FieldsContainer unless row.respond_to?(:fields)\n row.fields = @stmt.columns\n end\n\n row.extend TypesContainer\n row.types = @stmt.types\n\n return row\n end\n\n nil\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n results_as_objects(results)\n \n end",
"def exercise2\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n gr.name as group_name,\n u.name as user_name,\n sum(m.mapviews) as groups_count\n FROM (((users as u\n INNER JOIN groups_users as gu ON u.id=gu.user_id)\n INNER JOIN groups as gr ON gr.id = gu.group_id)\n INNER JOIN maps as m ON m.user_id = u.id)\n GROUP BY (gr.name, u.name)\n ORDER BY gr.name, groups_count DESC;\");\n\n @results2 = []\n\n index = 0\n @content.each do |r|\n @results2[index] = Result2.new r\n index = index + 1;\n end\n\n return @results2\n end",
"def all_as_objects\n table_name = self.to_s.pluralize\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n \n results_as_objects << self.new(result_hash)\n \n end\n \n return results_as_objects\n \n end",
"def results(id)\n @pgsql.exec('SELECT key, value FROM result WHERE job = $1', [id]).map do |r|\n [r['key'], r['value']]\n end.to_h\n end",
"def yield_hash_rows(res, cols)\n res.ntuples.times do |recnum|\n converted_rec = {}\n cols.each do |fieldnum, type_proc, fieldsym|\n value = res.getvalue(recnum, fieldnum)\n converted_rec[fieldsym] = (value && type_proc) ? type_proc.call(value) : value\n end\n yield converted_rec\n end\n end",
"def yield_hash_rows(res, cols)\n res.ntuples.times do |recnum|\n converted_rec = {}\n cols.each do |fieldnum, type_proc, fieldsym|\n value = res.getvalue(recnum, fieldnum)\n converted_rec[fieldsym] = (value && type_proc) ? type_proc.call(value) : value\n end\n yield converted_rec\n end\n end",
"def sql_select_one(sql)\n result = sql_select_first_row(sql)\n return nil unless result\n result.first[1] # Value des Key/Value-Tupels des ersten Elememtes im Hash\n end",
"def each\n # Need to close the connection, teh result_set, AND the result_set.getStatement when\n # we're done.\n connection = open_connection!\n\n # We're going to need to ask for item/copy info while in the\n # middle of streaming our results. JDBC is happier and more performant\n # if we use a seperate connection for this.\n extra_connection = open_connection! if include_some_holdings?\n\n # We're going to make our marc records in batches, and only yield\n # them to caller in batches, so we can fetch copy/item info in batches\n # for efficiency.\n batch_size = settings[\"horizon.batch_size\"].to_i\n record_batch = []\n\n exclude_tags = (settings[\"horizon.exclude_tags\"] || \"\").split(\",\")\n\n\n rs = self.fetch_result_set!(connection)\n\n current_bib_id = nil\n record = nil\n record_count = 0\n\n error_handler = org.marc4j.ErrorHandler.new\n\n while(rs.next)\n bib_id = rs.getInt(\"bib#\");\n\n if bib_id != current_bib_id\n record_count += 1\n\n if settings[\"debug_ascii_progress\"] && (record_count % settings[\"solrj_writer.batch_size\"] == 0)\n $stderr.write \",\"\n end\n\n # new record! Put old one on batch queue.\n record_batch << record if record\n\n # prepare and yield batch?\n if (record_count % batch_size == 0)\n enhance_batch!(extra_connection, record_batch)\n record_batch.each do |r|\n # set current_bib_id for error logging\n current_bib_id = r['001'].value\n yield r\n end\n record_batch.clear\n end\n\n # And start new record we've encountered.\n error_handler = org.marc4j.ErrorHandler.new\n current_bib_id = bib_id\n record = MARC::Record.new\n record.append MARC::ControlField.new(\"001\", bib_id.to_s)\n end\n\n tagord = rs.getInt(\"tagord\");\n tag = rs.getString(\"tag\")\n\n # just silently skip it, some weird row in the horizon db, it happens.\n # plus any of our exclude_tags.\n next if tag.nil? || tag == \"\" || exclude_tags.include?(tag)\n\n indicators = rs.getString(\"indicators\")\n\n # a packed byte array could be in various columns, in order of preference...\n # the xref stuff is joined in from the auth table\n # Have to get it as bytes and then convert it to String to avoid JDBC messing\n # up the encoding marc8 grr\n authtext = rs.getBytes(\"xref_longtext\") || rs.getBytes(\"xref_text\")\n text = rs.getBytes(\"longtext\") || rs.getBytes(\"text\")\n\n\n if tag == \"000\"\n # Horizon puts a \\x1E marc field terminator on the end of hte\n # leader in the db too, but that's not really part of it.\n record.leader = String.from_java_bytes(text).chomp(\"\\x1E\")\n\n fix_leader!(record.leader)\n elsif tag != \"001\"\n # we add an 001 ourselves with bib id in another part of code.\n field = build_marc_field!(error_handler, tag, indicators, text, authtext)\n record.append field unless field.nil?\n end\n end\n\n # last one\n record_batch << record if record\n\n # yield last batch\n enhance_batch!(extra_connection, record_batch)\n\n record_batch.each do |r|\n yield r\n end\n record_batch.clear\n\n rescue Exception => e\n logger.fatal \"HorizonReader, unexpected exception at bib id:#{current_bib_id}: #{e}\" \n raise e\n ensure\n logger.info(\"HorizonReader: Closing all JDBC objects...\")\n\n # have to cancel the statement to keep us from waiting on entire\n # result set when exception is raised in the middle of stream.\n statement = rs && rs.getStatement\n if statement\n statement.cancel\n statement.close\n end\n\n rs.close if rs\n\n # shouldn't actually need to close the resultset and statement if we cancel, I think.\n connection.close if connection\n\n extra_connection.close if extra_connection\n\n logger.info(\"HorizonReader: Closed JDBC objects\")\n end",
"def get_all_entries()\n jso = Hash.new()\n \n # Connect to database\n dbe = MIDB::API::Dbengine.new(@engine.config, @db)\n dblink = dbe.connect()\n rows = dbe.query(dblink, \"SELECT * FROM #{self.get_structure.values[0].split('/')[0]};\")\n if rows == false\n return MIDB::Interface::Server.json_error(400, \"Bad Request\")\n end\n # Iterate over all rows of this table\n rows.each do |row|\n jso[row[\"id\"]] = self.get_structure\n self.get_structure.each do |name, dbi|\n table = dbi.split(\"/\")[0]\n field = dbi.split(\"/\")[1]\n # Must-match relations (\"table2/field/table2-field->row-field\")\n if dbi.split(\"/\").length > 2\n match = dbi.split(\"/\")[2]\n matching_field = match.split(\"->\")[0]\n row_field = match.split(\"->\")[1]\n query = dbe.query(dblink, \"SELECT #{field} FROM #{table} WHERE #{matching_field}=#{row[row_field]};\")\n else\n query = dbe.query(dblink, \"SELECT #{field} from #{table} WHERE id=#{row['id']};\")\n end\n if query == false\n return MIDB::Interface::Server.json_error(400, \"Bad Request\")\n end\n jso[row[\"id\"]][name] = dbe.length(query) > 0 ? dbe.extract(query,field) : \"unknown\"\n jso[row[\"id\"]][name] = @hooks.format_field(name, jso[row[\"id\"]][name])\n end\n end\n @hooks.after_get_all_entries(dbe.length(rows))\n return jso\n end",
"def each_hash(the_query, with_table_names = false, &block)\n begin\n if with_table_names\n # We have to build the hash ourselves, if we want table names included\n query(the_query, { as: :array, cache_rows: false })\n if @result != nil\n fields = @result.fields\n tables = @result.respond_to?(:tables) ? @result.tables : [] # My addition to mysql2 results.c\n\n result = []\n @result.each do |row|\n hrow = {}\n (0...row.length).each do |i|\n field_name = tables[i].nil? ? fields[i] : \"#{tables[i]}.#{fields[i]}\"\n hrow[field_name] = row[i]\n end\n yield hrow\n result << hrow\n end\n return result\n end\n else\n query(the_query, { as: :hash, cache_rows: false })\n if @result != nil\n if block_given?\n @result.each(&block)\n else\n return @result.to_a\n end\n end\n end\n rescue Mysql2::Error => e\n # puts \"#{e.errno}: #{e.error}\"\n raise e\n ensure\n if block_given? && @result != nil\n @result.free\n end\n end\n end",
"def execute_all( sql ) # :yields: row\n loop do\n stmt = prepare( sql )\n stmt.execute do |result|\n result.each { |row| yield row if block_given? }\n end\n sql = stmt.remainder\n if sql.length > 0\n yield nil if block_given? # notify of new query starting\n else\n break\n end\n end\n end",
"def last_results\n $sql_multi ? $sql_results.last : $sql_results\nend",
"def unpack\n if self.values().length == 1\n row = self.values()[0]\n if row.length == 1\n return row[0]\n else\n warn 'more than 1 column in result.'\n return row\n end\n else\n warn 'more than 1 row returned.'\n return self.values()\n end\n end",
"def query sql\n result = db[sql].all\n return result\n end",
"def all \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_name}\")\n \n return self.results_as_objects(results)\n end",
"def query(query)\n raw_query(query).map do |row|\n row = row.map do |item| \n # If the row entry is a String, it is the result already, and not, as \n # Neo4j.build would expect, the URL of a Neo4j node or relationship. The\n # same is true for all non-hashes.\n next item unless item.is_a?(Hash)\n build_from_hash(item)\n end\n \n row = row.first if row.length == 1\n row\n end\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{get_table_name}\")\n\n results_as_objects = []\n\n results.each do |results_hash|\n results_as_objects << self.new(results_hash)\n end\n\n return results_as_objects\n end",
"def build_result(columns:, rows:, column_types: {})\n ActiveRecord::Result.new(columns, rows, column_types)\n end",
"def result_set\n klass.requestor.get(nil, { query: to_s })\n end",
"def execute\n results = ResultSet.new( @db, @statement.to_s )\n\n if block_given?\n begin\n yield results\n ensure\n results.close\n end\n else\n return results\n end\n end",
"def make_result_set\n results = []\n\n results.push(@leaders.clone.map!{|a| ''} +\n ['Category', 'Mean Time(ms)', 'Median Time', 'Min Time',\n 'Max Time', 'Range','First Run']\n ) if @addHeading\n @addHeading = false\n\n fieldSet = all_fields()\n fieldVals = values_for_fields(fieldSet)\n\n for f in fieldSet\n fv = fieldVals[f]\n first = fv.shift\n\n row = @leaders.clone\n row += [f, fv.mean, fv.median, fv.min, fv.max, fv.max - fv.min, first]\n\n results.push row\n end\n\n return results\n end",
"def get_first_row( sql, *bind_vars )\n execute( sql, *bind_vars ) { |row| return row }\n nil\n end",
"def rs_to_hash(rs, index_key_field, multi_val)\n # setting default hash value is necessary for appending to arrays\n hash=Hash.new{ |h, k| h[k] = [] }\n\n # get basic metadata for the recordset\n meta = rs.getMetaData\n cols = meta.getColumnCount.to_i\n\n # loop through the records to add them into hash\n while rs.next do\n # if multi_val is not true... create new hash value as an empty hash if it doesn't already exist\n hash[rs.getString(index_key_field)]={} if (!hash[rs.getString(index_key_field)] and !multi_val)\n\n # if multi_val is true... create new hash value as an empty array if it doesn't already exist\n hash[rs.getString(index_key_field)]=[] if (!hash[rs.getString(index_key_field)] and multi_val)\n\n # r is a temporary hash for the row being processed\n r=Hash.new\n\n # add each row to r\n (1..cols).each do |c|\n r[meta.get_column_name(c)] = rs.getObject(c)\n if convert_to_ruby_time_classes.include?(r[meta.get_column_name(c)].class)\n r[meta.get_column_name(c)] = Time.at(r[meta.get_column_name(c)].get_time / 1000).utc\n end\n end # each cols\n\n # set hash value to r if not multi_val\n hash[rs.getString(index_key_field)] = r if !multi_val\n\n # append hash to r if multi_val\n hash[rs.getString(index_key_field)] << r if multi_val\n end # while\n\n # completed hash is returned\n return hash\n end",
"def result_set\n\t @result_set ||= plan.query_result_set(self)\n\tend",
"def cursor_fetch_rows(sql)\n server_opts = {:server=>@opts[:server] || :read_only}\n cursor = @opts[:cursor]\n hold = cursor[:hold]\n cursor_name = quote_identifier(cursor[:cursor_name] || 'sequel_cursor')\n rows_per_fetch = cursor[:rows_per_fetch].to_i\n\n db.send(*(hold ? [:synchronize, server_opts[:server]] : [:transaction, server_opts])) do \n begin\n execute_ddl(\"DECLARE #{cursor_name} NO SCROLL CURSOR WITH#{'OUT' unless hold} HOLD FOR #{sql}\", server_opts)\n rows_per_fetch = 1000 if rows_per_fetch <= 0\n fetch_sql = \"FETCH FORWARD #{rows_per_fetch} FROM #{cursor_name}\"\n cols = nil\n # Load columns only in the first fetch, so subsequent fetches are faster\n execute(fetch_sql) do |res|\n cols = fetch_rows_set_cols(res)\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n loop do\n execute(fetch_sql) do |res|\n yield_hash_rows(res, cols){|h| yield h}\n return if res.ntuples < rows_per_fetch\n end\n end\n rescue Exception => e\n raise\n ensure\n begin\n execute_ddl(\"CLOSE #{cursor_name}\", server_opts)\n rescue\n raise e if e\n raise\n end\n end\n end\n end",
"def normalize_result(ar_res)\n res = []\n ar_res.each do |r|\n c = []\n columns.each do |col| \n if r.attributes[col[:id]] then\n c << r.send(col[:id].intern)\n else\n c << ''\n end\n end\n res << c\n end\n res\n end",
"def get_sighting_records(db)\r\n\r\n sighting_records = db.query(\"select * from sighting_details order by id\")\r\n\r\n return sighting_records.to_a\r\n\r\nend",
"def pack_cursor(cursor, options = {})\n \n recordset = []\n column_names = []\n var_cursor = cursor.get_col_names\n \n while current_row = cursor.fetch() \n case options[:return]\n when 'hash'\n current_record = {}\n current_row.each_index{ |index| \n current_record[var_cursor[index]] = current_row[index] \n column_names[index] = var_cursor[index].split('_').join(' ')\n }\n when 'array'\n current_record = []\n current_row.each_index{ |index| \n current_record[index] = current_row[index] \n column_names[index] = var_cursor[index].split('_').join(' ')\n } \n end\n \n recordset.push(current_record)\n end\n \n return recordset, column_names\n end",
"def next_hash\n result = @stmt.step\n return nil if result.nil?\n unless result.kind_of?(Hash)\n result_ary = result\n result = {}\n result_ary.each_with_index do |el, i|\n result[@stmt.column_name(i)] = el\n end\n end\n result\n end",
"def _select_map_single\n rows = []\n clone(:_sequel_pg_type=>:first).fetch_rows(sql){|s| rows << s}\n rows\n end",
"def map_to_hash_by_primary_key(result) \n hash = {}\n\n result.each do |record|\n hash[record[@primary_key]] = record\n end\n\n hash\n end",
"def query_thredis(prepare_only)\n if prepare_only\n @rows = @connection.redis.sqlprepare(@sql)\n else\n @rows = @connection.redis.sql(@sql, *@params)\n @prepare_only = false\n end\n if @rows.is_a? Integer\n @rows, @columns, @connection.changes = [], [], @rows\n else\n @columns = @rows.shift\n## @rows = convert_type(@rows, @columns)\n end\n end",
"def select(sql, name = nil)\n fields, rows = select_raw(sql, name)\n result = []\n for row in rows\n row_hash = {}\n fields.each_with_index do |f, i|\n val = row[i]\n row_hash[f.to_s] = val.respond_to?(:rstrip) ? val.rstrip : val\n end\n result << row_hash\n end\n result\n end",
"def all\n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n\n results_as_objects(results)\n\n end",
"def execute\n result = nil\n ActiveRecord::Base.connection_pool.with_connection do |con|\n result = con.execute(to_sql)\n end\n if @sql_returning.nil?\n nil\n else\n if @returning_flat\n result.values.map{|r| r.first}\n else\n result\n end\n end\n end",
"def select_rows(sql, name = nil)\n select_raw(sql, name).last\n end",
"def select_rows(sql, name = nil)\n select_raw(sql, name).last\n end",
"def each(&block)\n\t plan.query_each(result_set, &block)\n\t self\n\tend",
"def drillthrough(query)\n RowSet.new @connection.create_statement.execute_query(query.to_s)\n end",
"def all(sql, *args, into: nil, &block)\n raise ArgumentError, \"all no longer support blocks, use each instead.\" if block\n\n rows, pg_source_oid, column_info = each_without_conversion(sql, *args, into: into)\n\n result = convert_rows_to_result rows, into: into, pg_source_oid: pg_source_oid\n\n # [TODO] - resolve associations. Note that this is only possible if the type\n # is not an Array (i.e. into is nil)\n\n result.pagination_scope = sql if sql.is_a?(::Simple::SQL::Connection::Scope) && sql.paginated?\n result.column_info = column_info\n result\n end",
"def result_meta\n unless @result_meta\n meta = []\n column_count.times do |idx|\n column_meta = ::OpenStruct.new\n column_meta.name = @stmt_api.column_name( idx )\n\n db_name = @stmt_api.column_database_name( idx ) \n tbl_name = @stmt_api.column_table_name( idx ) \n col_name = @stmt_api.column_origin_name( idx ) \n\n column_meta.schema = ::Amalgalite::Column.new( db_name, tbl_name, col_name, idx )\n column_meta.schema.declared_data_type = @stmt_api.column_declared_type( idx )\n\n # only check for rowid if we have a table name and it is not one of the\n # sqlite_master tables. We could get recursion in those cases.\n if not using_rowid_column? and tbl_name and\n not %w[ sqlite_master sqlite_temp_master ].include?( tbl_name ) and is_column_rowid?( tbl_name, col_name ) then\n @rowid_index = idx\n end\n\n meta << column_meta \n end\n\n @result_meta = meta\n end\n return @result_meta\n end",
"def query_return_array(sql, *binds)\n mysql.fetch(sql, *binds).all\n end",
"def recordset_from_plsql(sp)\n logger.debug \"\\n\" << sp << \"\\n\"\n cursor = $connection.exec(sp)\n recordset, = pack_cursor(cursor, :return => 'hash')\n return recordset\n end",
"def next\n return nil if @eof\n\n if @current_row\n result, @current_row = @current_row, nil\n else\n result = API.step( @vm )\n check_eof( result )\n end\n\n unless @eof\n row = result[:row]\n\n if @db.type_translation\n row = @types.zip( row ).map do |type, value|\n @db.translator.translate( type, value )\n end\n end\n\n if @db.results_as_hash\n new_row = Hash[ *( @columns.zip( row ).flatten ) ]\n row.each_with_index { |value,idx| new_row[idx] = value }\n row = new_row\n else\n row.extend FieldsContainer unless row.respond_to?(:fields)\n row.fields = @columns\n end\n\n row.extend TypesContainer\n row.types = @types\n\n return row\n end\n\n nil\n end",
"def each(&block)\n @result_records.each(&block)\n end",
"def all\n table_name = self.table_name\n \n results = CONNECTION.execute(\"SELECT * FROM '#{table_name}';\")\n\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n \n return results_as_objects\n end",
"def each_without_conversion(sql, *args, into: nil)\n pg_result = exec_logged(sql, *args)\n\n column_info = collect_column_info(pg_result)\n rows = []\n pg_source_oid = nil\n\n if pg_result.ntuples > 0 && pg_result.nfields > 0\n decoder = Decoder.new(pg_result, into: (into ? Hash : nil), column_info: column_info)\n pg_source_oid = pg_result.ftable(0)\n\n pg_result.each_row do |row|\n rows << decoder.decode(row)\n end\n end\n\n [rows, pg_source_oid, column_info]\n ensure\n # optimization: If we wouldn't clear here the GC would do this later.\n pg_result.clear if pg_result && !pg_result.autoclear?\n end",
"def query_single(sql, *params)\n results = run(sql, *params)\n results.each(as: :array, :first => true).first\n end",
"def find_rows(field_name, record_id) \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_name} WHERE #{field_name} = #{record_id}\")\n \n return self.results_as_objects(results) \n end",
"def parse_results(results)\n results.rows.collect do |row|\n record = {}\n row.each_with_index{|val, i| \n val = val.force_encoding('utf-8') if val\n record[results.fields[i].name] = val\n }\n \n record\n end\n end",
"def fetch(sql, *params)\n rs = self.execute(sql, *params)\n self.execute(\"flush privileges\") # Always flush in case user wants to alter users\n return [] if self.interpreter.preview? && ! rs\n return rs.fetch_all rescue nil\n end",
"def to_hash(cols=[])\n col_info = column_info(cols)\n rows = []\n while try { @result_set.next } do\n row = {}\n col_info.each do |col, info|\n obj = try{ @result_set.object(info[:index]) }\n case info[:type]\n when :string\n row[col] = obj.to_s\n when :boolean\n row[col] = (obj.to_s =~ /true/i ? true : false)\n when :long\n row[col] = obj.to_i\n when :double\n row[col] = obj.to_f\n else\n log.warning \"Unkown type: #{info[:type]} for #{col}\"\n row[col] = obj.to_s\n end\n end\n rows << row\n end\n rows\n end",
"def get_data\n\t\texecute unless @result\n\t\treturn get_data_from_result(@result)\n\tend",
"def each_row_for_next_chunk\n return nil if finished?\n raise \"#{self.class}: instance not prepared before running the iteration\" unless @prepared\n\n select_sql = @select_sql.present? ? @select_sql : '*'\n sql = \"SELECT #{select_sql} FROM #{data_table_name} WHERE #{data_where_scope} ORDER BY id ASC LIMIT #{Import::CHUNK_ROWS_COUNT} OFFSET #{@iteration_number * Import::CHUNK_ROWS_COUNT}\"\n pg_result = postgres.copy(\"COPY (#{sql}) TO STDOUT WITH CSV DELIMITER ','\") do |row|\n yield row\n end\n\n @iteration_number += 1\n check_if_finished\n end",
"def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = CONNECTION.execute(\"SELECT * FROM #{table_name}\")\n\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n \n return results_as_objects\n end",
"def select(sql, name = nil)\n @connection.context.reset\n log(sql, name) do\n if normal_select?\n # If limit is not explicitly set, return all results.\n @logger.debug \"Setting row count to (#{@limit || 'off'})\" if @logger\n\n # Run a normal select\n @connection.set_rowcount(@limit || 0)\n @connection.sql(sql)\n else\n # Select into a temp table and prune results\n @logger.debug \"Selecting #{@limit + (@offset || 0)} or fewer rows into #artemp\" if @logger\n @connection.set_rowcount(@limit + (@offset || 0))\n @connection.sql_norow(sql) # Select into temp table\n @logger.debug \"Deleting #{@offset || 0} or fewer rows from #artemp\" if @logger\n @connection.set_rowcount(@offset || 0)\n @connection.sql_norow(\"delete from #artemp\") # Delete leading rows\n @connection.set_rowcount(0)\n @connection.sql(\"select * from #artemp\") # Return the rest\n end\n end\n\n rows = []\n if @connection.context.failed? or @connection.cmd_fail?\n raise StatementInvalid, \"SQL Command Failed for #{name}: #{sql}\\nMessage: #{@connection.context.message}\"\n else\n results = @connection.top_row_result\n if results && results.rows.length > 0\n fields = fixup_column_names(results.columns)\n results.rows.each do |row|\n hashed_row = {}\n row.zip(fields) { |cell, column| hashed_row[column] = cell }\n rows << hashed_row\n end\n end\n end\n @connection.sql_norow(\"drop table #artemp\") if !normal_select?\n @limit = @offset = nil\n return rows\n end",
"def all_hash\n results = CONNECTION.execute(\"SELECT * FROM #{get_table_name};\")\n return array_list = make_object_array(results)\n end",
"def exercise1\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n u.name as user_name,\n COUNT(gr.name) as groups_count,\n CONCAT('[', COALESCE(STRING_AGG(gr.name, ', ' ), ''),']') as groups\n FROM ((users as u\n LEFT JOIN groups_users as gu ON u.id=gu.user_id)\n LEFT JOIN groups as gr ON gr.id = gu.group_id)\n GROUP BY user_name\n ORDER BY groups_count;\");\n\n @results1 = []\n\n index = 0\n @content.each do |r|\n @results1[index] = Result1.new r\n index = index + 1;\n end\n\n return @results1\n end",
"def select_rows(sql, name = nil)\n # last parameter indicates to return also column list\n result, columns = select(sql, name, true)\n result.map{ |v| columns.map{|c| v[c]} }\n end",
"def execute_scalar( sql )\r\n resultset = execute( sql )\r\n return nil unless resultset.rowcount > 0\r\n raise InvalidOperationException.new( \"excecute_scalar can not return multiple rows\" ) if resultset.rowcount > 1\r\n return resultset.rows.first.send( resultset.columns.first.name.to_sym )\r\n end"
] | [
"0.72692496",
"0.7105443",
"0.7092875",
"0.7083107",
"0.7067302",
"0.6878713",
"0.6834572",
"0.68228084",
"0.68021697",
"0.6779759",
"0.6705803",
"0.6664653",
"0.6627259",
"0.66172636",
"0.65640014",
"0.6547251",
"0.6530729",
"0.6467955",
"0.64433676",
"0.6437422",
"0.6425402",
"0.63227683",
"0.6309779",
"0.6250847",
"0.62397176",
"0.6225062",
"0.62093997",
"0.6091701",
"0.60729027",
"0.6070645",
"0.6033361",
"0.5998523",
"0.5988064",
"0.597808",
"0.5977967",
"0.5973938",
"0.5961728",
"0.596018",
"0.5956736",
"0.5950611",
"0.5929151",
"0.59259444",
"0.5909287",
"0.58937114",
"0.5893163",
"0.5893163",
"0.5877339",
"0.5869972",
"0.5853562",
"0.58403134",
"0.58384126",
"0.5824305",
"0.58181113",
"0.5811449",
"0.5808578",
"0.58047354",
"0.57985175",
"0.576114",
"0.57538414",
"0.5748361",
"0.57467264",
"0.5742152",
"0.57339877",
"0.5728947",
"0.5720645",
"0.57164794",
"0.57154256",
"0.5712935",
"0.57060343",
"0.57060266",
"0.57059115",
"0.57038003",
"0.5703073",
"0.5696863",
"0.5689628",
"0.5676967",
"0.56763494",
"0.5671259",
"0.56663567",
"0.56421214",
"0.5640796",
"0.56333977",
"0.5623014",
"0.5621743",
"0.5621686",
"0.5619562",
"0.5619402",
"0.56189215",
"0.56137526",
"0.56126904",
"0.56097746",
"0.56054324",
"0.5588579",
"0.557829",
"0.55772406",
"0.5574705",
"0.55681115",
"0.5565638",
"0.55619645",
"0.5559278"
] | 0.597673 | 35 |
returns the unique column values contained within the result set | def pluck_unique(column_name, results = last_results)
results.map {|r| r[column_name]}.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def values_distinct(column)\n values(column).uniq\n end",
"def column_values attribute\n self.map{|row| row[attribute]}.to_a.uniq\n end",
"def distinct\n result = empty_dup\n uniq_rows = rows.uniq\n uniq_rows.each do |row|\n result << row\n end\n result\n end",
"def values; distinct_values.map(&:value).compact; end",
"def uniq\n distinct\n end",
"def getUntappdUnique\n db.execute(\"SELECT name FROM #{@untappdTable} GROUP BY name\")\n end",
"def victory_column?(column_values)\n unique_values = column_values.uniq\n one_unique_value?(unique_values)\nend",
"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 rows_enum\n data_maker.questions.\n map{|q|q.attribute_name}.\n uniq.select{|val| val.size > 0 && !self.cols.include?(val)}\n end",
"def mots_uniques\n @mots_uniques ||= begin\n self.select do |mot_min, arr_indexes|\n arr_indexes.count == 1\n end.keys\n end\n end",
"def unseen\n table.reject do |k, v|\n v[2]\n end\n end",
"def unique(table, column, options)\n column = Array(column).map {|c| %{\"#{c}\"} }.join(', ')\n \"unique (#{column})\"\n end",
"def distinctValues(array)\n\nend",
"def get_unique_filter_values\n Rails.logger.info \"Updating filter values for SearchFacet: #{self.name} using id: #{self.big_query_id_column} and name: #{self.big_query_name_column}\"\n query_string = self.generate_bq_query_string\n begin\n Rails.logger.info \"Executing query: #{query_string}\"\n results = SearchFacet.big_query_dataset.query(query_string)\n self.is_numeric? ? results.first : results\n rescue => e\n Rails.logger.error \"Error retrieving unique values for #{CellMetadatum::BIGQUERY_TABLE}: #{e.class.name}:#{e.message}\"\n error_context = ErrorTracker.format_extra_context({query_string: query_string})\n ErrorTracker.report_exception(e, nil, error_context)\n []\n end\n end",
"def non_duplicated_values(values)\n # Write your code here\n values.uniq!\nend",
"def unique\n self['unique']\n end",
"def unique_houses(values)\n houses = values.map {|house| house[2]}\n houses.compact!\n puts houses.uniq\nend",
"def non_duplicated_values(values)\n p values.select{ |i|\n values.count(i) == 1\n \t}\nend",
"def my_uniq\n unique = []\n each_index { |i| unique << self[i] unless unique.include?(self[i]) }\n unique\n end",
"def distinct(columns, order_by)\n \"DISTINCT #{columns_for_distinct(columns, order_by)}\"\n end",
"def distinct(columns, order_by)\n \"DISTINCT #{columns_for_distinct(columns, order_by)}\"\n end",
"def victory_row?(row_values)\n unique_values = row_values.uniq\n one_unique_value?(unique_values)\nend",
"def cols_enum\n data_maker.questions.\n map{|q|q.attribute_name}.\n uniq.select{|val| val.size > 0 && !self.rows.include?(val)}\n end",
"def as_set\n content = as_content_array\n set = Set.new\n content.each {|row| row.each {|column_name, column_data| set << column_data}}\n set\n end",
"def uniq() end",
"def uniq!( header )\n column = col_index( colref_by_header( header ) )\n @data = skip_headers { |d| d.uniq { |row| row[ column - 1 ] } }\n calc_dimensions\n end",
"def my_uniq\n unique = []\n self.each do |ele|\n unique << ele if !unique.include?(ele)\n end\n unique\n end",
"def valid_sudoku(table)\n # seen_set = Set.new()\n # for i in \nend",
"def distinct_value\n id\n end",
"def unique\n lambda do |rec, acc|\n acc.uniq!\n end\n end",
"def distinct\n self.map('lambda{|x| [x, nil]}')\n .reduce_by_key('lambda{|x,_| x}')\n .map('lambda{|x| x[0]}')\n end",
"def get_unique_filter_values(public_only: false)\n log_message = \"Updating#{public_only ? ' public' : nil} filter values for SearchFacet: #{name} using id: \" \\\n \"#{big_query_id_column} and name: #{big_query_name_column}\"\n Rails.logger.info log_message\n if public_only\n accessions = Study.where(public: true).pluck(:accession)\n query_string = generate_bq_query_string(accessions: accessions)\n else\n query_string = generate_bq_query_string\n end\n begin\n Rails.logger.info \"Executing query: #{query_string}\"\n results = SearchFacet.big_query_dataset.query(query_string)\n is_numeric? ? results.first : results.to_a\n rescue => e\n Rails.logger.error \"Error retrieving unique values for #{CellMetadatum::BIGQUERY_TABLE}: #{e.class.name}:#{e.message}\"\n ErrorTracker.report_exception(e, nil, { query_string: query_string, public_only: public_only })\n []\n end\n end",
"def secunia\n\t\t\t\t\twhere(:reference_name => \"secunia\").select('DISTINCT value')\n\t\t\t\tend",
"def non_duplicated_values(values)\n results = []\n values.each do |value|\n results << value if values.count(value) == 1\n end\n results\nend",
"def columns; @columns_hash.values; end",
"def find_unique all_hash\n unique = []\n\n all_hash.each_pair do |full_name, cm|\n unique << cm if full_name == cm.full_name\n end\n\n unique\n end",
"def unique_scope\n if index = indexes.select{|i| i.unique}.sort_by{|i| i.columns.size}.first\n index.columns.reject{|name| name == self.name}\n end\n end",
"def getfieldvalues\n #instantiate the Array here to be sure it is clear of values before populating\n @fieldvalues = Array.new\n @db.execute(\"select distinct(#{@fieldname}) from data\") do |value|\n v=value[0].to_s\n @fieldvalues << value[0].to_s\n end\nend",
"def get_unique_keys_hash\n columns = unique_key_columns << :id\n Hash[select(columns).load.map { |r| [r.unique_key, r.id] }]\n end",
"def uniq\n end",
"def uniq\n end",
"def distinct(*columns)\n select(*columns) unless columns.empty?\n @conjunction.set_distinct\n nil\n end",
"def columnheaders_unique?\r\n columnheaders_raw.length == columnheaders_raw.uniq.length\r\n end",
"def get_rid_of_duplicate_columns(columns)\n\t\tcolumns.length.times do |x|\n\t\t\t# Only select rows that don't repeat colors in a column\n\t\t\t@current_options = @current_options.select do |option|\n\t\t\t\tcolumns[x].include?(option[x]) == false\n\t\t\tend\n\t\tend\n\t\t@current_options\n\tend",
"def unique_genes\n Gene.where(study_id: self.id, :study_file_id.in => self.expression_matrix_files.map(&:id)).pluck(:name).uniq\n end",
"def uniques(array)\n hash = Hash[array.map {|x| [x, nil]}]\n print hash.keys\nend",
"def distinct_count_sql(records)\n \"DISTINCT #{records.table_name}.#{records.primary_key}\"\n end",
"def find_dupes\n @hathi_report_filtered.find_all.with_index do |row, index|\n row if (row['local_id'] == @hathi_report_filtered.at(index + 1)&.[]('local_id')) || (row['local_id'] == @hathi_report_filtered.at(index - 1)['local_id'])\n end.compact\n end",
"def non_duplicated_values(values)\n return values.select {|x| values.count(x) == 1 } \nend",
"def uniq_keys\n all.to_a.collect {|n| n.key }.uniq\n end",
"def my_uniq(arr)\n unique_set = arr.reduce({}) do |acc, el|\n acc[el] = true\n acc\n end\n unique_set.keys\nend",
"def sql_columns\n columns.map(&:sql_names).compact.flatten.uniq.map(&:to_s)\n end",
"def uniq(networkcheckoutput)\n mash = Hashie::Mash.new networkcheckoutput\n #networkcheckoutput.hits.hits.each do |value|\n\n #this creates a dataset of unique values based on a specified field. Need to break the Date out of the timestamp field to use.\n seen = Set.new\n mash.hits.hits.inject([]) do |kept, record|\n\n\n #brokenfield = record._source.src_ip.match(/\\w++ [^_]\\w/)\n\n unless seen.include?(record._source.src_ip)\n kept << record\n seen << record._source.src_ip\n end\n kept\n end\n end",
"def non_duplicated_values(values)\n values.find_all { |x| values.count(x) == 1 }\nend",
"def collect_column_headers\n @column_headers = []\n CSV.foreach('testdata.csv') {|row| @column_headers << row[0].to_i}\n @column_headers = @column_headers.uniq.sort[1..-1] # ==> [102231711, 103244134, 103285344, 103293593]\nend",
"def unique_entries_by_(key) \n seen = Set.new()\n entries.select { |e|\n k = e.send(key)\n seen.add?(k)\n }.sort{|a, b| a.range.low <=> b.range.low }\n end",
"def showuniquevalueswfunction(array)\n # result array \n result = Array.new \n # check if input array is empty\n if array.length > 0 then\n # make the result array iqual to the input array uniq function which returns a new array by removing duplicate values in self. \n result = array.uniq\n else\n print \"Input array is empty. It can not be empty\"\n end\n return result\nend",
"def unique_available_page_cell_names(page)\n available_page_cells(page).collect(&:name).uniq\n end",
"def generate_non_array_query\n \"SELECT DISTINCT #{self.big_query_id_column} AS id, #{self.big_query_name_column} AS name FROM #{CellMetadatum::BIGQUERY_TABLE}\"\n end",
"def getUntappdUniqueCount\n db.execute(\"SELECT count(name) FROM #{@untappdTable}\")[0][0]\n end",
"def values\n sub_result = []\n i = 0\n while i < @hash.length do\n if @hash[i] != nil && @hash[i].length > 0\n @hash[i].map { |k, v| sub_result.push(v) }\n end\n i += 1\n end\n return sub_result.uniq\n end",
"def non_duplicated_values(values)\n values.select{|item| values.count(item) == 1}.uniq\nend",
"def unique(integers)\n integers.to_set.to_a\nend",
"def omim_ids\n @table.keys\n end",
"def resultset; end",
"def uniq_by\n clean = []\n self.collect{|x| yield(x)}.uniq.each do |x|\n clean << self.select{|y| yield(y) == x}.last\n end\n clean\n end",
"def non_duplicated_values(values)\n uniques = []\n for number in values.uniq.each do\n if values.count(number) == 1\n uniques.push(number)\n end\n end\n return uniques\nend",
"def non_duplicated_values(values)\n values.select { |value| values.count(value) == 1 }\nend",
"def non_duplicated_values(values)\n values.select { |value| values.count(value) == 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 yale_row_as_set i\n require 'set'\n yale_row_as_array(i).to_set\n end",
"def unique_index_columns\n inventory_collection.manager_ref_to_cols.map(&:to_sym)\n end",
"def uniq!() end",
"def distinct\n @interactiondistinct = Interaction.select('location').where('DATEDIFF(CURRENT_TIMESTAMP,date_time)<33').uniq\n end",
"def uniq!\n im = Rubinius::IdentityMap.from self\n return if im.size == size\n\n Rubinius.check_frozen\n\n array = im.to_array\n @tuple = array.tuple\n @start = array.start\n @total = array.total\n\n self\n end",
"def num_uniq\n Set[*self].size\n end",
"def duplicate_names\n array = all.pluck(:name)\n array.select{|element| array.count(element) > 1 }.uniq\n end",
"def duplicate_names\n array = all.pluck(:name)\n array.select{|element| array.count(element) > 1 }.uniq\n end",
"def unique_items(ary)\r\n ary.select {|x| ary.count(x) == 1}\r\nend",
"def keys\n @result_set ? @callsite.columns_hash.keys : super | @monitored_columns.keys\n end",
"def keys\n map(&:key).uniq\n end",
"def clean_result_set(result_set)\n result_set.each do |set|\n set.sort!\n end\n result_set.sort! {|a,b| a.size <=> b.size}\n end",
"def column_values(column)\r\n assert_exists\r\n arr_rows = rows\r\n values = Array.new(arr_rows.length)\r\n for i in 0..arr_rows.length - 1 do\r\n values[i] = arr_rows[i][column].to_s \r\n end\r\n return values\r\n end",
"def iava\n\t\t\t\t\twhere(:reference_name => \"iava\").select('DISTINCT value')\n\t\t\t\tend",
"def uniq\n uniq_vector = @data.uniq\n new_index = uniq_vector.inject([]) do |acc, element| \n acc << index_of(element) \n acc\n end\n\n Daru::Vector.new uniq_vector, name: @name, index: new_index, dtype: @dtype\n end",
"def using_uniq(array)\n\n \nend",
"def generate_array_query\n \"SELECT DISTINCT id, name FROM(SELECT id_col AS id, name_col as name \" + \\\n \"FROM #{CellMetadatum::BIGQUERY_TABLE}, UNNEST(#{self.big_query_id_column}) AS id_col WITH OFFSET id_pos, \" + \\\n \"UNNEST(#{self.big_query_name_column}) as name_col WITH OFFSET name_pos WHERE id_pos = name_pos)\"\n end",
"def uniq_ints()\n []\n end",
"def my_unique\n dict = Hash.new(false)\n self.each_with_index do |el, idx|\n self[idx] = nil if dict[el]\n dict[el] = true\n end\n self.compact!\n end",
"def allowable_values(allowable_values)\n seen_values = Set.new\n self.cells.each do |cell|\n seen_values << cell.value\n end\n return allowable_values - seen_values.to_a\n end",
"def get_unique_permutations annotation_time_slot\r\n\t\treturn annotation_time_slot.uniq.permutation.to_a\r\n\tend",
"def unique_elements(arr)\n\thash = {}\n arr.each { |ele| hash[ele] = true }\n return hash.keys \t\nend",
"def non_duplicated_values(values)\n values.find_all do |e|\n if values.count(e) > 1\n values.delete(e)\n end\n end\n values\nend",
"def clean_table(table, number_of_colums)\n above_row = []\n #filter if they are not last column, and they are same as the item on the row above\n table.reduce([]) { |result, row|\n result << row.each_with_index.map do |item,i|\n if i == number_of_colums\n item \n else\n item == above_row[i] ? '' : item \n end\n end\n above_row = row\n result\n }\n end",
"def clean_table(table, number_of_colums)\n above_row = []\n #filter if they are not last column, and they are same as the item on the row above\n table.reduce([]) { |result, row|\n result << row.each_with_index.map do |item,i|\n if i == number_of_colums\n item \n else\n item == above_row[i] ? '' : item \n end\n end\n above_row = row\n result\n }\n end",
"def osvdb\n\t\t\t\t\twhere(:reference_name => \"osvdb\").select('DISTINCT value')\n\t\t\t\tend",
"def distinct_factors(tuples)\n accumulator = []\n tuples.each { |el| accumulator << el }\n return accumulator.uniq == accumulator\nend",
"def filtered_results(results)\n return [] if results.blank?\n\n members = results.first[:uniquemember]\n members = results.first[:member] if members.blank?\n members.map do |r|\n uid = r.split(\",\").first\n uid.split(\"=\", 2).last\n end\n end",
"def element_names_not_in_cell\n definition['elements'].uniq - element_names_from_cells\n end",
"def set(arr)\n\treturn arr.uniq\nend"
] | [
"0.74648225",
"0.7228825",
"0.7008775",
"0.6572763",
"0.65444523",
"0.6499435",
"0.63154155",
"0.62317437",
"0.60778254",
"0.60629845",
"0.60582674",
"0.60230774",
"0.601775",
"0.59118074",
"0.58979434",
"0.5893905",
"0.5879149",
"0.58765554",
"0.58665615",
"0.5855902",
"0.5855902",
"0.5854695",
"0.5854247",
"0.58486944",
"0.5832527",
"0.58314085",
"0.5826976",
"0.58153296",
"0.5812099",
"0.5798184",
"0.578761",
"0.57703924",
"0.5732674",
"0.5729526",
"0.57231414",
"0.5694126",
"0.5687371",
"0.5687293",
"0.56758237",
"0.5675449",
"0.5675449",
"0.5641896",
"0.5640648",
"0.5631161",
"0.56195265",
"0.5613252",
"0.5599436",
"0.55745214",
"0.55702335",
"0.55684084",
"0.55681586",
"0.5561072",
"0.55557173",
"0.5546803",
"0.55445707",
"0.55395484",
"0.55251384",
"0.5523412",
"0.5509086",
"0.5490575",
"0.5480084",
"0.54780304",
"0.5477143",
"0.54740673",
"0.54561424",
"0.544481",
"0.5442562",
"0.5441306",
"0.5441306",
"0.5437665",
"0.5429476",
"0.54187614",
"0.5397331",
"0.5386503",
"0.53862476",
"0.5386152",
"0.5385259",
"0.5383708",
"0.5383486",
"0.5383",
"0.5380963",
"0.53747594",
"0.5371859",
"0.53630173",
"0.53514236",
"0.5346865",
"0.53434366",
"0.5339632",
"0.53329396",
"0.5325585",
"0.532357",
"0.5323145",
"0.53163594",
"0.5311258",
"0.5311258",
"0.53096604",
"0.5301867",
"0.5300217",
"0.5293555",
"0.5290028"
] | 0.71440125 | 2 |
//////////////////////////////////////////////////////////////////////////// // Class helpers & accessors. | def uid
(@in['uid_hi'] << 16) | @in['uid_lo']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def class; end",
"def class; end",
"def instance; end",
"def instance; end",
"def instance; end",
"def initialize\n\n end",
"def initialize\n\n end",
"def implementation; end",
"def implementation; end",
"def getters; end",
"def class() end",
"def class_variables; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def klass; end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def instance_variables; end",
"def public; end",
"def public; end",
"def class_variables() end",
"def initialize\n\t\t\n\tend",
"def class_name; end",
"def class_name; end",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def class_variables\n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def __getobj__\n end",
"def class_attributes; end",
"def instance_type; end",
"def initialize\r\n\r\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def public_method; end",
"def initialize()\n\n end",
"def initialize()\r\n\r\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize\n \n end",
"def initialize\n \n end",
"def instance_variables() end",
"def self_type; end",
"def self_type; end",
"def self_type; end",
"def attr_reader(*)\n end",
"def initialize()\n\t\tend",
"def base_class; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def initialize\n end"
] | [
"0.7919786",
"0.6944393",
"0.6944393",
"0.6791091",
"0.6791091",
"0.6791091",
"0.671222",
"0.671222",
"0.66667444",
"0.66667444",
"0.6635319",
"0.66351116",
"0.66179955",
"0.6601462",
"0.6601462",
"0.66014427",
"0.66014427",
"0.66014427",
"0.66014427",
"0.66014427",
"0.66014427",
"0.6599553",
"0.6599553",
"0.6599553",
"0.6599553",
"0.6599553",
"0.6599553",
"0.6599553",
"0.6599553",
"0.6599553",
"0.6599553",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.6577544",
"0.65511537",
"0.65450543",
"0.65450543",
"0.6540605",
"0.652336",
"0.65117276",
"0.65117276",
"0.6483011",
"0.6483011",
"0.6477922",
"0.64736515",
"0.64736515",
"0.64736515",
"0.64736515",
"0.64736515",
"0.64736515",
"0.64736515",
"0.64736515",
"0.64736515",
"0.64736515",
"0.64736515",
"0.6465072",
"0.6445721",
"0.64079785",
"0.64016837",
"0.6397839",
"0.6397839",
"0.6397839",
"0.6397839",
"0.6390015",
"0.6390015",
"0.6390015",
"0.6390015",
"0.6390015",
"0.6390015",
"0.6390015",
"0.6385261",
"0.6345409",
"0.6341813",
"0.6339672",
"0.6339672",
"0.63360167",
"0.63360167",
"0.6332912",
"0.63237107",
"0.63237107",
"0.63237107",
"0.632283",
"0.62941426",
"0.629391",
"0.6282916",
"0.6282916",
"0.6282916",
"0.6282916",
"0.62810737"
] | 0.0 | -1 |
//////////////////////////////////////////////////////////////////////////// // Utility functions. | def fileModeToFileType
@@FM2FT[@mode & MSK_FILE_MODE]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def terpene; end",
"def probers; end",
"def berlioz; end",
"def user_os_complex\r\n end",
"def ibu; end",
"def file_utils; end",
"def stderrs; end",
"def schubert; end",
"def tiny; end",
"def ext; end",
"def ext; end",
"def anchored; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def issn; end",
"def verdi; end",
"def rassoc(p0) end",
"def loc; end",
"def loc; end",
"def loc; end",
"def big_bad; end",
"def gounod; end",
"def hiss; end",
"def trd; end",
"def strings; end",
"def identify; end",
"def blg; end",
"def ismn; end",
"def suivre; end",
"def test_inspect\n\t\t# normalize, as instance_variables order is undefined\n\t\tnormalize = proc { |s| s[/ (.*)>$/, 1].split(', ').sort.join(', ') }\n\t\tassert_match %r{blocks=2.*ftype=file.*size=72}, normalize[@ole.file.stat('file1').inspect]\n\tend",
"def str2; end",
"def str2; end",
"def malts; end",
"def string()\n #This is a stub, used for indexing\n end",
"def String(p0) end",
"def weber; end",
"def file_utils=(_arg0); end",
"def short_name( fn )\n #puts \"Calculate short name for #{fn}\\n\"\n return fn if ARCH != 'w32'\n fn.gsub!( /\\//, \"\\\\\" )\n buffer = ' ' * 260\n length = ShortPName.call( fn, buffer, buffer.size )\n fn = buffer.slice(0..length-1) if length > 0\n fn.gsub!( /\\\\/, '/' )\n return fn\nend",
"def from; end",
"def from; end",
"def from; end",
"def from; end",
"def my955; end",
"def string() end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def beautify; end",
"def beautify; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def str; end",
"def str; end",
"def who_we_are\r\n end",
"def romeo_and_juliet; end",
"def str3; end",
"def str3; end",
"def as_you_like_it_quote; end",
"def jack_handey; end",
"def intern() end",
"def by_magic(io); end",
"def bs; end",
"def herald; end",
"def tld; end",
"def tld; end",
"def missing?; end",
"def with_repl_like_sigint; end",
"def sld; end",
"def mozart; end",
"def missing?; false; end",
"def same; end",
"def plausible_common_name; end",
"def missing; end",
"def diff2; end",
"def buzzword; end",
"def buzzword; end",
"def test_account_format\n assert_equal false, elfproef(123456)\n assert_equal false, elfproef(1234567890)\n assert_equal false, elfproef('12345678a')\n end",
"def rossini; end",
"def hipsterfy(string)\r\n\r\nend",
"def real_name; end",
"def formation; end",
"def lsi; end",
"def name_safe?; end",
"def bytepos; end",
"def extension; end",
"def extension; end",
"def extension; end",
"def extension; end",
"def defang_i_paddr(address)\n address.gsub('.', '[.]')\nend",
"def check ; true ; end",
"def common\n \n end"
] | [
"0.599519",
"0.5604515",
"0.55783224",
"0.5510952",
"0.54838866",
"0.5455098",
"0.5382202",
"0.53464663",
"0.53452194",
"0.5324838",
"0.5316659",
"0.5316659",
"0.5278308",
"0.525551",
"0.525551",
"0.525551",
"0.525551",
"0.5178268",
"0.5120912",
"0.5119151",
"0.5103225",
"0.5103225",
"0.5103225",
"0.5096778",
"0.50919425",
"0.5091733",
"0.5088518",
"0.5033015",
"0.50163436",
"0.50162697",
"0.49985296",
"0.4994801",
"0.49804512",
"0.49530944",
"0.49530944",
"0.49522257",
"0.49423283",
"0.49288163",
"0.49245414",
"0.49245307",
"0.4923661",
"0.4915609",
"0.4915609",
"0.4915609",
"0.4915609",
"0.49050236",
"0.48991394",
"0.4898781",
"0.4898781",
"0.4898781",
"0.48920906",
"0.48920906",
"0.48870388",
"0.48870388",
"0.48870388",
"0.48870388",
"0.48870388",
"0.48870388",
"0.48870388",
"0.48870388",
"0.48870388",
"0.48866227",
"0.48866227",
"0.48833826",
"0.48796135",
"0.48784354",
"0.48784354",
"0.4878062",
"0.48771146",
"0.48568913",
"0.48565784",
"0.48561323",
"0.48550054",
"0.48541108",
"0.48541108",
"0.48492244",
"0.48489514",
"0.48489106",
"0.48414162",
"0.48379788",
"0.48367816",
"0.4834724",
"0.4832221",
"0.4828034",
"0.48271024",
"0.48271024",
"0.48255032",
"0.4825382",
"0.48252156",
"0.4824341",
"0.48189202",
"0.48114145",
"0.48093948",
"0.48069876",
"0.4805952",
"0.4805952",
"0.4805952",
"0.4805952",
"0.47974545",
"0.47973296",
"0.47972256"
] | 0.0 | -1 |
Adds the file with the given filename to the working copy. | def add(filename)
not_implemented('add')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_file(filename)\n dir = File.dirname(filename).gsub(\"#{@dest}\",\".\")\n fn = File.basename(filename)\n folder = @folders[dir] || @folders[dir]=[]\n folder << fn\n end",
"def add_file(filename)\n dir = File.dirname(filename).gsub(\"#{@dest}\",\".\")\n fn = File.basename(filename)\n folder = @folders[dir] || @folders[dir]=[]\n folder << fn\n end",
"def add_file (file)\n @files[file.path] = file\n end",
"def add_file (file)\n @files[file.path] = file\n end",
"def add_file(file)\n @zip.put_next_entry(file.path)\n @zip.write(file.read)\n end",
"def add_file(file)\n @files << file\n end",
"def project_file_add(project_id, file)\n put(\"/projects/#{project_id}/files\", nil, file)\n end",
"def copy_file(source_file, destination_file, version)\n # add new filename to existing digest in current state.\n # If destination file already exists, overwrite it.\n existing_files = get_files(version)\n\n if existing_files.key?(destination_file)\n delete_file(destination_file, version)\n end\n # should NOT call add_file, as add_file updates the manifest.\n # Should instead JUST update current state with new filepath.\n digest = get_digest(source_file, version) # errors out if source_file not found in current state\n\n my_state = get_state(version)\n my_files = my_state[digest]\n my_files << destination_file\n unique_files = my_files.uniq # Just in case we're trying to add the same thing multiple times.\n # Need to actually add this to @versions!\n @versions[OcflTools::Utils.version_int_to_string(version)]['state'][digest] = unique_files\n # Prove we actually added to state\n get_state(version)\n # self.add_file(destination_file, self.get_digest(source_file, version), version)\n end",
"def add_file(file)\n @files[file.name] = file\n file.parent = self\n end",
"def addFile(src, dest=nil)\n orig = dest\n dest = File.join(@defaultPath, File.basename(src)) if !dest\n @files[src] = dest\n end",
"def addFile(file)\r\n @files << file\r\n end",
"def add_file src, target, exclude = nil\n @files << FileItem.new(src, target, exclude)\n self\n end",
"def add_file(name)\n @files[name] = nil unless @files.has_key?(name)\n end",
"def append(filename)\n return @filemgr.append(filename, @contents)\n end",
"def copy_one_file(filename)\n source_name = File.join(source_directory,filename)\n install_name = File.join(install_directory,filename)\n dir_name = File.dirname(install_name)\n \n mkdir_p(dir_name)\n cp(source_name,install_name,:preserve => true)\n end",
"def add_file(file)\n index = @repo.index\n index.add path: file, oid: (Rugged::Blob.from_workdir @repo, file), mode: 0100644\n index.write\n\n @affected_files << file\n end",
"def add_file( file_path )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_add_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} add #{file_path}\"\n log.info(x) { \"[git] single file add command => #{git_add_cmd}\" }\n %x[#{git_add_cmd}];\n log.info(x) { \"[git] has added #{file_path} into the git repository.\" }\n\n end",
"def add_file file\n if not File.file? file\n raise ArgumentError\n else\n @files.push file\n puts \"#{File.basename file} added to package #{@name}\" if @verbose\n end\n end",
"def add(file_or_filename)\n if file_or_filename.respond_to?(:to_io)\n add_file file_or_filename.to_io\n elsif file_or_filename.respond_to?(:to_str)\n add_filename file_or_filename\n end\n end",
"def addFile(name)\n @filesQueue.push(name)\n end",
"def add_file( zipfile, f )\n if File.exists?(f)\n puts \"Writing #{f} at #{@dest_dir}\" if verbose\n zipfile.add(f, \"#{@dest_dir}/#{f}\")\n else\n puts \"Ignoring missing file #{f} at #{@dest_dir}\"\n end\n end",
"def copy_file(filename,dst_dir='/',dst_repo=self.repo,src_repo=self.repo)\n post_copy(src_repo,{\"file_names\"=>filename, \"dst_repo\" => dst_repo, \"dst_dir\"=>dst_dir})\n end",
"def add_file(file_path)\n @ole.AddFile(file_path)\n end",
"def add_file(file_path)\n @ole.AddFile(file_path)\n end",
"def zip_add_file(zip, filename, content)\n print_status(\"Adding '#{filename}' (#{content.length} bytes)\");\n zip.add_file(filename, content, nil, nil, nil)\n end",
"def add file\n file.download unless file.downloaded?\n @files << file\n end",
"def record(filename)\n contents = File.read(filename) rescue nil\n files[filename] = contents unless files.has_key? filename\n end",
"def add_file path\n if File.exist? path\n @files << path\n else\n raise Errno::ENOENT, \"File '#{path}' doesn't exist\"\n end\n end",
"def add_file(file, dsid, file_name) \n return add_external_file(file, dsid, file_name) if dsid == 'content'\n super\n end",
"def add(file)\n @file = file\n FileUtils.cp_r(file.path,folder_path)\n unless system(\"cd #{repo_path};git add .\")\n raise GitCloud::GitException.new(\"Add\")\n end\n end",
"def push_file(source, original_filename, id = nil)\n data = self.read_from(source)\n self.grid.put(data, filename: original_filename, _id: id)\n end",
"def add_file(file)\n @files_so_far += 1\n @display.print_file @files_so_far, file\n end",
"def add_file(file, dsid, file_name) \n return add_external_file(file, file_name) if dsid == 'content'\n super\n end",
"def add_to_git_ignore(filename)\n File.open(File.join(dotfiles_path, '.gitignore'), \"a+\") do |file|\n contents = file.read\n unless contents =~ %r{^#{filename}$}\n info(\"Adding #{filename} to #{File.join(dotfiles_path, '.gitignore')}\")\n file.write(filename + \"\\n\")\n end\n end\n end",
"def addFile(url, local_name)\r\n\t\t\t`bitsadmin /rawreturn /addfile {#{@id}} #{url} #{local_name}`\r\n\t\tend",
"def add_file(str)\n\t\[email protected](str)\n\tend",
"def add_file(file)\n setup_file_tailer file\n self\n end",
"def add_file(tar_writer, file, root_path)\n stat = File.stat(file)\n name = Pathname.new(file).relative_path_from(root_path).to_s\n tar_writer.add_file_simple(name, stat.mode, stat.size) do |io|\n File.open(file, 'rb') { |f| IO.copy_stream(f, io) }\n end\n rescue Errno::ENOENT\n nil\n end",
"def add_file(file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil)\n Dropio::Resource.client.add_file(self, file_path, description, convert_to, pingback_url, comment)\n end",
"def add_file(name, content)\n full_path = File.join(path, name)\n file = MirrorFile.new(full_path)\n\n file.write(content)\n\n file\n end",
"def appendFile(src, dest)\n Dir.foreach(src) do |file|\n # Do not add file if it was in the exclusion list.\n next if exclude? file\n \n file = File.join(src, file)\n \n # Do not add file if it was in the manifest.\n next if in_manifest? file\n \n if File.directory? file\n appendFile(file, dest) # Recurse over directories.\n else\n # Open the file and copy its contents to the destination.\n begin\n f = File.open(file.strip! || file)\n f.each_line { |line| File.open(dest, 'a') { |f| f.write(line) } }\n f.close\n rescue => e\n puts \"FAILED!\"\n puts e.message\n exit\n end\n end\n end\nend",
"def add_file(uploaded_file, path)\n filename = sanitize_filename(uploaded_file.original_filename)\n\n if (path and path != '')\n FileUtils.mkdir_p(self.path_to_folder + path)\n end\n\n # if it's large enough to be a real file\n return FileUtils.copy(uploaded_file.local_path, self.path_to_folder + path + filename) if uploaded_file.instance_of?(Tempfile)\n # else\n File.open(self.path_to_folder + path + filename, \"w\") { |f| f.write(uploaded_file.read) }\n end",
"def add_file file, opts={}\n opts[:mime_type] ||= Ddr::Utils.mime_type_for(file)\n opts[:original_name] ||= Ddr::Utils.file_name_for(file)\n\n # @file_to_add is set for callbacks to access the data\n self.file_to_add = file\n\n run_callbacks(:add_file) do\n super\n end\n\n # clear the instance data\n self.file_to_add = nil\n end",
"def save_file(file_id, source)\n synchronize do\n unless cached?(file_id)\n destination = File.join(@cache_root, Utils.fileid2name(file_id))\n FileUtils.cp(source, destination)\n \n if File.exist?(destination)\n cached_file = CachedFile.new\n cached_file.filename = File.basename(source)\n cached_file.last_copy = DateTime::now\n \n @cached_files[file_id] = cached_file\n else\n message = \"Cache: Unable to copy file with id #{file_id}.\"\n @logger.error(message) if @logger\n raise message\n end\n end\n end\n end",
"def add_file(path)\n File.readlines(path).each { |s| self << s.strip }\n nil\n end",
"def add_file(file_name, data, flags)\n data = filter \"decode\", file_name, data\n path = working_join file_name\n \n File.unlink path rescue nil\n \n if flags.include? 'l' # if it's a link\n @file_opener.symlink path, data\n else\n @file_opener.open(path, 'w') {|f| f.write data }\n File.set_flag path, false, true if flags.include? 'x'\n end\n end",
"def file(path)\n new_file = SourceFile.new(path)\n add_file(new_file)\n new_file\n end",
"def copy( src_filepath, dst_name = nil )\n dst_filepath = dst_name ? @current_path.join( dst_name ) : @current_path\n FileUtils.copy( src_filepath, dst_filepath )\n end",
"def add_file entry, content = nil\n path = repo_path.join entry\n dir, filename = path.split unless entry.end_with? \"/\"\n\n FileUtils.mkdir_p dir.to_s == '.' ? repo_path : dir\n FileUtils.touch path if filename\n File.write path, content if filename && content\n end",
"def add_file(*args)\n context = args.pop\n file_path_hash_or_string, content, commit_msg = args\n file_path_hash = file_path_hash_form(file_path_hash_or_string)\n get_adapter_repo(context).add_file(file_path_hash, content, commit_msg)\n end",
"def push(filename)\n File.open(filename, 'r'){ |f| Uploader.new.store! f }\n end",
"def copy_file(filename1, filename2)\n save_tasks_to_file_impl(load_tasks_from_file_impl(filename1), filename2)\n end",
"def addFile(filename, essence)\n \n \n \n begin\n \n\n filesize = essence.length\n filename.gsub!(/ /, '_')\n \n # if filesize is larger than about 5mb, increase git timeout\n if filesize > 5000000\n Grit::Git.git_timeout = 30\n # if filesize is larger than about 100mb, throw an exception\n if filesize > 100000000\n raise Exception.new(\"File is too large to handle with git\")\n end\n else\n Grit::Git.git_timeout = 10\n end\n \n # create dir if it does not exist\n if not (File.exists?(@dev_path) && File.directory?(@dev_path))\n FileUtils.mkdir_p(@dev_path) \n end\n \n \n if filename.size > 1\n path = filename[0..filename.rindex('/')]\n FileUtils.mkdir_p(@dev_path+path) \n end\n \n #puts \"name: #{filename}\"\n #puts \"path: #{path}\"\n \n \n path = File.join(@dev_path, filename)\n # write the file\n File.open(path, \"wb\") { |f| \n #puts f.to_s\n f.write(essence)\n \n }\n sleep(0.2)\n @repo.add(\"#{@dev_path}#{filename}\")\n puts \"File \" + filename + \" added to repo.\"\n rescue Exception => e\n puts \"Error: #{e.to_s}\"\n puts \" -- line: #{e.backtrace[0].to_s}\"\n raise Exception.new(\"Could not add a new file to virtual container!\")\n end\n return true\n end",
"def add_file(file_params)\n # append a new file to our the current identity's list of bruse_files\n\n file = BruseFile.new(file_params)\n\n if bruse_files << file\n # return file\n file\n else\n # could not append file!\n file.destroy\n nil\n end\n end",
"def add_keyfile(file)\n ProcessWatcher.watch(\"ssh-add\", [file], nil, -1, 10)\n end",
"def store_file!(full_path_filename)\n store!(File.open(full_path_filename))\n end",
"def append_file(fn, str)\n File.open(fn, 'a') do |f|\n f.puts str\n end\n end",
"def add_filepath_to_source(filepath)\n\t\tFile.open(@source, 'r+') do |file|\n\t\t\tlines = self.get_source_content\n\t\t\tlines.push(filepath)\n\t\t\tlines.uniq!\n\t\t\tlines.sort!\n\t\t\tfile.puts lines.join(\"\\n\")\n\t\tend\n\tend",
"def add(file); @actions << Action::AddAction.new(file); end",
"def append filename, config\n @config << ({\n file: filename,\n config: config\n })\n end",
"def save_file\n FileUtils.mkdir_p(File.dirname(full_filename))\n FileUtils.cp(temp_path, full_filename)\n FileUtils.chmod(0644, full_filename)\n end",
"def add_file(rev, full_path, content, _mime_type = 'text/plain')\n if file_exists?(rev, full_path)\n raise Repository::FileExistsConflict, full_path\n end\n # file does not exist, so add it\n creation_time = Time.current\n file = Repository::RevisionFile.new(rev.revision_identifier, {\n name: File.basename(full_path),\n path: File.dirname(full_path),\n last_modified_revision: rev.revision_identifier,\n changed: true,\n user_id: rev.user_id,\n last_modified_date: creation_time,\n submitted_date: creation_time\n })\n rev.__add_file(file, content)\n rev\n end",
"def save_file(file, name = '')\n if name.size > 0\n filename = name + File.extname(file[:filename])\n else\n filename = file[:filename]\n end\n FileUtils.mkdir_p(attach_dir) unless File.exists?(attach_dir)\n new_file = File.join(attach_dir, filename)\n\n f = File.new(new_file, 'w')\n f.write(file[:tempfile].read)\n f.close\n\n commit_message = \"uploaded #{filename} for #{@name}\"\n begin\n $repo.add(new_file)\n $repo.commit(commit_message)\n rescue\n # FIXME why!??\n nil\n end\n end",
"def append_file(filename,data)\n begin\n File.open(filename, \"a+\") do |f|\n f<< data\n end\n rescue Exception => e\n puts e.message \n end\n end",
"def file_append(filepath, newcontent, backup=false)\n content = StringIO.new\n \n if self.file_exists?(filepath)\n self.cp filepath, \"#{filepath}-previous\" if backup\n content = self.file_download filepath\n end\n \n if newcontent.is_a?(StringIO)\n newcontent.rewind\n content.puts newcontent.read\n else\n content.puts newcontent\n end\n \n self.file_upload content, filepath\n end",
"def filename() @fn.dup end",
"def add_file(file_id, user, ip, source, port)\n times_to_retry = @storage_config.times_to_retry\n while (times_to_retry > 0)\n begin\n destination = File.join(@storage_config.files_storage_root_full_path, Utils.fileid2name(file_id))\n cmd_line = \"scp -P #{port} #{user}@#{ip}:#{source} #{destination}\"\n \n @logger.info(\"DSS: Saving file :#{cmd_line}\")\n if ( system(cmd_line) == false )\n message = \"DSS: Transaction faild with error #{$?}\"\n raise message\n else\n @logger.info(\"DSS: Save Successful\")\n return true;\n end \n rescue \n times_to_retry -= 1\n if (times_to_retry > 0)\n sleep(@storage_config.sleep_on_retry)\n else\n message = \"DSS: Unable to save file #{source} to #{destination}, error: #{$!.message}\"\n @logger.error(message)\n raise message\n end \n end \n end \n end",
"def rc_file_copy(sp, fn = '')\n if sp.is_a? String\n fn = sp.dup\n sp = sp.split(File::SEPARATOR)\n end\n if sp.length == 1\n # remove_file sp[0]\n copy_file sp[0]\n else\n inside sp.shift do\n rc_file_copy(sp, fn)\n end\n end\nend",
"def write_to(filename)\n FileUtils.mkdir_p File.dirname(filename)\n\n PathUtils.atomic_write(filename) do |f|\n f.write source\n end\n\n nil\n end",
"def addFile(filePath, hash)\n #N Without this the path won't be broken up into elements so that we can start by processing the first element\n pathElements = getPathElements(filePath)\n #N Without this check, we would attempt to process an invalid path consisting of an empty string or no path elements (since the path should always contain at least one element consisting of the file name)\n if pathElements.length == 0\n #N Without this, the case of zero path elements will not be treated as an error\n raise \"Invalid file path: #{filePath.inspect}\"\n end\n #N Without this check, the cases of having the immediate file name (to be added as a file in this directory) and having a file within a sub-directory will not be distinguished\n if pathElements.length == 1\n #N Without this, the single path element will not be treated as being the immediate file name\n fileName = pathElements[0]\n #N Without this, we won't have our object representing the file name and a hash of its contents\n fileContent = FileContent.new(fileName, hash, @pathElements)\n #N Without this, the file&content object won't be added to the list of files contained in this directory\n files << fileContent\n #N Without this, we won't be able to look up the file&content object by name.\n fileByName[fileName] = fileContent\n else\n #N Without this, we won't have the first part of the file path required to identify the immediate sub-directory that it is found in.\n pathStart = pathElements[0]\n #N Without this, we won't have the rest of the path which needs to be passed to the content tree in the immediate sub-directory\n restOfPath = pathElements[1..-1]\n #N Without this, the file & hash won't be added into the sub-directory's content tree\n getContentTreeForSubDir(pathStart).addFile(restOfPath, hash)\n end\n end",
"def notify_file_cp(src, dst)\r\n if @files.key?(src)\r\n @files[dst] = @files[src].clone\r\n else\r\n @files[src] = { exist: true }\r\n @files[dst] = { exist: true }\r\n end\r\n register_file_in_dirs(dst)\r\n end",
"def add(filename)\n raise StandardError, \"That filename is invalid, its too long\" if filename.length > 255\n # Get the next record number\n p n = getNextRecordNumber\n \n filename = File.expand_path(filename)\n filename.gsub!(/^([a-z])/){$1.upcase}\n \n utf8 = filename\n # Are there any UTF8 characters to deal with?\n if not filename =~ /^[\\x21-\\x7E]+$/i\n # Use File::SEPARATOR\n filename = filename[0,3]+(filename[3..-1].split(\"\\\\\").collect { |chunk| ((chunk =~ /^[\\x21-\\x7E]+$/i) ? chunk : chunk.gsub(/([^a-z0-9_])/i,\"\")[0..5].upcase+\"~1\"+File.extname(chunk))}.join(\"\\\\\"))\n end\n \n test = open(\"temp.txt\",\"w\")\n # Go to the end of the file, where the next record needs to be written\n @fh.sysseek(0, IO::SEEK_END)\n @fh.write filename.ljust(280,\"\\000\")\n @fh.write [n].pack(\"V\")\n @fh.write [filename.match(/^([A-Z]):/i)[1].upcase[0] - 65].pack(\"V\")\n @fh.write [((Time.now.to_f+11644473600)*(10**7)).to_i].pack(\"Q\")\n @fh.write [(open(utf8).read.length / Sys::Filesystem.stat(filename[0,3]).block_size).ceil].pack(\"V\")\n @fh.write Iconv.new(\"UTF-16LE\",\"UTF-8\").iconv(utf8).ljust(520,\"\\000\")\n @fh.write \"\\x0D\\x0A\"\n \"D#{filename[0..0].downcase}#{n+1}\"+File.extname(utf8)\n end",
"def add(entry, src_path, &continue_on_exists_proc)\n continue_on_exists_proc ||= proc { ::Zip.continue_on_exists_proc }\n check_entry_exists(entry, continue_on_exists_proc, 'add')\n new_entry = entry.kind_of?(::Zip::Entry) ? entry : ::Zip::Entry.new(@name, entry.to_s)\n new_entry.gather_fileinfo_from_srcpath(src_path)\n new_entry.dirty = true\n @entry_set << new_entry\n end",
"def addFiles(branch, files)\n zombie_check\n on_worktree(branch) do |repo|\n repo.checkout_file(@repo.current_branch, files)\n repo.add(files)\n end\n end",
"def add_torrent_file filename, filedump, options={}\n filedump_enc = Base64.encode64(filedump)\n @con.call 'core.add_torrent_file', filename, filedump_enc, options, {}\n end",
"def add( file, number )\n\t\t@files[ number ] = file\n\tend",
"def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end",
"def copy_file(src_file, dest_file)\n Dir.chdir(@workdir_path) do\n FileUtils.mkdir_p(File.dirname(dest_file)) unless File.directory?(File.dirname(dest_file))\n FileUtils.cp(ROOT_DIR.join(src_file), dest_file)\n end\n end",
"def append_line_to_file(filename, line)\n FileUtils.touch(filename)\n File.open(filename, 'a') do |f|\n f.puts line\n end\nend",
"def add_file(file)\n raise FileError, 'Piece length must be greater than 0' if @data['info']['piece length'] <= 0\n\n if @data['info'].key?('name') && @data['info'].key?('length')\n @data['info']['files'] = []\n @data['info']['files'] << {\n 'path' => [@data['info']['name']],\n 'length' => @data['info']['length']\n }\n @data['info'].delete('name')\n @data['info'].delete('length')\n end\n\n if @data['info'].key?('files')\n @data['info']['files'] << {\n 'path' => file.split('/'),\n 'length' => ::File.size(file)\n }\n @data['info']['pieces'] += hash_file(file, @data['info']['piece length'])\n return\n end\n\n @data['info']['name'] = ::File.basename(file)\n @data['info']['length'] = ::File.size(file)\n @data['info']['pieces'] = hash_file(file, @data['info']['piece length'])\n end",
"def touch(filename)\n unless in_zip?\n FileUtils.touch current_dir.join(filename)\n else\n Zip::File.open(current_zip) do |zip|\n # zip.file.open(filename, 'w') {|_f| } #HAXX this code creates an unneeded temporary file\n zip.instance_variable_get(:@entry_set) << Zip::Entry.new(current_zip, filename)\n end\n end\n\n ls\n move_cursor items.index {|i| i.name == filename}\n end",
"def append_file(relative_destination, data)\r\n path = destination_path(relative_destination)\r\n File.open(path, 'ab') { |file| file.write(data) }\r\n end",
"def save_file(file, name = '')\n if name.size > 0\n filename = name + File.extname(file[:filename])\n else\n filename = file[:filename]\n end\n filename = filename.wiki_filename # convert to wiki friendly name\n ext = File.extname(filename)\n filename = File.basename(filename, ext).gsub('.','-')+ext.downcase #remove periods from basename, messes up route matching\n\n new_file = verify_file_under_repo(File.join(@attach_dir, filename))\n\n FileUtils.mkdir_p(@attach_dir) if !File.exists?(@attach_dir)\n f = File.new(new_file, 'w')\n f.write(file[:tempfile].read)\n f.close\n\n commit_message = \"uploaded #{filename} for #{@basename}\"\n begin\n $repo.add(new_file)\n $repo.commit(commit_message)\n rescue\n nil\n end\n end",
"def copy_data_file\n copy_or_move(@file_data_to_write, file_path)\n end",
"def copy_data_file\n copy_or_move(@file_data_to_write, file_path)\n end",
"def add_file_from_url(url, skip_file_characterisation)\n valid_file=false\n file = fetch_file_from_url(url)\n if (file)\n add_file(file, skip_file_characterisation)\n else\n false\n end\n end",
"def preform_copy_file\n @destination_files.each do |destination|\n copy_file(@sources.pop, destination)\n end\n end",
"def copy_file(source_file, dest_file, settings)\n\tFileUtils.cp_r(source_file, dest_file)\nend",
"def write_file(filename)\n File.open(filename, \"w\") do |f|\n self.write(f)\n end\n end",
"def copy_item(fname)\n src = source + fname\n if src.directory?\n copy_dir(fname)\n else\n copy_doc(fname)\n end\n end",
"def add_file(file)\n logger.info(\" ########### add file\")\n if (file.nil?)\n logger.error(\"file is nil\")\n self.original_filename = nil\n self.has_attached_file = false\n return false\n elsif (!check_file?(file))\n logger.error(\"error uploading file\")\n self.original_filename = nil\n self.has_attached_file = false\n\n return false\n else\n self.add_file_datastream(file, :label => file.original_filename, :mimeType => file.content_type, :dsid => 'content', :controlGroup => 'M')\n self.original_filename = file.original_filename\n self.mime_type = file.content_type\n self.has_attached_file = true\n end\n return true\n end",
"def open_file(filename)\n begin\n f = File.open filename, (File::WRONLY | File::APPEND)\n f.sync = true\n rescue Errno::ENOENT\n return nil\n end\n f\n end",
"def pushFile (file_path)\n if File.file?(file_path)\n file = File.open(file_path, \"rb\") # read file contents into string\n @commands.push(file.read)\n file.close # release the file\n end\n end",
"def create(filename)\n @filename = filename\n time = Time.now\n @@files[@filename] = time \n puts \"A new file: #{@filename} has been created by #{@username} at #{time}.\"\n end",
"def add!()\n git \"add #{@path}\"\n end",
"def copy(file, new_basename = nil, pathtype: :tree)\n filename = new_basename || File.basename(file)\n path = store_path(filename)\n File.open(path, 'wb') { |f| f.write(File.new(file).read) }\n file_path path, pathtype\n end",
"def file(filename)\n check_file! filename\n\n File.new(filename)\n end",
"def copy_file(src, dst)\n File.open(src) do |fin|\n File.open(dst, 'w') do |fout|\n fout.write(fin.read)\n end\n end\n end",
"def add_file(file, line = T.unsafe(nil), has_comments = T.unsafe(nil)); end",
"def add_file(file, skip_fits)\n if file.class == ActionDispatch::Http::UploadedFile\n file_object = file.tempfile\n file_name = file.original_filename\n mime_type = file.content_type\n elsif file.class == File\n file_object = file\n file_name = Pathname.new(file.path).basename.to_s\n mime_type = mime_type_from_ext(file_name)\n else\n return false\n end\n\n self.add_file_datastream(file_object, label: file_name, mimeType: mime_type, dsid: 'content')\n set_file_timestamps(file_object)\n self.checksum = generate_checksum(file_object)\n self.original_filename = file_name\n self.mime_type = mime_type\n self.size = file.size\n self.file_uuid = UUID.new.generate\n unless skip_fits\n self.add_fits_metadata_datastream(file)\n end\n true\n end"
] | [
"0.7280785",
"0.7280785",
"0.67722666",
"0.6755351",
"0.6636438",
"0.65272945",
"0.64990014",
"0.6490678",
"0.64827275",
"0.64653426",
"0.64012533",
"0.6349266",
"0.63392943",
"0.6336141",
"0.6332972",
"0.6309191",
"0.63026386",
"0.62867916",
"0.6258293",
"0.6233408",
"0.62215286",
"0.6219861",
"0.621231",
"0.621231",
"0.6179143",
"0.6149107",
"0.61052245",
"0.60101986",
"0.5962878",
"0.59522724",
"0.59230953",
"0.59155786",
"0.58943903",
"0.5878471",
"0.5843179",
"0.5812783",
"0.5795713",
"0.57826114",
"0.57707065",
"0.5732329",
"0.5727523",
"0.5725835",
"0.5719364",
"0.5709471",
"0.56938857",
"0.56864274",
"0.5650984",
"0.56387675",
"0.56244403",
"0.56241995",
"0.56217563",
"0.5600248",
"0.5583912",
"0.55611646",
"0.5540139",
"0.5536547",
"0.55310756",
"0.5530376",
"0.55222356",
"0.5504918",
"0.5479669",
"0.5457963",
"0.5450213",
"0.54450405",
"0.5425156",
"0.5412312",
"0.5399303",
"0.53813094",
"0.53799266",
"0.537908",
"0.53736144",
"0.53733903",
"0.53601176",
"0.5360018",
"0.5356885",
"0.53495115",
"0.5343685",
"0.5341816",
"0.5330882",
"0.53283054",
"0.5327658",
"0.53256595",
"0.5317244",
"0.53111535",
"0.53111535",
"0.5308754",
"0.53073454",
"0.5305363",
"0.5273795",
"0.52710766",
"0.526057",
"0.5259878",
"0.5254769",
"0.5249656",
"0.52423334",
"0.52353126",
"0.5224667",
"0.52246237",
"0.522269",
"0.5216524"
] | 0.6749832 | 4 |
Removes the file with the given filename from the working copy. When this method is executed, the file should no longer be present on the disk. | def remove(filename)
not_implemented('remove')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy_file\n FileUtils.rm(full_filename) if File.exists?(full_filename)\n end",
"def remove(filename); end",
"def remove_file(name)\n @files.delete_at(name) if @files[name]\n end",
"def remove(filename)\n send_request(FXP_REMOVE, :string, filename)\n end",
"def remove_file\n return unless file_exists?\n\n s3_object(false).delete\n rescue => e\n Rails.logger.error \"Unable to delete file #{self.filename}: #{e.message}\"\n end",
"def delete(filename)\n File.delete File.join(@base_path, filename)\n end",
"def remove file\n file.delete\n @files -= [file]\n end",
"def rm_file(file)\n @files.delete(file.path)\n end",
"def rm_file(file)\n @files.delete(file.path)\n end",
"def remove_content\n File.unlink(filename) if File.exist?(filename)\n end",
"def remove_file(filename, options={})\n end",
"def remove_file(path)\n FileUtils.rm_f(path)\n end",
"def remove_file(path)\n FileUtils.rm_f(path)\n end",
"def destroy_file\n File.delete full_file_path\n rescue\n end",
"def delete_uploaded_file\r\n return unless file_exists?\r\n File.delete(full_path)\r\n remove_empty_directory\r\n @saved_full_path = nil\r\n end",
"def delete\n File.delete(file_name)\n rescue\n # ignore\n end",
"def delete_file(filename)\n begin\n File.delete(filename)\n rescue Exception => e\n puts e.message\n end\n end",
"def delete_file(filename)\r\n DeleteFile.new(filename)\r\n end",
"def deleteFile(filePath, dryRun)\n #N Without this, the deletion command won't be run at all\n sshAndScp.deleteFile(filePath, dryRun)\n end",
"def remove!\n FileUtils.rm(File.join(remote_path, remote_file))\n end",
"def remove!\n with_callbacks(:remove) do\n delete_file\n @file = nil\n @cache_id = nil\n end\n end",
"def remove_file_if_exists(file)\n File.delete file if File.exists? file\n end",
"def remove_file(file)\n File.delete(file) if File.exist?(file)\nend",
"def deleteFile(filePath, dryRun)\n #N Without this, the required ssh command to delete a file won't be (optionally) executed.\n ssh(\"rm #{filePath}\", dryRun)\n end",
"def delete_file\n File.unlink file\n end",
"def delete_file\n File.unlink file\n end",
"def del_file( file_path )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_rm_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} rm #{file_path}\"\n log.info(x) { \"[git] file remove command => #{git_rm_cmd}\" }\n %x[#{git_rm_cmd}];\n log.info(x) { \"[git] has removed #{file_path} from repo and working copy.\" }\n\n end",
"def remove_file(path, config = {})\n return unless behavior == :invoke\n path = File.expand_path(path, destination_root)\n\n say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)\n ::FileUtils.rm_rf(path) if !options[:pretend] && File.exist?(path)\n end",
"def destroy_file\n FileUtils.rm full_filename\n # remove directory also if it is now empty\n Dir.rmdir(File.dirname(full_filename)) if (Dir.entries(File.dirname(full_filename))-['.','..']).empty?\n rescue\n logger.info \"Exception destroying #{full_filename.inspect}: [#{$!.class.name}] #{$1.to_s}\"\n logger.warn $!.backtrace.collect { |b| \" > #{b}\" }.join(\"\\n\")\n end",
"def remove_if_present(filename)\n begin\n File.unlink(filename)\n rescue Errno::ENOENT\n return false\n end\n return true\n end",
"def remove filename\n return false unless source_hash.key?(filename)\n source_hash.delete filename\n true\n end",
"def purge\n ::FileUtils.rm(@fname)\n end",
"def delete(filename); end",
"def destroy_file\n Qiniu::RS.delete(qiniu_config[:bucket_name], full_filename)\n end",
"def delete_file\n begin\n File.delete(stored_file_path)\n rescue => e\n logger.error(\"Could not delete #{stored_file_path}. Ignored.\")\n logger.error(e)\n end\n end",
"def del\n File.delete(@file)\n end",
"def remove_file(file)\n return nil if file.blank?\n\n FileUtils.rm(file, force: true) if file_exists?(file)\n end",
"def remove_storage_file\n FileUtils.rm(file_path)\n end",
"def deleteIgnoreFile(fileName)\n @fileAccess.deleteIgnoreFile(fileName)\n end",
"def remove_file(file)\n index = @repo.index\n index.remove file\n\n @affected_files << file\n end",
"def remove_file\n @assignment = Assignment.find(params[:id])\n if ((@assignment.facebook_user.id == @fb_user.id) or (@assignment.is_author? @fb_user))\n @assignment.remove_file(params[:path])\n ZipWorker.asynch_zip_assignment(:id => @assignment.id)\n render :partial => \"file_removed\", :layout => false\n end\n end",
"def delete_file name\n filename = \"#{RAILS_ROOT}/#{@@dir}/#{name}\" \n File.delete filename if File.exists? filename\n end",
"def deleteUploadFile\n\n filepath = Rails.root.join(path, file_name)\n\n if File.exist? filepath \n File.delete filepath\n end\n\n end",
"def clean_local_file\n File.delete(@file_path) if File.exist? @file_path\n end",
"def remove_local_file(file, user)\n logger.debug(\"removing local file #{file.uid} by user #{user.dxuser}\")\n UserFile.transaction do\n # Use find_by(file.id) since file.reload may raise ActiveRecord::RecordNotFound\n file = UserFile.find_by(id: file.id)\n return unless file\n\n Event::FileDeleted.create_for(file, user)\n file.destroy!\n end\n end",
"def remove_file(file)\n file = File.expand_path(file, @app.root)\n \n if @local_data.has_key?(file)\n @app.cache.remove(:raw_template, file)\n @local_data.delete(file) \n end\n end",
"def delete_file(file_name)\n fail 'No Structure ID defined for structure. Can\\'t delete file' if @structure.id.nil?\n\n data = Hashie::Mash.new\n data.structure_id = @structure.id\n data.file_name = file_name\n\n push_file('api/remove_file', MultiJson.dump(data))\n end",
"def remove_file(file)\n path = file_to_path(file)\n return false unless path\n \n path = normalize_path(path)\n if @pages.has_key?(path)\n page(path).delete()\n @pages.delete(path)\n end\n end",
"def remove(uploaded_file, context)\n uploaded_file.delete\n end",
"def remove_file\n\n @source_files_id = params[:source] + '_files'\n @source = TaliaCore::Source.find(N::URI.from_encoded(params[:source]))\n\n TaliaFile.find(params[:talia_file_uri]).destroy\n end",
"def remove!(filename, &callback)\n wait_for(remove(filename, &callback))\n end",
"def destroy\n file&.delete\n end",
"def remove_created_file(file_path)\n if file_path && File.exists?(file_path)\n File.delete(file_path)\n end\nend",
"def delete_file \n #pp \"deleting file_asset: path is\" + full_filepath\n File.delete(full_filepath) if File.exists?(full_filepath)\n end",
"def drop\r\n\t\t\tif [email protected]?\r\n\t\t\t\tfilename=@filename\r\n\t\t\t\tself.close if [email protected]?\r\n\t\t\t\tif !FileUtils.rm(filename)\r\n\t\t\t\t\traise \"Error unlinking file #{filename}: $!\\n\"\r\n\t\t\t\t\treturn\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\t\treturn true\r\n\t\tend",
"def destroy_file\n object = self.class.bucket.objects.find(full_filename)\n object.destroy\n end",
"def delete!\n safe_close\n File.delete(@file_path)\n end",
"def remove_file_if_present(path)\n if File.exist?(path)\n info \"unlinking #{path}\"\n File::unlink(path)\n end\n end",
"def delete(filename)\n within_source_root do\n FileUtils.mkdir_p File.dirname(filename)\n FileUtils.touch filename\n end\n \n generate { File.should_not exist(filename) }\n end",
"def delete\n @file = nil\n # file.delete\n end",
"def delete_file(file_name)\n dst_path = \"#{self.path}#{file_name}\"\n if self.class.curr_host == host\n begin\n File.delete(dst_path)\n rescue Errno::EISDIR\n FileUtils.rm_r(dst_path)\n rescue Errno::ENOENT\n end\n else\n cmd = \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"rm -rf #{dst_path.shellescape}\\\"\"\n r = `#{cmd} 2>&1`\n raise r if $?.exitstatus != 0\n \n cmd = \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"ls -la #{dst_path.shellescape}\\\"\"\n r = `#{cmd} 2>/dev/null`\n raise \"Path #{dst_path} not deleted\" unless r.empty?\n end\n end",
"def delete_file(file_name)\n dst_path = \"#{self.path}#{file_name}\"\n if self.class.curr_host == host\n begin\n File.delete(dst_path)\n rescue Errno::EISDIR\n FileUtils.rm_r(dst_path)\n rescue Errno::ENOENT\n end\n else\n cmd = \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"rm -rf #{dst_path.shellescape}\\\"\"\n r = `#{cmd} 2>&1`\n raise r if $?.exitstatus != 0\n \n cmd = \"ssh -q -oBatchMode=yes -oStrictHostKeyChecking=no #{self.host} \\\"ls -la #{dst_path.shellescape}\\\"\"\n r = `#{cmd} 2>/dev/null`\n raise \"Path #{dst_path} not deleted\" unless r.empty?\n end\n end",
"def delete_file(file)\n delete_attachment(file)\n end",
"def remove_created_file(file_path)\n File.delete(file_path) if file_path && File.exist?(file_path)\nend",
"def remove_file src\n src = src.src if src.respond_to? :src # if passed an OpenStruct e.g.\n trace { \"remove_file: removing file '#{src}' [nuget model: package]\" }\n @files = @files.reject { |f| f.src == src }\n end",
"def remove_file(id)\n\n # Get file name\n file_name = \"#{Repository.data_dir}#{id}.json\"\n\n\t\t# Check if file exists\n\t\tif File.exists?(file_name)\n\t\t\t# if so delete\n\t\t\tFile.delete(file_name)\n\t\telse\n\t\t\tDebug.add(\"[WARNING] #{id}.json not found\")\n\t\tend\n end",
"def rm(file)\n cmd_exec(\"rm -rf #{file}\")\n end",
"def safe_unlink filename\n return unless filename\n begin\n File.unlink filename\n rescue => e\n Rails.logger.warn(\"Cannot unlink temp file \" + filename) if Rails.logger && Rails.logger.warn?\n end\n end",
"def delete_file(file_path)\n if Rails.env.production? && file_exists?(file_path)\n bucket.object(file_path).delete\n end\n end",
"def delete_result_file\n return unless result_path.present?\n file_path = result_file_path\n File.delete(file_path) if File.exist?(file_path)\n end",
"def destroy_dirty_file!(file)\n system(\"trashtrash #{file}\")\n end",
"def delete_uploaded_file(new_file)\n if version_name.blank? && Refinery::PhotoGallery.delete_uploaded_file\n filename_to_delete = File.join(Rails.root.to_s,Refinery::PhotoGallery.photo_gallery_dir_relative_to_root, store_dir, filename )\n File.delete(filename_to_delete)\n end\n end",
"def deleteFile(file_path)\n puts \"Delete file: \" + file_path.to_s\n File.delete(file_path) if File.exist?(file_path)\nend",
"def destroy_file\n start_ssh do |ssh|\n ssh.exec!(\"rm #{e full_filename}\")\n dir = File.dirname(full_filename)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n dir = File.dirname(dir)\n ssh.exec!(\"find #{e dir} -maxdepth 0 -empty -exec rm -r {} \\\\;\")\n end\n end",
"def delete_file(filename)\n http.delete([204,404], luwak, escape(filename))\n true\n end",
"def reset\n FileUtils.remove_file(@path)\n end",
"def delete_file\n return false if !@file\n FileUtils.rm @file if File.file? @file\n return true\n end",
"def destroy\n remove_files(@path + \"*\")\n end",
"def drop\n File.unlink @file if File.exist?(@file)\n self\n end",
"def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end",
"def delete_file(dst, name)\n ori_file = dst.join(name)\n File.delete(ori_file) if File.exist?(ori_file)\n delete_hex(get_prefix_from_name(name))\n name\n end",
"def delete_file(filepath)\n begin\n File.delete(filepath) if filepath\n puts %|Deleted the file \"#{filepath}\"| if @debug_logging_enabled\n rescue Exception => e\n puts %|Failed to delete file \"#{filepath}\": #{e.inspect}|\n end\n end",
"def rm\n FileUtils.rm path if File.exist?(path)\n end",
"def remove_file(rev, full_path, expected_revision_int)\n unless file_exists?(rev, full_path)\n raise Repository::FileDoesNotExistConflict, full_path\n end\n act_rev = get_latest_revision\n if act_rev.revision_identifier != expected_revision_int.to_i\n raise Repository::FileOutOfSyncConflict, full_path\n end\n filename = File.basename(full_path)\n path = File.dirname(full_path)\n files_set = rev.files_at_path(path)\n rev.files.delete_at(rev.files.index(files_set[filename])) # delete file, but keep contents\n rev\n end",
"def remove_file!\n begin\n super\n rescue Fog::Storage::Rackspace::NotFound\n self.file = nil\n self.send(:write_attribute, :file, nil)\n end\n end",
"def delete\n ::File.unlink(@path)\n end",
"def delete_file\n @file = []\n end",
"def delete\n FileUtils.rm(self.path) if exists?\n end",
"def unmap_file(path)\n path = path.to_s\n @files.delete path\n end",
"def unmap_file(path)\n path = path.to_s\n @files.delete path\n end",
"def remove_watch(file)\n @files.delete(file)\n end",
"def delete_file!(file_id)\n execute!(api_method: drive.files.delete, parameters: { fileId: file_id })\n end",
"def destroy\n File.unlink(@resource[:path])\n Puppet.debug \"deleted file #{@resource[:path]}\"\n end",
"def undo\n if(File.exist?(@newName) and @hasExecuted == true)\n File.rename(@newName, @filepath)\n @hasExecuted=false\n end\n end",
"def _delete(uploaded_file, context)\n remove(uploaded_file, context)\n end",
"def rm(path)\n file = scope.get(path)\n return if !file\n file.remove!\n end",
"def clear_redo(filename)\n filename ||= Doing.setting('doing_file')\n backups = Dir.glob(\"undone*___#{File.basename(filename)}\", base: backup_dir).sort.reverse\n backups.each do |file|\n FileUtils.rm(File.join(backup_dir, file))\n end\n end",
"def remove_file(file_id)\n\t\t@client ||= api_client()\n\n\t\tif file_id.nil?\n\t\t\tRails.logger.info(\"File id is nil. WTF man?\")\n\t\t\treturn false\n\t\tend\n\n\t \tresult = @client.execute(\n\t \t:api_method => @drive.files.delete,\n\t \t:parameters => { 'fileId' => file_id }\n \t)\n\n\t \tif result.status != 200 or result.status != 204\n\t \tRails.logger.info(\"An error occurred: #{result.inspect}\")\n\t \treturn false\n\t \tend\n\n\t \treturn true\n\tend",
"def remove!\n messages = []\n transferred_files do |local_file, remote_file|\n messages << \"#{storage_name} started removing '#{ local_file }'.\"\n end\n Logger.message messages.join(\"\\n\")\n\n FileUtils.rm_r(remote_path)\n end",
"def remove_file(file)\n if File.exists?(file) && !File.directory?(file)\n rm_rf file\n end\nend"
] | [
"0.74631965",
"0.72423965",
"0.7238968",
"0.71797854",
"0.7156031",
"0.70848185",
"0.7041913",
"0.6966986",
"0.6947973",
"0.69134533",
"0.6902328",
"0.6859245",
"0.6859245",
"0.68490314",
"0.6793277",
"0.67878145",
"0.6775145",
"0.67609227",
"0.6740448",
"0.671225",
"0.6709886",
"0.67049134",
"0.66995096",
"0.669009",
"0.6677895",
"0.6677895",
"0.66776556",
"0.65999013",
"0.65809655",
"0.65720814",
"0.65606517",
"0.6554656",
"0.6540605",
"0.65373105",
"0.6536584",
"0.6506508",
"0.65007603",
"0.6483044",
"0.6458594",
"0.6457327",
"0.64310765",
"0.64222175",
"0.6415522",
"0.63997316",
"0.63987243",
"0.63878024",
"0.63772213",
"0.63734436",
"0.6368373",
"0.63600105",
"0.634511",
"0.63318706",
"0.6327754",
"0.6326656",
"0.6315798",
"0.630938",
"0.63057166",
"0.62835425",
"0.6280149",
"0.62784934",
"0.62733597",
"0.62733597",
"0.6206297",
"0.6198278",
"0.6192797",
"0.6177153",
"0.6167213",
"0.6155407",
"0.61552036",
"0.6095824",
"0.6094544",
"0.6093567",
"0.6085824",
"0.6065569",
"0.60531807",
"0.60406154",
"0.6036881",
"0.6034599",
"0.6028193",
"0.6011892",
"0.60062474",
"0.6003285",
"0.5999303",
"0.5997977",
"0.5987403",
"0.5975853",
"0.5972059",
"0.59504145",
"0.59474003",
"0.59474003",
"0.592889",
"0.59271455",
"0.592525",
"0.5910981",
"0.59000975",
"0.5887043",
"0.5877155",
"0.5853527",
"0.5849339",
"0.58377725"
] | 0.693963 | 9 |
Moves the file with the given filename to a new location. When this method is executed, the original file should no longer be present on the disk. | def move(src, dst)
not_implemented('move')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move\n display_change\n File.move(@real_path, new_path, false)\n end",
"def execute()\r\n FileUtils.mv(@OldFilePath, @NewFilePath)\r\n end",
"def rename_file\n return unless filename_changed?\n\n old_full_filename = [base_path, filename_was].join(\"/\")\n\n object = self.class.bucket.objects.find(old_full_filename)\n new_object = object.copy(:key => full_filename, :acl => attachment_options[:acl])\n object.destroy\n true\n end",
"def rename_file\n return unless @old_filename and @old_filename != full_filename\n start_ssh do |ssh|\n if save_attachment?\n ssh.exec!(\"rm #{e @old_filename}\")\n else\n ssh.exec!(\"mv #{e @old_filename} #{e full_filename}\")\n end\n end\n @old_filename = nil\n true\n end",
"def undo()\r\n File.rename(@NewFileName, @OldFileName)\r\n end",
"def move!(new_path)\n if exists?\n FileUtils.mv(path, new_path) unless File.identical?(new_path, path)\n else\n File.open(new_path, \"wb\") { |f| f.write(read) }\n end\n end",
"def execute()\r\n File.rename(@OldFileName, @NewFileName)\r\n end",
"def rename_file\n return unless @old_filename && @old_filename != full_filename\n if save_attachment? && File.exists?(@old_filename)\n FileUtils.rm @old_filename\n elsif File.exists?(@old_filename)\n FileUtils.mv @old_filename, full_filename\n end\n @old_filename = nil\n true\n end",
"def undo()\r\n oldname = @FilePath.basename\r\n @CopiedFilePath = \"#{@CopiedFilePath}/#{oldname}\"\r\n origfolder = @FilePath.dirname\r\n @FilePath = origfolder\r\n FileUtils.mv(@CopiedFilePath, @FilePath)\r\n end",
"def undo\n if(File.exist?(@newName) and @hasExecuted == true)\n File.rename(@newName, @filepath)\n @hasExecuted=false\n end\n end",
"def move_to(new_path, new_file_name = nil)\n res = false\n new_file_name ||= file_name\n current_user_role_names.each do |role_name|\n curr_path = file_path_for role_name: role_name\n next unless File.exist?(curr_path)\n\n self.path = new_path if new_path\n self.file_name = new_file_name\n self.valid_path_change = true\n\n transaction do\n move_from curr_path\n save!\n res = true\n end\n break\n end\n\n raise FsException::Action, \"Failed to move file to #{new_path}/#{new_file_name}\" unless res\n\n res\n end",
"def moveOldFile(name)\n return unless File.file?(name)\n\n count = 0\n while true\n count += 1\n nfn = \"#{name}.#{count}\"\n\n if !File.file?(nfn)\n File.rename(name, nfn)\n break\n end\n end\nend",
"def undo()\r\n #need to manipulate strings by taking file name off of OldFilePath and adding it onto NewFilePath\r\n oldname = @OldFilePath.basename\r\n @NewFilePath = \"#{@NewFilePath}/#{oldname}\"\r\n origfolder = @OldFilePath.dirname\r\n @OldFilePath = origfolder\r\n\r\n FileUtils.mv(@NewFilePath, @OldFilePath)\r\n end",
"def rename_file(old_filename,new_filename)\n begin\n File.rename(old_filename,new_filename)\n rescue Exception => e\n puts e.message\n end\n end",
"def move_origional_file\n if File.exist? @origional_file\n $logger.info \" moving previous (orig->processed)\\n #{@origional_file} ->\\n #{processed_file}\"\n FileUtils.mkdir_p(File.dirname(processed_file))\n FileUtils.mv @origional_file, processed_file\n end\n end",
"def move_file\n\n end",
"def rename(new_filename)\n @filename = new_filename\n end",
"def move(file, new_basename = nil, pathtype: :tree)\n filename = new_basename || File.basename(file)\n path = store_path(filename)\n FileUtils.mv File.expand_path(file), path\n file_path path, pathtype\n end",
"def move_file(file, destination)\n return nil if file.blank? || destination.blank?\n\n FileUtils.mv(file, destination, force: true) if file_exists?(file)\n end",
"def mv!( from_path, to_path )\r\n got = @ndev.rpc.command( \"file rename #{from_path} #{to_path}\" )\r\n return true if got.nil? # got no error\r\n raise IOError, got.text\r\n end",
"def backup_existing_file(file_path)\n FileUtils.move(file_path, \"#{file_path}-#{Time.now.to_i.to_s}\")\n end",
"def rename(to) File.rename(path, to) end",
"def move_file(src, dest)\n FileUtils.mv(src, dest, force: false)\nrescue Errno::EACCES\n FileUtils.cp_r(src, dest)\n FileUtils.rm_rf(src)\nend",
"def save_as!(filename)\n @new_filename = filename\n save!\n self\n end",
"def execute\n if(File.exist?(@filepath) and @hasExecuted == false)\n File.rename(@filepath, @newName)\n @hasExecuted=true\n end\n end",
"def rename_file(old_file, new_file)\n if session.type == \"meterpreter\"\n return (session.fs.file.mv(old_file, new_file).result == 0)\n else\n if session.platform == 'windows'\n cmd_exec(%Q|move /y \"#{old_file}\" \"#{new_file}\"|) =~ /moved/\n else\n cmd_exec(%Q|mv -f \"#{old_file}\" \"#{new_file}\"|).empty?\n end\n end\n end",
"def rename_uploaded_file\r\n return unless @uploaded_file.nil?\r\n if file_exists? and full_path != full_path_from_current_attributes\r\n ensure_directory_exists\r\n File.rename(full_path, full_path_from_current_attributes)\r\n remove_empty_directory\r\n @saved_full_path = full_path_from_current_attributes\r\n end\r\n end",
"def mv(from_location, to_location)\n @client.file_move(from_location, to_location)\n rescue\n puts $! if @@verbose\n nil\n end",
"def swap(uploaded_file)\n update(uploaded_file)\n uploaded_file\n end",
"def write_file\n\n # file_edited is false when there was no match in the whole file and thus no contents have changed.\n if file_edited\n backup_pathname = original_pathname + \".old\"\n FileUtils.cp(original_pathname, backup_pathname, :preserve => true)\n File.open(original_pathname, \"w\") do |newfile|\n contents.each do |line|\n newfile.puts(line)\n end\n newfile.flush\n end\n end\n self.file_edited = false\n end",
"def mv(srcpath,dstpath)\n FileUtils.mv(srcpath,dstpath)\n end",
"def rename_original_file\n new_path = \"#{CSV_PWD}/old_#{CSV_FILE_NAME}\"\n File.rename(ORIGINAL_FULL_PATH, new_path)\n new_path\n end",
"def move_to(new_path, permissions=nil, directory_permissions=nil, keep_filename=false)\n return if self.empty?\n new_path = File.expand_path(new_path)\n\n mkdir!(new_path, directory_permissions)\n move!(new_path)\n chmod!(new_path, permissions)\n self.file = {tempfile: new_path, filename: keep_filename ? original_filename : nil, content_type: declared_content_type}\n self\n end",
"def mv(src, dst)\n FileUtils.mv(src, dst, :verbose => verbose?)\n end",
"def rename oldname, newname\n add \"mv #{oldname} #{newname}\", check_file(newname)\n end",
"def replace_file!(tmp_file_path)\n # Retain the current file name and path\n orig_path = path\n orig_file_name = file_name\n\n blanked_path = path || ''\n if respond_to? :archive_file\n orig_archive_file = archive_file\n orig_file_path = File.join(blanked_path, orig_archive_file, orig_file_name)\n else\n orig_file_path = File.join(blanked_path, orig_file_name)\n end\n file_path, role_name = file_path_and_role_name\n new_trash_path = trash_path\n\n unless file_path\n raise FsException::Action, \"Replacing file not allowed. File not accessible with current roles: #{file_path}\"\n end\n\n orig_fs_path = Filesystem.nfs_store_path(role_name, container, path, file_name, archive_file: orig_archive_file)\n self.current_role_name = role_name\n\n transaction do\n # Move the current file to trash. Prevent removal of an empty directory\n # since the replacement will go back into it\n move_to_trash! remove_empty_dir: false\n\n unless self.class.trash_path?(path)\n raise FsException::Action, \"Replacing file did not move original to trash: #{orig_file_path}\"\n end\n\n trash_file_path = Filesystem.nfs_store_path(role_name, container, new_trash_path, file_name)\n unless File.exist?(trash_file_path)\n raise FsException::Action,\n \"Replacing file did not move the actual file to the trash filesystem location: #{trash_file_path}\"\n end\n\n # Resetting file name and generating new hash, mime type, etc\n self.path = orig_path\n self.file_name = orig_file_name\n self.archive_file = orig_archive_file if respond_to? :archive_file\n self.valid_path_change = true\n\n rep_fs_path = Filesystem.nfs_store_path(role_name, container, path, file_name,\n archive_file: orig_archive_file)\n unless rep_fs_path == orig_fs_path\n raise FsException::Action, \"Replacement file targeting wrong location: #{rep_fs_path}\"\n end\n\n # Move the temporary file to the original location\n move_from tmp_file_path\n\n self.file_hash = nil\n analyze_file!\n self.file_hash ||= ContainerFile.hash_for_file(rep_fs_path)\n\n # Remove the trash file\n Filesystem.remove_trash_file trash_file_path\n\n save!\n end\n\n true\n end",
"def move_temp_to_destination\n if !File.exist? temp_file\n $logger.info \"no moving, transcode didn't complete\"\n return\n end\n $logger.info \" moving (temp->destination)\\n #{temp_file} ->\\n #{destination_file}\"\n FileUtils.mv temp_file, destination_file\n end",
"def move_original\n original_image = local_file_name(:original)\n unless File.rename(upload_temp_file, original_image)\n raise(SystemCallError.new(\"Try again.\"))\n end\n\n FileUtils.chmod(0o644, original_image)\n true\n rescue SystemCallError\n # Use Kernel.system to allow stubbing in tests\n unless Kernel.system(\"cp\", upload_temp_file, original_image)\n raise(:runtime_image_move_failed.t(id: id))\n end\n\n true\n end",
"def rename(file, newname)\n raise \"Sorry... 'AimsCalc rename' isn't implemented yet.\"\nend",
"def rename_given_file\n PS2.rename(@filename, @options)\n end",
"def rename_file(existing_file, file_name_uuid, is_real_run)\n # create all needed information\n existing_path = existing_file\n existing_name = File.basename(existing_path)\n existing_name_without_ext = File.basename(existing_path, File.extname(existing_path))\n existing_dir = File.dirname(existing_path)\n existing_is_new = existing_name_without_ext.end_with?('Z')\n\n new_name = file_name_uuid\n new_path = File.join(existing_dir, new_name)\n new_name_without_ext = File.basename(new_name, File.extname(new_name))\n new_dir = existing_dir\n\n # check each possible situation\n if existing_is_new && File.exist?(new_path)\n # existing file is already new format, nothing to change\n {\n new_file: existing_path,\n moved: false\n }\n elsif !existing_is_new && File.exist?(new_path) && File.exist?(existing_path)\n # both new and old formats exist, do nothing\n\n @logger.info(@class_name) do\n \"Found equivalent old and new file names, no action performed. Old: #{existing_path} New: #{new_path}.\"\n end\n\n {\n new_file: new_path,\n moved: false\n }\n else\n # file is in old format, file in new format does not exist\n\n @logger.info(@class_name) { \"Moving #{existing_path} to #{new_path}.\" } if is_real_run\n FileUtils.move(existing_path, new_path) if is_real_run\n\n unless is_real_run\n @logger.info(@class_name) {\n \"Dry Run: Would have moved #{existing_path} to #{new_path}.\"\n }\n end\n\n {\n new_file: new_path,\n moved: true\n }\n\n end\n end",
"def archive_incoming_file(filename, filepath)\n if ENV.key?(\"DIAVERUM_DO_NOT_USE_MV\")\n FileUtils.cp filepath, Paths.incoming_archive.join(filename)\n FileUtils.rm filepath\n else\n FileUtils.mv filepath, Paths.incoming_archive.join(filename)\n end\n end",
"def copy_to_backup\n FileUtils.cp(@original_file_path, @new_file_path)\n end",
"def mv(file)\n abort \"#{file} does not exist\" unless File.exist? file\n\n timestamp = Time.now.strftime(\"%F %H.%M.%S\")\n new_file = \"Screenshot #{timestamp}.#{File.extname(file).slice(1..-1)}\"\n new_path = File.join(destination_directory, new_file)\n new_dir = File.dirname(new_path)\n\n FileUtils.mkdir_p(new_dir) or abort \"Couldn't create #{new_dir}\"\n FileUtils.mv(file, new_path) or abort \"Coudln't move #{file} to #{new_path}\"\n\n new_path\n end",
"def file_update\n File.rename(file_path,\n File.join(File.dirname(file_path),\n File.basename(file_path).gsub(/_\\d+\\.txt/, \"_#{Time.now.to_i}.txt\")))\n end",
"def replace_file(filename, data)\n remove_file filename\n create_file filename, data\nend",
"def replace_file(filename, data)\n remove_file filename\n create_file filename, data\nend",
"def rename_file\n\n end",
"def move_file_to_path(src, dest_path, overwrite: false)\n dest = File.join(dest_path, File.basename(src))\n move_file(src, dest, overwrite: overwrite)\n end",
"def undo\n\t\tif Dir.exist?(\"#{parent_directory}/#{newname}\")\n\t\t\tif Dir.exist?(filePath)\n\t\t\t\tputs \"-'#{name_of_subject}' already exists in this directory\"\n\t\t\telse\n\t\t\t\tFile.rename(\"#{parent_directory}/#{newname}\", filePath)\n\t\t\t\tputs \"-'#{newname}' was renamed '#{name_of_subject}' \\n\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"-'#{newname}' does not exist in this directory \\n\"\n\t\tend\n\tend",
"def revert_file(filename,commit_id,repo=self.repo)\n post_revert(\"#{filename}\",commit_id,repo)\n end",
"def move_to dir=\"\"\n #TODO chmod!!!, работа с флагами\n return false if dir.empty?\n \n filename_target = File.join(dir, @name_target+@extention)\n\n begin\n FileUtils.mv(@filename, filename_target) \n rescue StandardError => e\n add_error e.full_message(@name+@extention) \n return false \n else\n @filename = filename_target\n @name = @name_target\n return true\n end\n end",
"def move_file (new_directory_path,file)\n FileUtils.mkdir_p new_directory_path if not File.exist? new_directory_path\n if File.exist? file and File.file? file\n if File.exist? new_directory_path + file\n puts \"# - File #{file} already exists. Skipping...\"\n FileUtils.rm file\n else\n puts \"# - Moving the file: #{file} to #{new_directory_path}...\" \n FileUtils.mv file, new_directory_path\n end\n else\n raise \"Error while moving file to #{LOG_OLD_DIR}\"\n end\nend",
"def mv!(to)\n files.map{|file| file.mv! to }\n end",
"def mv( dst, options = {} )\n # what does FileUtils.rm actually return? Glancing an the source, it\n # seems to only throw errors.\n FileUtils.mv( self, dst, **options )\n end",
"def mv srcpath, dstpath\n end",
"def shift_from(other)\n raise ArgumentError.new(other) unless other.kind_of?(self.class)\n unless File.ftype(other.path) == \"file\"\n raise ArgumentError.new(other)\n end\n dir = @path.dirname\n dir.mkpath unless dir.exist?\n FileUtils.mv(other.path, @path)\n end",
"def fix\n path = Rails.root.join(\"public/system/files/#{self.id}/original/#{self.file_file_name}\")\n Formatador.display_line(\"Uploading file at: [green]#{path}[/]\")\n if File.exists?(path)\n self.attached_file.store!(File.open(path))\n self.update_attribute(:attached_file, self.file_file_name)\n Formatador.display_line(\"[yellow]Done![/]\")\n else\n Formatador.display_line(\"[red]ERROR: [/]File does not exist!\")\n end\n end",
"def update_from_filename filename\n self.original_filename = filename\n self.valid?\n end",
"def move_to_target_directory!\n return if new_record? || !readable?\n\n src = diskfile\n self.disk_directory = target_directory\n dest = diskfile\n\n return if src == dest\n\n if !RedmicaS3::Connection.move_object(src, dest)\n Rails.logger.error \"Could not move attachment from #{src} to #{dest}\"\n return\n end\n\n update_column :disk_directory, disk_directory\n end",
"def touch(filename)\n File.open(filename, 'w') {}\n end",
"def move!(entry, dest_path)\n src_path = Wide::PathUtils.relative_to_base(base_path, entry.path)\n dest_path = Wide::PathUtils.relative_to_base(base_path, dest_path)\n\n cmd = cmd_prefix.push('mv', src_path, dest_path)\n shellout(Escape.shell_command(cmd))\n\n begin\n if($? && $?.exitstatus != 0)\n entry.move!(dest_path);\n end\n rescue\n raise CommandFailed.new(\"Failed to move file #{src_path} to #{dest_path} in the Mercurial repository in #{base_path}\")\n end\n end",
"def move_to(new_path)\n self.path = new_path\n self.save\n end",
"def rename(a)\n File.rename(@file,a)\n @file = a\n end",
"def execute()\r\n FileUtils.cp(@FilePath, @CopiedFilePath)\r\n File.delete(@FilePath) if File.exist?(@FilePath)\r\n end",
"def elegant_move(file_name, destination_name)\n # Generate full paths\n destination = \"#{ENV['HOME']}/#{destination_name}\"\n file = \"#{ENV['HOME']}/dotfiles/#{file_name}\"\n\n # If the destination already exists\n if (File.exists?(destination) or File.symlink?(destination))\n # If the destination has the same content as the file, skip\n if files_are_same(destination, file)\n puts \"#{file_name} - skipping\".yellow\n else\n # Create the backup dir if doesn't already exist\n `mkdir -p ~/.backup`\n\n # Else backup the old file\n backup_path = \".backup/#{destination_name}_#{Time.now.to_f}\"\n backup = \"#{ENV['HOME']}/#{backup_path}\"\n puts \"#{file_name} - moving old\".green\n # Ignore errors we may get in case of dodgy symlinks\n `mv #{destination} #{backup} 2> /dev/null`\n \n # Then link the new file\n symlink file, destination, :force => true, :verbose => false\n end\n else\n # Else link the new file\n puts \"#{file_name} - creating\".green\n symlink file, destination, :force => true, :verbose => false\n end\nend",
"def swap(other)\n unless File.ftype(other) == \"file\"\n raise ArgumentError.new(other)\n end\n dir = @path.dirname\n dir.mkpath unless dir.exist?\n FileUtils.mv(other, @path)\n FileUtils.symlink(@path, other)\n end",
"def upload_file(file_dir, orig_filename, aip_filename, type)\n @log.info 'Uploading file ' + orig_filename\n @log.info \"Renaming #{type} #{aip_filename} -> #{orig_filename}\"\n\n File.rename(file_dir + '/' + aip_filename,\n file_dir + '/' + orig_filename)\n file = File.open(file_dir + '/' + orig_filename)\n\n uploaded_file = Hyrax::UploadedFile.create(file: file)\n uploaded_file.save\n\n file.close\n\n uploaded_file\nend",
"def disk_mv(src_file, dst_file, options)\n mover = options[:git] ? 'git mv' : 'mv'\n command = \"#{mover} '#{src_file.path}' '#{dst_file.path}'\"\n system(command) || raise(InputError, \"#{command} failed\")\n end",
"def rename(old_name, new_name)\n move(old_name, new_name)\n end",
"def rename(file, destination)\n\t\tlogin_filter\n\t\tfile = namespace_path(file)\n\t\tdestination = namespace_path(destination)\n\t\[email protected](\"/cmd/rename#{file}\", {\"to_path\"=> destination, \"t\" => @token }).code == \"200\"\n\tend",
"def delete(filename)\n File.delete File.join(@base_path, filename)\n end",
"def file_move(from_path, to_path)\n params = {\n \"root\" => @root,\n \"from_path\" => format_path(from_path, false),\n \"to_path\" => format_path(to_path, false),\n }\n response = @session.do_post build_url(\"/fileops/move\", params)\n parse_response(response)\n end",
"def archive(file)\n FileUtils.mv(file, @archive_location)\n end",
"def mv_to_parsed(file_path)\n FileUtils.mv(file_path, @parsed_path)\n end",
"def make_old(mode=:rm) #mode=:rm or :save\n ## After introduction of dyntask, the default is to save the old file if existing\n if File.exist? @filename\n case mode\n when :save\n FileUtils.mkdir_p(File.join(File.dirname(@filename),\".save\"))\n FileUtils.mv(@filename,@filename_old=File.join(File.dirname(@filename),\".save\",File.basename(@filename)))\n when :rm\n FileUtils.rm(@filename)\n end\n end\n end",
"def update_file(dst, ori_name, file)\n ori_file = dst.join(ori_name)\n File.delete(ori_file) if File.exist?(ori_file)\n hex = update_hex(get_prefix_from_name(ori_name), new_hex())\n new_name = rename_with_file_type(file.original_filename, hex)\n write_to_file(file, dst.join(new_name))\n new_name\n end",
"def copy_or_move(original, target)\n if(@delete_original_file)\n begin\n FileUtils.move(original, target)\n rescue Errno::EACCES\n # Workaround for File.rename bug with JRuby (jira.codehaus.org/browse/JRUBY-3381),\n # based on the code from Lenny Marks 03/Jun/10.\n safe_copy original, target\n FileUtils.rm original\n end\n else\n # Delay can be enabled through enviroment\n if(delay_copies)\n DelayedCopier.cp(original, target)\n else\n safe_copy original, target\n end\n end\n end",
"def undo \n if(@hasExecuted==true and (File::exist?(@newPath)))\n FileUtils.cp_r(@newPath, @ogPath)\n FileUtils::rm_r(@newPath)\n @hasExecuted=false\n end\n end",
"def reopen_file!\n @file_contents = FileContents.new(file_path, @file_metadata)\n end",
"def move(from, to)\n @ctx.mv(@path + from, @path + to)\n end",
"def save(sourcepath, filename, host)\n saved_file_name = calculate_file_name(sourcepath, filename)\n destination_path = destination('host' => host)\n\n # The path is set dynamically based on host name and time\n # make sure it exists if not create it\n FileUtils.mkdir_p(destination_path) unless Dir.exists?(destination_path)\n\n FileUtils.mv(sourcepath, File.join(destination_path, saved_file_name))\n end",
"def move_file(from_source:, from_file:, to_source:, to_file:)\n response = HTTParty.get(\"#{@host}/move_file\", query: {\n source_file: \"#{from_source}:#{from_file}\",\n dest_file: \"#{to_source}:#{to_file}\",\n api_key: @api_key\n })\n \n return response.body\n end",
"def move_file(path:, move_destination:)\n BrickFTP::API::FileOperation::Move.create(path: path, 'move-destination': move_destination)\n end",
"def move_file bucket_name:, file_name:, new_name:\n # The ID of your GCS bucket\n # bucket_name = \"your-unique-bucket-name\"\n\n # The ID of your GCS object\n # file_name = \"your-file-name\"\n\n # The ID of your new GCS object\n # new_name = \"your-new-file-name\"\n\n require \"google/cloud/storage\"\n\n storage = Google::Cloud::Storage.new\n bucket = storage.bucket bucket_name, skip_lookup: true\n file = bucket.file file_name\n\n renamed_file = file.copy new_name\n\n file.delete\n\n puts \"#{file_name} has been renamed to #{renamed_file.name}\"\nend",
"def save_file\n FileUtils.mkdir_p(File.dirname(full_filename))\n FileUtils.cp(temp_path, full_filename)\n FileUtils.chmod(0644, full_filename)\n end",
"def replace_file( src, dest )\n if File.identical? src, dest\n puts \"identical #{dest}, ignoring\"\n else\n puts \"mv #{dest} #{dest}.orig\"\n File.rename( dest, \"#{dest}.orig\" )\n link_file( src, dest )\n end\nend",
"def close\n @disk.save(@filename) if @changed\n end",
"def mv(from_path, to_path, replace=false)\n move(from_path, to_path, nil, true, replace)\n end",
"def opx_file_backup()\n File.rename(TABULATOR_DATA_FILE, TABULATOR_BACKUP_FILE)\n rescue => e\n opx_err(\"Fatal failure of File.rename from #{TABULATOR_DATA_FILE} \" +\n \"to #{TABULATOR_BACKUP_FILE}\", e)\n end",
"def rename!(name)\n @name = name\n @path = make_path\n end",
"def update\n description = file_params[:description] || @file.description\n\n raise ApiError, \"Can't rename a file.\" unless @file.rename(file_params[:name], description)\n\n render json: @file, adapter: :json\n end",
"def project_mv(src_file, dst_file, options)\n if src_file.path.directory?\n # Process all children first\n children = src_file.path.children.map { |c| c.directory? ? Group.new(c) : File.new(c) }\n children.each do |src_child|\n dst_child = src_child.with_dirname(dst_file.path)\n project_mv(src_child, dst_child, options)\n end\n else\n # Remove old destination file reference if it exists\n dst_file.remove_from_project if dst_file.pbx_file\n\n # Add new destination file reference to the new xcodeproj\n dst_file.create_file_reference\n dst_file.add_to_targets(options[:targets], options[:headers])\n end\n\n # Remove original directory/file from xcodeproj\n if src_file.pbx_file\n src_file.remove_from_project\n else\n warn(\"⚠️ Warning: #{src_file.path.basename} not found in #{src_file.project.path.basename}, moving anyway...\")\n end\n end",
"def move_file(path:, move_destination:)\n BrickFTP::API::FileOperation::Move.create(path: path, :'move-destination' => move_destination)\n end",
"def move_file\n source_file = Item.new(Path.new(params[:source_file]))\n dest_file = Item.new(Path.new(params[:dest_file]))\n\n response = {}\n if source_file.path.to_s == dest_file.path.to_s\n response[:msg] = \"Same file\"\n render json: response, status: 200\n return\n end\n\n response[:source_file] = source_file\n response[:dest_file] = dest_file\n if source_file.move_to(dest_file)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 402\n end\n end",
"def replace_file(file, target)\n LOGGER.info \"Replacing #{file}\".blue\n system %(rm -rf \"#{target}\")\n link_file(file, target)\nend",
"def mv orig, dest, rm = true\n rm_rf dest unless !rm\n execute(\"mv #{orig} #{dest}\")\n end",
"def edit\n cur_path = current_path\n dir = Dir.new( cur_path )\n if request.post?\n original_name = params[:original_file_name].gsub(/\\.\\./, '')\n file_name = params[:file_name].gsub(/\\.\\./, '')\n if (original_name.blank? or file_name.blank?)\n @edit_file = original_name\n flash[:warning] = _('Invalid filename')\n elsif (dir.entries.include? file_name)\n flash[:warning] = _('File with the same name already exists!')\n else\n FileUtils.mv(cur_path + original_name, cur_path + file_name)\n flash[:notice] = _('File name updated successfully!')\n end\n end\n redirect_to :action => 'list', :path => @path.join('/'), :ahr => request.xhr?, :mode => params[:mode]\n end",
"def overwrite(filename)\n res = -1\n File.open(filename, 'w+') do | file | \n p file \n res = write_to_file(file) \n end \n return res\n end",
"def move_to_trash!(remove_empty_dir: true)\n curr_path, = file_path_and_role_name\n unless curr_path\n raise FsException::Action, \"Move to trash not allowed. File not accessible with current roles: #{curr_path}\"\n end\n\n dt = DateTime.now.to_i\n new_file_name = \"#{file_name}--#{dt}\"\n move_to trash_path, new_file_name\n\n return unless curr_path && is_a?(ArchivedFile) && remove_empty_dir\n\n NfsStore::Archive::Mounter.remove_empty_archive_dir(curr_path)\n end",
"def move_epub\n origin = manifest.filename\n target = preview? ? origin + '-preview' : origin\n FileUtils.mv(File.join('epub', \"#{origin}.epub\"),\n File.join('ebooks', \"#{target}.epub\"))\n end"
] | [
"0.70535296",
"0.6991466",
"0.69445086",
"0.68627465",
"0.6700984",
"0.66592026",
"0.66377234",
"0.6622271",
"0.6591527",
"0.6551897",
"0.64417833",
"0.63584733",
"0.6329053",
"0.63048226",
"0.6259425",
"0.62380344",
"0.6234982",
"0.62339795",
"0.6217973",
"0.6132246",
"0.61276686",
"0.6086643",
"0.6013066",
"0.6002223",
"0.59990865",
"0.5947362",
"0.5898008",
"0.5891057",
"0.58424526",
"0.5818412",
"0.5785859",
"0.5781733",
"0.5755826",
"0.57481325",
"0.5744131",
"0.57391185",
"0.5735515",
"0.5731721",
"0.57286704",
"0.5702713",
"0.56954074",
"0.56933063",
"0.56913745",
"0.568358",
"0.5668087",
"0.5663237",
"0.5663237",
"0.5654812",
"0.5654251",
"0.5640012",
"0.56368136",
"0.5635673",
"0.56302786",
"0.56266993",
"0.561739",
"0.5610947",
"0.5582271",
"0.557285",
"0.5563185",
"0.55586696",
"0.55555934",
"0.55195713",
"0.55171806",
"0.55139154",
"0.5511049",
"0.55087787",
"0.5474686",
"0.54595417",
"0.5453132",
"0.5451598",
"0.5449494",
"0.5431116",
"0.5413774",
"0.54034805",
"0.5394672",
"0.53905576",
"0.5381435",
"0.5355137",
"0.53468496",
"0.5328525",
"0.5320236",
"0.53110033",
"0.53049225",
"0.53046274",
"0.5304117",
"0.53013116",
"0.5300745",
"0.5283468",
"0.5281008",
"0.52789265",
"0.5274867",
"0.5270791",
"0.5257518",
"0.5255569",
"0.5252473",
"0.5248426",
"0.5233644",
"0.5222185",
"0.5217744",
"0.52134824",
"0.52052"
] | 0.0 | -1 |
GET /hostnesses GET /hostnesses.xml | def index
@hostnesses = Hostness.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @hostnesses }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @hostness = Hostness.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hostness }\n end\n end",
"def index\n @hosts = Host.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @hosts }\n end\n end",
"def show\n @host = Host.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @host }\n end\n end",
"def index\n @hosts = Host.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @hosts.to_xml }\n end\n end",
"def get_host( host_id)\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Zerigo::DNS::GetHost.new,\n :path => \"/api/1.1/hosts/#{host_id}.xml\"\n )\n end",
"def host_meta\n @host_meta ||= begin\n request = Net::HTTP::Get.new(host_meta_uri.path)\n http = Net::HTTP.new(host_meta_uri.host, host_meta_uri.port)\n http.use_ssl = (host_meta_uri.port==443)\n response = http.start {|http| http.request(request) }\n raise OpenTransact::UndiscoverableResource unless response.code==\"200\"\n MultiXml.parse(response.body)[\"XRD\"]\n end\n end",
"def externalNodes\n certname = params[:name]\n @host ||= resource_base.find_by_certname certname\n @host ||= resource_base.find_by_name certname\n not_found and return unless @host\n\n begin\n respond_to do |format|\n format.html { render :text => \"<pre>#{@host.info.to_yaml}</pre>\" }\n format.yml { render :text => @host.info.to_yaml }\n end\n rescue\n # failed\n logger.warn \"Failed to generate external nodes for #{@host} with #{$!}\"\n render :text => _('Unable to generate output, Check log files\\n'), :status => 412 and return\n end\n end",
"def show\n\t @host = Host.find(params[:id])\n\n\t respond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @host }\n\t end\n\tend",
"def rest_get(uri)\n \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 return doc\n \n end\n \nend",
"def show\n @hostel = Hostel.find(params[:id])\n @rooms = @hostel.rooms\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hostel }\n end\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def index\n @servers = Server.beating\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @servers }\n end\n end",
"def show\n @demo_host_setting = Demo::HostSetting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @demo_host_setting }\n end\n end",
"def show\n @search = Host.search params[:search]\n @host = Host.find(params[:id])\n \n filter_notes\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @host }\n end\n end",
"def fetch_xml(uri)\n http = Net::HTTP.new(uri.host, uri.port)\n\n if uri.scheme == 'https'\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n http.read_timeout = GoogleCustomSearch.configuration.timeout\n\n request = Net::HTTP::Get.new(uri.request_uri)\n request.initialize_http_header({ 'User-Agent' => user_agent })\n\n response = http.request(request)\n\n raise GoogleCustomSearch::InvalidRequest if response.code.match(/[34]\\d{2}/)\n raise GoogleCustomSearch::ServerError if response.code.match(/5\\d{2}/)\n\n response.body\n end",
"def get_flows()\n\tputs \"Getting flows\"\n\tresponse = request_get('/api/partner/flow')\n\tputs response.body\nend",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def index\n @node = Fedora.rest('rest/')\n end",
"def index\n @selector_sites = SelectorSite.curr_ver.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @selector_sites }\n end\n end",
"def show\n @discovery = Discovery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def show\n @sleuths = HTTParty.get('https://webservice.wikipathways.org/findPathwaysByText?query=' + @sleuth.ext_gene + '&species=homo+sapiens&format=json',\n :headers =>{'Content-Type' => 'application/json'} )\n @pubs = HTTParty.get('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&term='+ @sleuth.ext_gene,\n :headers =>{'Content-Type' => 'application/json'} )\n end",
"def get_channnel_xml( url )\n path = url.sub(/http:\\/\\/gdata\\.youtube\\.com/,'')\n xml = \"\"\n\n Net::HTTP.version_1_2\n Net::HTTP.start(\"#{@url}\", \"#{@port}\") do |http|\n response = http.get(\"/#{path}\")\n xml = response.body\n end\n\n return xml\n end",
"def info\n CouchRest.get \"#{@uri}/\"\n end",
"def show\n @host = Host.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @host }\n end\n end",
"def get_host(fqdn)\n foreman('GET', \"/api/hosts/#{fqdn}\")\n end",
"def index\n # This should never be called, just used for debugging\n @emergencies = Emergency.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @emergencies }\n end\n end",
"def index\n @eversions = Eversion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @eversions }\n end\n end",
"def get_xml_from_api(uri, query)\n resp = HTTParty.get(uri, query: query, headers: request_headers)\n # If we received anything but a 200 then log an error and return an empty array\n raise \"Unable to connect to connect to - #{@pubmed_api}?#{query}: status: #{resp.code}\" if resp.code != 200\n # Return an empty array if the response did not have any results\n return nil if resp.code != 200 || resp.blank?\n\n resp.body\n end",
"def index\n @clusters = Cluster.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clusters }\n end\n end",
"def http_request(host)\n begin\n response = Nokogiri::HTML(open(\"http:\\/\\/bleed-1161785939.us-east-1.elb.amazonaws.com\\/bleed\\/#{host}\"))\n display_result(response, host)\n rescue\n puts \"[-] #{host}: Issues connecting to site\"\n end\nend",
"def test_get_site_list\r\n endpoint = \"/sites\"\r\n uri = URI(\"#{@host}#{endpoint}\")\r\n request = Net::HTTP::Get.new(uri)\r\n request['Accept'] = 'application/json'\r\n \r\n test_start = Time.now\r\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\r\n http.request(request)\r\n end\r\n test_end = Time.now\r\n\r\n @results << {\r\n :api => 'GET /sites',\r\n :endpoint => endpoint,\r\n :start_time => test_start,\r\n :runtime => (test_end.to_f - test_start.to_f) * 1000.0,\r\n :status => response.code,\r\n :content_type => response['content-type']\r\n }\r\n end",
"def index\n @entries = @resource_finder.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def as_host_xml\n xml = \"\"\n hosts.each do |host|\n xml = xml + \"<host mac='#{host[:mac]}' name='#{host[:name]}' ip='#{host[:ip]}' />\"\n end\n xml\n end",
"def index\n @components_front_levers = Components::FrontLever.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_front_levers }\n end\n end",
"def fetchInstallations(token)\n url = URI(\"https://api.acceptance.hertekconnect.nl/api/v1/installations\")\n\n http = Net::HTTP.new(url.host, url.port);\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"Content-Type\"] = \"application/json\"\n request[\"Authorization\"] = \"Bearer #{token}\"\n\n response = http.request(request)\n puts response.read_body\nend",
"def info\n get '/'\n end",
"def getNodeList\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n result = HTTParty.get(broker_url + \"/resources/nodes\", :verify => false)\n temp2 = JSON.parse(result.body)\n\n node_data = temp2[\"resource_response\"][\"resources\"]\n return node_data\n \n end",
"def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end",
"def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end",
"def serveOAI\n content_type 'text/xml;charset=utf-8'\n provider = EscholProvider.new\n provider.process_request(params)\n end",
"def servers\n endpoint = 'https://pcs.baidu.com/rest/2.0/pcs/manage?method=listhost'\n @res = @api.request_json( endpoint )\n end",
"def get_facts(host)\n curl = setup_curl(\"#{@puppetdb_url}/v3/nodes/#{host}/facts\")\n curl.get\n result = JSON.parse(curl.body_str)\n warn \"Error #{host} not found in puppetdb\" if result.empty?\n result\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @helibases = Helibase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @helibases }\n end\n end",
"def show\n @host = Host.find(params[:id])\n\n render json: @host\n end",
"def hosts; end",
"def hosts; end",
"def hosts; end",
"def query_api(path)\n with_http_error_handling do\n res = RestClient.get(endpoint + path)\n h = Hash.from_xml(res.body)\n h[\"response\"]\n end\n end",
"def getXMLTicket(path)\n resp2 = @@conn.get do |req|\n req.url path\n req.headers['Authorization'] = 'Basic aHIuc2VsbGVydEBnbWFpbC5jb206c2VzMTEy' #@TODO make this a param\n req.headers['Content-Type'] = 'application/xml'\n end\n # puts \"Responce : \" + resp2['body'].inspect\n # puts \"Responce2 : \" + resp2.body.to_s()\n \n return resp2.body.to_s()\n end",
"def show\n @hosts_to_mac_addresses = HostsToMacAddresses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hosts_to_mac_addresses }\n end\n end",
"def get(url = \"/api/system/info\")\n url = File.join(@client.url, url)\n request = Typhoeus::Request.new(url,\n method: :get,\n headers: headers,\n ssl_verifypeer: @client.ssl_verify_peer?,\n cookiefile: cookie_file_path, # read from\n cookiejar: cookie_file_path, # write to\n userpwd: [@client.user, @client.password].join(\":\"))\n request.run\n request.response\n end",
"def show\n @host = Host.find_by(hostname: params[:id])\n\n render json: @host\n end",
"def uri_host; end",
"def show\n @components_front_lever = Components::FrontLever.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @components_front_lever }\n end\n end",
"def show\n @lookup_demographichandedness = LookupDemographichandedness.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_demographichandedness }\n end\n end",
"def show\n @host = Host.find(params[:id])\n @stages = @host.stages.uniq.sort_by{|x| x.project.name}\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @host.to_xml }\n end\n end",
"def hosts\n @job = Job.find(params[:id])\n host_array = []\n @job.nodes.each do |node|\n host_array << \"#{node.private_dns_name} #{node.private_dns_name.split('.')[0]}\"\n end\n send_data host_array.join(\"\\n\"), :type => 'text/html; charset=utf-8'\n end",
"def index_hosts\n load_service\n return if (@service.blank?)\n\n # Preload hosts\n @hosts = Host.where(:_id.in => @service.host_ids)\n\n respond_to do |format|\n format.html\n end\n end",
"def show\n @helibase = Helibase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @helibase }\n end\n end",
"def index\n @sys_configs = @system.sys_configs.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sys_configs.to_xml }\n end\n end",
"def index\n @distributions = @foyer.distributions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @distributions }\n end\n end",
"def show\n @helibasis = Helibase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @helibasis }\n end\n end",
"def servers_detailed()\n return get_request(address(\"/servers/detail\"), @token)\n end",
"def show\n @lookup_hardware = LookupHardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_hardware }\n end\n end",
"def index\n @websites = Website.find(:all, :order => 'name')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @websites.to_xml }\n end\n end",
"def info\n IbmCloudRest.get \"#{@uri}/\"\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @compliances = Compliance.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compliances }\n end\n end",
"def show\n @configuration = current_host.configuration_parameters.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @configuration.to_xml }\n end\n end",
"def index\n @certs = Cert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @certs }\n end\n end",
"def get_host_xml(mac)\n xml = \"\"\n hosts.each do |host|\n if host[:mac] == mac\n return \"<host mac='#{host[:mac]}' name='#{host[:name]}' ip='#{host[:ip]}' />\"\n end\n end\n xml\n end",
"def index\n @transport_lines = TransportLine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transport_lines }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clients }\n end\n end",
"def query(action, hash = {})\n # uri = URI.parse(\"https://130.59.10.31\")\n # http = Net::HTTP.new(uri.host, uri.port)\n # http.use_ssl = true\n # http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n #\n # request = Net::HTTP::Get.new(uri.request_uri)\n #\n # response = http.request(request)\n # response.body\n # response.status\n # response[\"header-here\"] # All headers are lowercase\n uri = URI.parse(@url + \"/api/xml?action=#{action}\")\n hash.each_pair do |key, val|\n if val\n if key == \"filter\" or key == \"sort\"\n uri.query += val.query\n else\n uri.query += \"&\" + key + \"=\" + CGI::escape(\"#{val}\")\n end\n end\n end\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme == \"https\"\n http.use_ssl=true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n request = Net::HTTP::Get.new(uri.request_uri)\n # logger = Logger.new('log/development.log')\n # logger.info(url.path + \"?\" + url.query)\n if @sessionid\n request.add_field(\"Cookie\", \"BREEZESESSION=\"+@sessionid)\n end\n puts \"ACS query - request: \" + request.path\n response = http.request(request)\n puts \"ACS query - response: \" + response.body.inspect\n return response\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @client }\n end\n end",
"def get_blockchain_stats\n stats = HTTParty.get(\"http://webbtc.com/stats.json\")\nend",
"def index\n @querylists = HTTParty.post(\"http://66.175.217.67:3020/argames/getQuery\", :body => { :checkFilter => '' }, :headers => {\"Authorization\" => \"Bearer \" + ENV[\"API_KEY\"] })\n end",
"def list\n get('/')\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @compliance }\n end\n end",
"def show\n @host = Host.find(params[:id])\n @stages = @host.stages.uniq.sort_by{|x| x.project.name}\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @host.to_xml }\n end\n end",
"def index\n\n if request.format == Mime::XML\n limit=params[:limit].nil? ? 1000: params[:limit]\n else\n limit=params[:limit].nil? ? 50 : params[:limit]\n end\n\n config_template_id=params[:config_template_id]\n @config_template=ConfigTemplate.find(config_template_id)\n\n @node_configs = NodeConfig.find(:all, :conditions => [\"config_template_id = ?\", config_template_id], :order => \"hostname DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @node_configs }\n format.json { render :json => @node_configs }\n end\n end",
"def show\n @server = Server.find params[:id]\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @server }\n end\n end",
"def get_alerts\r\n\t\turl = URI.parse(\"http://api.wunderground.com/api/#{@token}/alerts/q/#{@state_code}/#{@city}.json\")\r\n\t\thttp_response = HTTParty.get(url).parsed_response\r\n\t\tputs JSON.pretty_generate(http_response)\r\n\tend",
"def show\n @hostela = Hostela.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hostela }\n end\n end",
"def report_get_host(report_id,host)\r\n\t\tpost= { \"token\" => @token, \"report\" => report_id } \r\n\t\tdocxml=nessus_request('report/hosts', post)\r\n\t\tdocxml.root.elements['contents'].elements['hostList'].each_element('//host') { |host| \r\n\t\t\tif host.elements['hostname'].text == host\r\n\t\t\t\tretval={}\r\n\t\t\t\tretval[:severity] = host.elements['severity'].text\r\n\t\t\t\tretval[:current] = host.elements['scanProgressCurrent'].text\r\n\t\t\t\tretval[:total] = host.elements['scanProgressTotal'].text\r\n\t\t\t\treturn retval\r\n\t\t\tend\r\n\t\t}\r\n\tend",
"def endpoint\n \"https://#{@host}:#{@port}/wsman\"\n end",
"def index\n @installation = Installation.find(params[:installation_id]) \n @eats = @installation.eats.find(:all, :order => 'name')\n \n @neighborhoods = @installation.neighborhoods\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @eats }\n end\n end",
"def index\n @compliances = Compliance.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compliances }\n end\n end",
"def index\n @lookup_sets = LookupSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_sets }\n end\n end",
"def list()\n puts \"Listing all endpoints\"\n load_manifest\n\n pp manifest.keys\n\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def index\n @subways = Subway.find(:all, :order => \"day, hour\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subways }\n end\n end",
"def show\n @client_app = ClientApp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @seed }\n end\n end",
"def hosts\n\t\tHost.find(:all)\n\tend"
] | [
"0.68635285",
"0.65740025",
"0.6359163",
"0.62932813",
"0.62361896",
"0.6197955",
"0.6121101",
"0.60841703",
"0.6070646",
"0.5979585",
"0.5961438",
"0.5909579",
"0.58809775",
"0.5790083",
"0.57673913",
"0.5752485",
"0.57215196",
"0.5703022",
"0.5699883",
"0.5694871",
"0.5671989",
"0.56604195",
"0.564418",
"0.5622379",
"0.5608985",
"0.5594168",
"0.5578894",
"0.5578522",
"0.5529801",
"0.55280876",
"0.5527675",
"0.5511475",
"0.5493191",
"0.54929113",
"0.54838973",
"0.5474436",
"0.5467025",
"0.54605436",
"0.54605436",
"0.54579926",
"0.5428457",
"0.54249215",
"0.54111564",
"0.54111564",
"0.54111564",
"0.54111564",
"0.54111564",
"0.5408395",
"0.54040843",
"0.53994745",
"0.53994745",
"0.53994745",
"0.539351",
"0.53911227",
"0.53770155",
"0.5369132",
"0.5367642",
"0.5353891",
"0.53453714",
"0.5342265",
"0.5341909",
"0.5336674",
"0.5333059",
"0.5330084",
"0.53189707",
"0.5313309",
"0.53132385",
"0.530327",
"0.53020215",
"0.53003854",
"0.52980244",
"0.52971935",
"0.52971935",
"0.52965933",
"0.5293434",
"0.52807903",
"0.5276876",
"0.5275974",
"0.52738017",
"0.5273773",
"0.52737117",
"0.52670956",
"0.52639097",
"0.5262038",
"0.52612066",
"0.52551675",
"0.5254733",
"0.52500165",
"0.5249996",
"0.5249985",
"0.52482903",
"0.52433133",
"0.5239329",
"0.5237785",
"0.523721",
"0.5230582",
"0.5228379",
"0.52266574",
"0.5217075",
"0.5214089"
] | 0.72850645 | 0 |
GET /hostnesses/1 GET /hostnesses/1.xml | def show
@hostness = Hostness.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @hostness }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @hostnesses = Hostness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @hostnesses }\n end\n end",
"def index\n @hosts = Host.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @hosts }\n end\n end",
"def show\n @host = Host.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @host }\n end\n end",
"def get_host( host_id)\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Zerigo::DNS::GetHost.new,\n :path => \"/api/1.1/hosts/#{host_id}.xml\"\n )\n end",
"def index\n @hosts = Host.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @hosts.to_xml }\n end\n end",
"def show\n\t @host = Host.find(params[:id])\n\n\t respond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @host }\n\t end\n\tend",
"def externalNodes\n certname = params[:name]\n @host ||= resource_base.find_by_certname certname\n @host ||= resource_base.find_by_name certname\n not_found and return unless @host\n\n begin\n respond_to do |format|\n format.html { render :text => \"<pre>#{@host.info.to_yaml}</pre>\" }\n format.yml { render :text => @host.info.to_yaml }\n end\n rescue\n # failed\n logger.warn \"Failed to generate external nodes for #{@host} with #{$!}\"\n render :text => _('Unable to generate output, Check log files\\n'), :status => 412 and return\n end\n end",
"def host_meta\n @host_meta ||= begin\n request = Net::HTTP::Get.new(host_meta_uri.path)\n http = Net::HTTP.new(host_meta_uri.host, host_meta_uri.port)\n http.use_ssl = (host_meta_uri.port==443)\n response = http.start {|http| http.request(request) }\n raise OpenTransact::UndiscoverableResource unless response.code==\"200\"\n MultiXml.parse(response.body)[\"XRD\"]\n end\n end",
"def index\n @servers = Server.beating\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @servers }\n end\n end",
"def rest_get(uri)\n \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 return doc\n \n end\n \nend",
"def show\n @demo_host_setting = Demo::HostSetting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @demo_host_setting }\n end\n end",
"def show\n @hostel = Hostel.find(params[:id])\n @rooms = @hostel.rooms\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hostel }\n end\n end",
"def show\n @search = Host.search params[:search]\n @host = Host.find(params[:id])\n \n filter_notes\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @host }\n end\n end",
"def index\n @node = Fedora.rest('rest/')\n end",
"def show\n @discovery = Discovery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def show\n @host = Host.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @host }\n end\n end",
"def get_host(fqdn)\n foreman('GET', \"/api/hosts/#{fqdn}\")\n end",
"def index\n @selector_sites = SelectorSite.curr_ver.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @selector_sites }\n end\n end",
"def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end",
"def show\n @server = Server.find params[:id]\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @server }\n end\n end",
"def index\n @clusters = Cluster.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clusters }\n end\n end",
"def show\n @host = Host.find_by(hostname: params[:id])\n\n render json: @host\n end",
"def run_host(ip)\n\n\t\tverbs = [\n\t\t\t\t'get',\n\t\t\t\t'active',\n\t\t\t\t'create',\n\t\t\t\t'change',\n\t\t\t\t'set',\n\t\t\t\t'put',\n\t\t\t\t'do',\n\t\t\t\t'go',\n\t\t\t\t'resolve',\n\t\t\t\t'start',\n\t\t\t\t'recover',\n\t\t\t\t'initiate',\n\t\t\t\t'negotiate',\n\t\t\t\t'define',\n\t\t\t\t'stop',\n\t\t\t\t'begin',\n\t\t\t\t'end',\n\t\t\t\t'manage',\n\t\t\t\t'administer',\n\t\t\t\t'modify',\n\t\t\t\t'register',\n\t\t\t\t'log',\n\t\t\t\t'add',\n\t\t\t\t#'delete', # Best to be safe!\n\t\t\t]\n\n\t\tnouns = [\n\t\t\t\t'password',\n\t\t\t\t'task',\n\t\t\t\t'pass',\n\t\t\t\t'administration',\n\t\t\t\t'account',\n\t\t\t\t'admin',\n\t\t\t\t'login',\n\t\t\t\t'token',\n\t\t\t\t'credentials',\n\t\t\t\t'credential',\n\t\t\t\t'key',\n\t\t\t\t'guid',\n\t\t\t\t'message',\n\t\t\t\t'user',\n\t\t\t\t'username',\n\t\t\t\t'load',\n\t\t\t\t'list',\n\t\t\t\t'name',\n\t\t\t\t'file',\n\t\t\t\t'path',\n\t\t\t\t'directory',\n\t\t\t\t'configuration',\n\t\t\t\t'config',\n\t\t\t\t'setting',\n\t\t\t\t'settings',\n\t\t\t\t'registry',\n\t\t\t\t'on',\n\t\t\t\t'off',\n\t\t\t]\n\n\t\ttarget_port = datastore['RPORT']\n\t\tvhost = datastore['VHOST'] || wmap_target_host || ip\n\n\t\tbegin\n\t\t\t# Check service exists\n\t\t\tres = send_request_raw({\n\t\t\t\t'uri' => datastore['PATH'],\n\t\t\t\t'method' => 'GET',\n\t\t\t\t'vhost' => vhost,\n\t\t\t}, 10)\n\n\t\t\tif (res.code == 200)\n\t\t\t\tprint_status(\"PATH appears to be OK.\")\n\n\t\t\t\tverbs.each do |v|\n\t\t\t\t\tnouns.each do |n|\n\n\t\t\t\t\t\t# This could be cleaned up - patrickw\n\t\t\t\t\t\tdata = '<?xml version=\"1.0\" encoding=\"utf-8\"?>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '<soap:Envelope xmlns:xsi=\"' + datastore['XMLINSTANCE'] + '\" xmlns:xsd=\"' + datastore['XMLSCHEMA'] + '\" xmlns:soap=\"' + datastore['XMLSOAP'] + '\">' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '<soap:Body>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << \"<#{v}#{n}\" + \" xmlns=\\\"#{datastore['XMLNAMESPACE']}\\\">\" + \"\\r\\n\"\n\t\t\t\t\t\tdata << \"</#{v}#{n}>\" + \"\\r\\n\"\n\t\t\t\t\t\tdata << '</soap:Body>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '</soap:Envelope>' + \"\\r\\n\\r\\n\"\n\n\t\t\t\t\t\tres = send_request_raw({\n\t\t\t\t\t\t\t'uri' => datastore['PATH'] + '/' + v + n,\n\t\t\t\t\t\t\t'method' => 'POST',\n\t\t\t\t\t\t\t'vhost' => vhost,\n\t\t\t\t\t\t\t'data'\t\t=> data,\n\t\t\t\t\t\t\t'headers' =>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'Content-Length' => data.length,\n\t\t\t\t\t\t\t\t\t'SOAPAction'\t=> '\"' + datastore['XMLNAMESPACE'] + v + n + '\"',\n\t\t\t\t\t\t\t\t\t'Expect'\t=> '100-continue',\n\t\t\t\t\t\t\t\t\t'Content-Type'\t=> datastore['CONTENTTYPE'],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, 15)\n\n\t\t\t\t\t\tif (res && !(res.body.empty?))\n\t\t\t\t\t\t\tif (res.body =~ /method name is not valid/)\n\t\t\t\t\t\t\t\tprint_status(\"Server rejected SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\telsif (res.message =~ /Cannot process the message because the content type/)\n\t\t\t\t\t\t\t\tprint_status(\"Server rejected CONTENTTYPE: HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\t\tres.message =~ /was not the expected type\\s\\'([^']+)'/\n\t\t\t\t\t\t\t\tprint_status(\"Set CONTENTTYPE to \\\"#{$1}\\\"\")\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\telsif (res.code == 404)\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tprint_status(\"Server responded to SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\t\t## Add Report\n\t\t\t\t\t\t\t\treport_note(\n\t\t\t\t\t\t\t\t\t:host\t=> ip,\n\t\t\t\t\t\t\t\t\t:proto\t=> 'HTTP',\n\t\t\t\t\t\t\t\t\t:port\t=> rport,\n\t\t\t\t\t\t\t\t\t:type\t=> \"SOAPAction: #{v}#{n}\",\n\t\t\t\t\t\t\t\t\t:data\t=> \"SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\"\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif datastore['DISPLAYHTML']\n\t\t\t\t\t\t\t\t\tprint_status(\"The HTML content follows:\")\n\t\t\t\t\t\t\t\t\tprint_status(res.body + \"\\r\\n\")\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\telse\n\t\t\tprint_status(\"Server did not respond with 200 OK.\")\n\t\t\tprint_status(res.to_s)\n\t\tend\n\t\trescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout\n\t\trescue ::Timeout::Error, ::Errno::EPIPE\n\t\tend\n\tend",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def show\n @host = Host.find(params[:id])\n @stages = @host.stages.uniq.sort_by{|x| x.project.name}\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @host.to_xml }\n end\n end",
"def show\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.add_missing_hosts # TODO: Does this need to be here???\n @schema = self.schema\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @physical_rack }\n format.csv {export_csv @physical_rack}\n end\n end",
"def fetch_xml(uri)\n http = Net::HTTP.new(uri.host, uri.port)\n\n if uri.scheme == 'https'\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n http.read_timeout = GoogleCustomSearch.configuration.timeout\n\n request = Net::HTTP::Get.new(uri.request_uri)\n request.initialize_http_header({ 'User-Agent' => user_agent })\n\n response = http.request(request)\n\n raise GoogleCustomSearch::InvalidRequest if response.code.match(/[34]\\d{2}/)\n raise GoogleCustomSearch::ServerError if response.code.match(/5\\d{2}/)\n\n response.body\n end",
"def index_hosts\n load_service\n return if (@service.blank?)\n\n # Preload hosts\n @hosts = Host.where(:_id.in => @service.host_ids)\n\n respond_to do |format|\n format.html\n end\n end",
"def show\n @host = Host.find(params[:id])\n\n render json: @host\n end",
"def uri_host; end",
"def info\n CouchRest.get \"#{@uri}/\"\n end",
"def show\n @helibase = Helibase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @helibase }\n end\n end",
"def index\n @eversions = Eversion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @eversions }\n end\n end",
"def as_host_xml\n xml = \"\"\n hosts.each do |host|\n xml = xml + \"<host mac='#{host[:mac]}' name='#{host[:name]}' ip='#{host[:ip]}' />\"\n end\n xml\n end",
"def show\n @configuration = current_host.configuration_parameters.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @configuration.to_xml }\n end\n end",
"def show\n @hosts_to_mac_addresses = HostsToMacAddresses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hosts_to_mac_addresses }\n end\n end",
"def index\n @components_front_levers = Components::FrontLever.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_front_levers }\n end\n end",
"def show\n @sleuths = HTTParty.get('https://webservice.wikipathways.org/findPathwaysByText?query=' + @sleuth.ext_gene + '&species=homo+sapiens&format=json',\n :headers =>{'Content-Type' => 'application/json'} )\n @pubs = HTTParty.get('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&term='+ @sleuth.ext_gene,\n :headers =>{'Content-Type' => 'application/json'} )\n end",
"def show\n @host = Host.find(params[:id])\n @stages = @host.stages.uniq.sort_by{|x| x.project.name}\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @host.to_xml }\n end\n end",
"def info\n get '/'\n end",
"def read(id=nil)\n request = Net::HTTP.new(@uri.host, @uri.port)\n if id.nil?\n response = request.get(\"#{@uri.path}.xml\")\n else\n response = request.get(\"#{@uri.path}/#{id}.xml\")\n end\n\n response.body\n end",
"def index\n\n if request.format == Mime::XML\n limit=params[:limit].nil? ? 1000: params[:limit]\n else\n limit=params[:limit].nil? ? 50 : params[:limit]\n end\n\n config_template_id=params[:config_template_id]\n @config_template=ConfigTemplate.find(config_template_id)\n\n @node_configs = NodeConfig.find(:all, :conditions => [\"config_template_id = ?\", config_template_id], :order => \"hostname DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @node_configs }\n format.json { render :json => @node_configs }\n end\n end",
"def new\n @hostel = Hostel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hostel }\n end\n end",
"def getXMLTicket(path)\n resp2 = @@conn.get do |req|\n req.url path\n req.headers['Authorization'] = 'Basic aHIuc2VsbGVydEBnbWFpbC5jb206c2VzMTEy' #@TODO make this a param\n req.headers['Content-Type'] = 'application/xml'\n end\n # puts \"Responce : \" + resp2['body'].inspect\n # puts \"Responce2 : \" + resp2.body.to_s()\n \n return resp2.body.to_s()\n end",
"def show\n @helibasis = Helibase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @helibasis }\n end\n end",
"def index\n @helibases = Helibase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @helibases }\n end\n end",
"def report_get_host(report_id,host)\r\n\t\tpost= { \"token\" => @token, \"report\" => report_id } \r\n\t\tdocxml=nessus_request('report/hosts', post)\r\n\t\tdocxml.root.elements['contents'].elements['hostList'].each_element('//host') { |host| \r\n\t\t\tif host.elements['hostname'].text == host\r\n\t\t\t\tretval={}\r\n\t\t\t\tretval[:severity] = host.elements['severity'].text\r\n\t\t\t\tretval[:current] = host.elements['scanProgressCurrent'].text\r\n\t\t\t\tretval[:total] = host.elements['scanProgressTotal'].text\r\n\t\t\t\treturn retval\r\n\t\t\tend\r\n\t\t}\r\n\tend",
"def hosts; end",
"def hosts; end",
"def hosts; end",
"def index\n @entries = @resource_finder.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def query_api(path)\n with_http_error_handling do\n res = RestClient.get(endpoint + path)\n h = Hash.from_xml(res.body)\n h[\"response\"]\n end\n end",
"def index\n @sys_configs = @system.sys_configs.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sys_configs.to_xml }\n end\n end",
"def show\n @components_front_lever = Components::FrontLever.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @components_front_lever }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sites }\n end\n end",
"def http_request(host)\n begin\n response = Nokogiri::HTML(open(\"http:\\/\\/bleed-1161785939.us-east-1.elb.amazonaws.com\\/bleed\\/#{host}\"))\n display_result(response, host)\n rescue\n puts \"[-] #{host}: Issues connecting to site\"\n end\nend",
"def extract_host_info(report_file)\n @hosts.each do |h|\n report_file.write(\" <host>\\n\")\n host_id = h.attributes[\"id\"]\n\n # Host attributes\n h.attributes.each_pair do |k,v|\n # Convert IPAddr -> String\n v = v.to_s if k == 'address'\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\") # Not checking types\n end\n\n # Host details sub-elements\n report_file.write(\" <host_details>\\n\")\n h.host_details.each do |d|\n report_file.write(\" <host_detail>\\n\")\n d.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n report_file.write(\" </host_detail>\\n\")\n end\n report_file.write(\" </host_details>\\n\")\n\n # Host exploit attempts sub-elements\n report_file.write(\" <exploit_attempts>\\n\")\n h.exploit_attempts.each do |d|\n report_file.write(\" <exploit_attempt>\\n\")\n d.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n report_file.write(\" </exploit_attempt>\\n\")\n end\n report_file.write(\" </exploit_attempts>\\n\")\n\n # Service sub-elements\n report_file.write(\" <services>\\n\")\n @services.where(host_id: host_id).each do |e|\n report_file.write(\" <service>\\n\")\n e.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n report_file.write(\" </service>\\n\")\n end\n report_file.write(\" </services>\\n\")\n\n # Notes sub-elements\n report_file.write(\" <notes>\\n\")\n @notes.where(host_id: host_id).each do |e|\n report_file.write(\" <note>\\n\")\n e.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n report_file.write(\" </note>\\n\")\n end\n report_file.write(\" </notes>\\n\")\n\n # Vulns sub-elements\n report_file.write(\" <vulns>\\n\")\n @vulns.where(host_id: host_id).each do |e|\n report_file.write(\" <vuln>\\n\")\n e.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n\n # Notes attached to vulns instead of the host\n report_file.write(\" <notes>\\n\")\n @notes.where(vuln_id: e.id).each do |note|\n report_file.write(\" <note>\\n\")\n note.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n report_file.write(\" </note>\\n\")\n end\n report_file.write(\" </notes>\\n\")\n\n # References\n report_file.write(\" <refs>\\n\")\n e.refs.each do |ref|\n el = create_xml_element(\"ref\",ref.name)\n report_file.write(\" #{el}\\n\")\n end\n report_file.write(\" </refs>\\n\")\n\n\n # Vuln details sub-elements\n report_file.write(\" <vuln_details>\\n\")\n e.vuln_details.each do |d|\n report_file.write(\" <vuln_detail>\\n\")\n d.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n report_file.write(\" </vuln_detail>\\n\")\n end\n report_file.write(\" </vuln_details>\\n\")\n\n\n # Vuln attempts sub-elements\n report_file.write(\" <vuln_attempts>\\n\")\n e.vuln_attempts.each do |d|\n report_file.write(\" <vuln_attempt>\\n\")\n d.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n report_file.write(\" </vuln_attempt>\\n\")\n end\n report_file.write(\" </vuln_attempts>\\n\")\n\n report_file.write(\" </vuln>\\n\")\n end\n report_file.write(\" </vulns>\\n\")\n\n report_file.write(\" </host>\\n\")\n end\n report_file.flush\n end",
"def show\n @topiccluster = Topiccluster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @topiccluster }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @client }\n end\n end",
"def serveOAI\n content_type 'text/xml;charset=utf-8'\n provider = EscholProvider.new\n provider.process_request(params)\n end",
"def hosts\n @job = Job.find(params[:id])\n host_array = []\n @job.nodes.each do |node|\n host_array << \"#{node.private_dns_name} #{node.private_dns_name.split('.')[0]}\"\n end\n send_data host_array.join(\"\\n\"), :type => 'text/html; charset=utf-8'\n end",
"def show\n @lookup_hardware = LookupHardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_hardware }\n end\n end",
"def new\n @demo_host_setting = Demo::HostSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @demo_host_setting }\n end\n end",
"def new\n @search = Host.search params[:search]\n @host = Host.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @host }\n end\n end",
"def get_xml_from_api(uri, query)\n resp = HTTParty.get(uri, query: query, headers: request_headers)\n # If we received anything but a 200 then log an error and return an empty array\n raise \"Unable to connect to connect to - #{@pubmed_api}?#{query}: status: #{resp.code}\" if resp.code != 200\n # Return an empty array if the response did not have any results\n return nil if resp.code != 200 || resp.blank?\n\n resp.body\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clients }\n end\n end",
"def index\n # This should never be called, just used for debugging\n @emergencies = Emergency.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @emergencies }\n end\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def servers_with_class(classname)\n hosts = []\n query = ['and', ['=', 'type', 'Class'], ['=', 'title', classname]]\n response = request('resources', query)\n response.each do |r|\n hostname = r['certname']\n hosts << hostname\n end\n\n hosts\nend",
"def discovery\n resource ''\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def show\n @probe = Probe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @probe }\n end\n end",
"def show\n @website = Website.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @website.to_xml }\n end\n end",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def get_channnel_xml( url )\n path = url.sub(/http:\\/\\/gdata\\.youtube\\.com/,'')\n xml = \"\"\n\n Net::HTTP.version_1_2\n Net::HTTP.start(\"#{@url}\", \"#{@port}\") do |http|\n response = http.get(\"/#{path}\")\n xml = response.body\n end\n\n return xml\n end",
"def show\n @website = Website.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @website }\n end\n end",
"def show\n @lab_rack = LabRack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lab_rack }\n end\n end",
"def show\n @port_info = PortSummary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @port_info }\n end\n end",
"def url\n @url ||= \"https://#{@host}/#{druid_without_prefix}.xml\"\n end",
"def index\n @websites = Website.find(:all, :order => 'name')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @websites.to_xml }\n end\n end",
"def servers\n endpoint = 'https://pcs.baidu.com/rest/2.0/pcs/manage?method=listhost'\n @res = @api.request_json( endpoint )\n end",
"def get_flows()\n\tputs \"Getting flows\"\n\tresponse = request_get('/api/partner/flow')\n\tputs response.body\nend",
"def show\n @erratum = Erratum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @erratum }\n end\n end",
"def index\n @transport_lines = TransportLine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transport_lines }\n end\n end",
"def servers_detailed()\n return get_request(address(\"/servers/detail\"), @token)\n end",
"def index\n @service_versions = ServiceVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @service_versions }\n end\n end",
"def index\n @certs = Cert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @certs }\n end\n end",
"def show\n @hostela = Hostela.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hostela }\n end\n end",
"def url\n Addressable::URI.new :scheme => 'http',\n :host => endpoint.host,\n :path => '/onca/xml',\n :query_values => parameters\n end",
"def get(path)\n HTTParty.get(\"http://localhost:3000#{path}\")\nend",
"def probe(url)\n # @todo Create args options Hash to dynamically configure settings.\n raise ArgumentError.new, \"Incorrect number of arguments: expected 1.\" if url.nil? \n\n # Associate argument with @uri element tag for future logging purposes.\n # Will also serve for faster clash checking (aka w/o DBMS)\n url = URI.parse(url)\n @uri = url\n\n #Create NET::HTTP request to the specified IP\n http = Net::HTTP.new(url.host, url.port)\n http.read_timeout, http.open_timeout = 3\n \n request = Net::HTTP::Get.new(url)\n request['User-Agent'] = \"Gerridae Gem\"\n request['Accept'] = \"*/*\"\n \n # Gather response, switch code to string, add it to content hash.\n response = http.request(request)\n code = response.code.to_s \n @content[:return_code] = code\n\n\n # todo Abstract to own method within Helpers module.\n if Helpers::is_good_http_response? code.to_i \n @content = { :http_version => response.http_version, :message => response.message }\n\n # @todo Use JSON parsing method here\n response.each do |key, value|\n @content[key.to_sym] = value unless key.nil? && value.nil? \n end\n #todo Return HTTP code to indicate success.\n end\n #todo Return nil or other failure indicator for failure.\n\n end",
"def endpoint\n \"https://#{@host}:#{@port}/wsman\"\n end",
"def get_host_xml(mac)\n xml = \"\"\n hosts.each do |host|\n if host[:mac] == mac\n return \"<host mac='#{host[:mac]}' name='#{host[:name]}' ip='#{host[:ip]}' />\"\n end\n end\n xml\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @site }\n end\n end"
] | [
"0.69564337",
"0.6650198",
"0.66445667",
"0.65678656",
"0.63863635",
"0.63815725",
"0.6205011",
"0.61212337",
"0.6086184",
"0.6044151",
"0.59948623",
"0.59616804",
"0.5838251",
"0.58010316",
"0.57935536",
"0.57739466",
"0.57423043",
"0.56908023",
"0.5686185",
"0.56332624",
"0.5600848",
"0.5594048",
"0.55813676",
"0.5571654",
"0.5562333",
"0.55572313",
"0.55546886",
"0.55363715",
"0.55327445",
"0.5505525",
"0.5497652",
"0.54935884",
"0.5493035",
"0.5487357",
"0.5478756",
"0.54738885",
"0.5473408",
"0.5466736",
"0.5466531",
"0.546551",
"0.54549474",
"0.54498535",
"0.5447175",
"0.5444467",
"0.54433686",
"0.5442421",
"0.5431417",
"0.54295266",
"0.5426207",
"0.5426207",
"0.5426207",
"0.5423823",
"0.54226947",
"0.5419315",
"0.5408394",
"0.54071945",
"0.54071945",
"0.54071945",
"0.54071945",
"0.54071945",
"0.5405986",
"0.53940856",
"0.53778034",
"0.5368933",
"0.5364617",
"0.53596663",
"0.5358464",
"0.5357638",
"0.5354721",
"0.5350433",
"0.53493094",
"0.534854",
"0.5345099",
"0.5343513",
"0.5340894",
"0.5336748",
"0.5336748",
"0.533615",
"0.5328499",
"0.53206193",
"0.53206015",
"0.5319469",
"0.5319126",
"0.5317877",
"0.5311373",
"0.53090245",
"0.5306788",
"0.52983105",
"0.5294436",
"0.5294155",
"0.52931887",
"0.5284461",
"0.5283433",
"0.5279177",
"0.5275652",
"0.527313",
"0.5269809",
"0.52674454",
"0.5255398",
"0.5255075"
] | 0.6760495 | 1 |
GET /hostnesses/new GET /hostnesses/new.xml | def new
@hostness = Hostness.new
form_vars
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @hostness }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @hostel = Hostel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hostel }\n end\n end",
"def new\n @search = Host.search params[:search]\n @host = Host.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @host }\n end\n end",
"def new\n @host = Host.new\n @roles = Role.find(:all, :order => 'role')\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @host }\n end\n end",
"def new\n @host = Host.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @host }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def newX\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @server }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def create\n @hostness = Hostness.new(params[:hostness])\n\n respond_to do |format|\n if @hostness.save\n format.html { redirect_to(hostnesses_path, :notice => 'Hostness was successfully created.') }\n format.xml { render :xml => @hostness, :status => :created, :location => @hostness }\n else\n format.html { form_vars; render :action => \"new\" }\n format.xml { render :xml => @hostness.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @demo_host_setting = Demo::HostSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @demo_host_setting }\n end\n end",
"def new\n @title = \"New Networks\"\n @network = Network.new\n @computers = Computer.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @network }\n end\n end",
"def new\n @pneighbour = Pneighbour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pneighbour }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @system }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def new\n @rails_url = RailsUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rails_url }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software }\n end\n end",
"def new\n @server_rack = ServerRack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @server_rack }\n end\n end",
"def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cloud }\n end\n end",
"def new\n @probe = Probe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @probe }\n end\n end",
"def new\n @cluster = Cluster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cluster }\n end\n end",
"def new\n @client_app = ClientApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @seed }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def index\n @hostnesses = Hostness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @hostnesses }\n end\n end",
"def new\n @website = Website.new params[:website]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @website }\n end\n end",
"def new\n @latestinfo = Latestinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @latestinfo }\n end\n end",
"def new\n @production = Production.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @production }\n end\n end",
"def show\n @hostness = Hostness.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hostness }\n end\n end",
"def create\n @host = Host.new(params[:host])\n\n respond_to do |format|\n if @host.save\n flash[:notice] = 'Host was successfully created.'\n format.html { redirect_to host_url(@host) }\n format.xml { head :created, :location => host_url(@host) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @host.errors.to_xml }\n end\n end\n end",
"def new\n @lookup_hardware = LookupHardware.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_hardware }\n end\n end",
"def new\n @shelf = Shelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shelf }\n end\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @neighborhood }\n end\n end",
"def new\n @computer = Computer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @computer }\n end\n end",
"def new\n @computer = Computer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @computer }\n end\n end",
"def new\n submenu_item 'agents-new'\n @agent = Agent.new(:host_id => params[:host_id])\n dictionary\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @agent }\n end\n end",
"def new\n @threat = Threat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @threat }\n end\n end",
"def new\n @host_tpl = HostTpl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @host_tpl }\n end\n end",
"def new\n @machine = Machine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine }\n end\n end",
"def new\n @hostela = Hostela.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hostela }\n end\n end",
"def new\n @topiccluster = Topiccluster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topiccluster }\n end\n end",
"def new\n @way = Way.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @way }\n end\n end",
"def new\n @ep = Ep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ep }\n end\n end",
"def new\n @lookup_switchboard = LookupSwitchboard.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_switchboard }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end",
"def new\n @transport = Transport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transport }\n end\n end",
"def new\n @transport = Transport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transport }\n end\n end",
"def new\n @transport = Transport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transport }\n end\n end",
"def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def create\n @host = Host.new(params[:host])\n\n respond_to do |format|\n if @host.save\n flash[:notice] = 'Host was successfully created.'\n format.html { redirect_to host_url(@host) }\n format.xml { head :created, location: host_url(@host) }\n else\n format.html { render action: 'new' }\n format.xml { render xml: @host.errors.to_xml }\n end\n end\n end",
"def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end",
"def new\n @house = House.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @house }\n end\n end",
"def new\n @partytype = Partytype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @partytype }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @compliance }\n end\n end",
"def new\n @domain = Domain.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @domain }\n end\n end",
"def new\n @proyect = Proyect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @proyect }\n end\n end",
"def new\n @quirk = Quirk.new()\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quirk }\n end\n end",
"def new\n @service_version = ServiceVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_version }\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @thred = Thred.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thred }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @subway = Subway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @subway }\n end\n end",
"def new\n @machine = Machine.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine }\n end\n end",
"def new\n @components_front_lever = Components::FrontLever.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @components_front_lever }\n end\n end",
"def new\n @uri_type = UriType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uri_type }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @helocapp = Helocapp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @helocapp }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hacker }\n end\n end",
"def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @part }\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n @client = Client.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @client }\n end\n\n end",
"def new\n @upgrade = Upgrade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @upgrade }\n end\n end",
"def create\n @hostel = Hostel.new(params[:hostel])\n\n respond_to do |format|\n if @hostel.save\n format.html { redirect_to(@hostel, :notice => 'Hostel was successfully created.') }\n format.xml { render :xml => @hostel, :status => :created, :location => @hostel }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @hostel.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_rest\n @entry_answer = EntryAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_answer }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n @resource = Resource.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n logger.debug 'new_some interesting information'\n @comdty = Comdty.new\n setvariables\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comdty }\n end\n end",
"def new\n @soft = Soft.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @soft }\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @site }\n format.xml { render :xml => @site }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @monkey }\n end\n end",
"def new\n @helibasis = Helibase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @helibasis }\n end\n end",
"def new\n @lookup_source = LookupSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_source }\n end\n end",
"def new\n @mechanism = Mechanism.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mechanism }\n end\n end",
"def new \n @how_to = HowTo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @how_to }\n end\n end",
"def new\n @brother = Brother.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @brother }\n end\n end",
"def new\n @howto = Howto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @howto }\n end\n end",
"def new\n @erratum = Erratum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @erratum }\n end\n end",
"def new\n @reqinfo = Reqinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reqinfo }\n end\n end",
"def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end"
] | [
"0.7179569",
"0.68829554",
"0.6757467",
"0.6683666",
"0.6638123",
"0.656303",
"0.6513526",
"0.6488726",
"0.6478186",
"0.64642197",
"0.6353725",
"0.63527936",
"0.63490635",
"0.6342386",
"0.6342386",
"0.6342386",
"0.6342386",
"0.6342386",
"0.6342386",
"0.6342386",
"0.6342386",
"0.63298905",
"0.63008976",
"0.6300631",
"0.62875384",
"0.6283524",
"0.6281444",
"0.6272011",
"0.62338626",
"0.62296295",
"0.6216673",
"0.62147146",
"0.62040806",
"0.6203722",
"0.6202159",
"0.61992276",
"0.6197822",
"0.61791635",
"0.6178212",
"0.61745423",
"0.61745423",
"0.61724323",
"0.61697996",
"0.61680853",
"0.61677915",
"0.6163963",
"0.61565876",
"0.6141907",
"0.6136799",
"0.6129931",
"0.6126287",
"0.61118084",
"0.61118084",
"0.61118084",
"0.61116946",
"0.61112297",
"0.61103976",
"0.610749",
"0.6093153",
"0.6092432",
"0.60896546",
"0.60798967",
"0.60766214",
"0.60753095",
"0.60675085",
"0.60675085",
"0.60675085",
"0.60671926",
"0.60603714",
"0.60603714",
"0.60598063",
"0.6054668",
"0.6054328",
"0.6052801",
"0.6045569",
"0.6045569",
"0.6042443",
"0.6041042",
"0.6036807",
"0.6035045",
"0.60295314",
"0.60283226",
"0.602585",
"0.6021591",
"0.60191524",
"0.60189503",
"0.60176575",
"0.6016364",
"0.600732",
"0.60067534",
"0.6005249",
"0.60042185",
"0.6003784",
"0.6003042",
"0.5999844",
"0.5997949",
"0.5993718",
"0.5990083",
"0.5989423",
"0.5987386"
] | 0.67921734 | 2 |
POST /hostnesses POST /hostnesses.xml | def create
@hostness = Hostness.new(params[:hostness])
respond_to do |format|
if @hostness.save
format.html { redirect_to(hostnesses_path, :notice => 'Hostness was successfully created.') }
format.xml { render :xml => @hostness, :status => :created, :location => @hostness }
else
format.html { form_vars; render :action => "new" }
format.xml { render :xml => @hostness.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def create\n @host = Host.new(params[:host])\n\n respond_to do |format|\n if @host.save\n flash[:notice] = 'Host was successfully created.'\n format.html { redirect_to host_url(@host) }\n format.xml { head :created, :location => host_url(@host) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @host.errors.to_xml }\n end\n end\n end",
"def create\n @host = Host.new(params[:host])\n\n respond_to do |format|\n if @host.save\n flash[:notice] = 'Host was successfully created.'\n format.html { redirect_to host_url(@host) }\n format.xml { head :created, location: host_url(@host) }\n else\n format.html { render action: 'new' }\n format.xml { render xml: @host.errors.to_xml }\n end\n end\n end",
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end",
"def create\n @hostel = Hostel.new(params[:hostel])\n\n respond_to do |format|\n if @hostel.save\n format.html { redirect_to(@hostel, :notice => 'Hostel was successfully created.') }\n format.xml { render :xml => @hostel, :status => :created, :location => @hostel }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @hostel.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def addhost(config)\n\n uri = URI.parse(\"#{config[\"addurl\"]}\")\n node = { \"EntityType\" => \"Orion.Nodes\", \"IPAddress\" => \"#{config[\"ipaddr\"]}\",\n \"Caption\"=> \"#{config[\"nodename\"]}\", \"DynamicIP\" => \"False\", \"EngineID\" => \"#{config[\"engineid\"]}\", \n \"Status\" => 1, \"UnManaged\" => \"False\", \"Allow64BitCounters\" => \"True\", \n \"SysObjectID\" => \"\", \"MachineType\" => \"\", \"VendorIcon\" => \"\", \n \"ObjectSubType\" => \"SNMP\", \"SNMPVersion\" => 2, \"Community\" => \"#{config[\"community\"]}\",\n }\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})\n request.body = node.to_json\n request.basic_auth(\"#{config[\"username\"]}\", \"#{config[\"password\"]}\")\n\n response = http.request(request)\nend",
"def post_headers\n {\"Content-Type\" => 'text/xml; charset=utf-8'}\n end",
"def create\n @demo_host_setting = Demo::HostSetting.new(params[:demo_host_setting])\n\n respond_to do |format|\n if @demo_host_setting.save\n format.html { redirect_to(@demo_host_setting, :notice => 'Host setting was successfully created.') }\n format.xml { render :xml => @demo_host_setting, :status => :created, :location => @demo_host_setting }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @demo_host_setting.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_xml_to_server(server, xml)\n http = Net::HTTP.new(server.host, 8443)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n headers = {\n 'HTTP_AUTH_LOGIN' => server.username,\n 'HTTP_AUTH_PASSWD' => server.password,\n 'Content-Type' => 'text/xml',\n }\n\n path = \"/enterprise/control/agent.php\"\n res, data = http.post2(path, xml, headers)\n return res.body\n end",
"def register_peer\n puts \"Registering with Index Server at #{@index_server_host}\\n\"\n begin \n HTTParty.post(\n \"#{@index_server_host}/register_peer\", \n {body: {peer_id: @peer_id, host: @peer_host}}\n )\n rescue => e\n puts \"Failed to register with Index Server. Exiting...\"\n exit false\n end\n puts \"Successfully registered with Index Server - #{@peer_id}\"\nend",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def create\n @host = Host.new(params[:host])\n\n respond_to do |format|\n if @host.valid? && @host.save\n flash[:notice] = 'Host was successfully created.'\n format.html { redirect_to(@host) }\n format.xml { render :xml => @host, :status => :created, :location => @host }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @host.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_post(data_xml,url)\r\n result = @client.post(self.target_uri(url), :body => data_xml , :head => {'Content-Type' => 'application/xml'} ) \r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200') \r\n #reply = Reply.from_xml(result.http_body)\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end",
"def upload_facts(host_json, host = '')\n curl = setup_curl(\"#{@foreman_url}/api/hosts/facts\")\n curl.headers['Accept'] = 'application/json,version=2'\n curl.headers['Content-Type'] = 'application/json'\n curl.http_post(host_json)\n result = JSON.parse(curl.body_str)\n raise result['message'] if result['message'] =~ /^ERF51/\n result\n rescue => e\n warn \"Could not push #{host}: #{e}\"\n false\n end",
"def post_inventories(name,description, organization=1,variables='')\n dprint \"/api/v1/hosts\"\n resp = @rest['/api/v1/hosts'].post({\n :name => name,\n :description => description,\n :organization => organization,\n :variables => variables\n })\n dprint resp\n\n #[XXX] Theoretical what this is at this point - need to see \n # actual response\n JSON.parse(resp)[\"results\"]\n end",
"def post_query( xml )\n url = URI.parse( self.url )\n response = self.http.post_form( url, { \"query\" => xml } )\n return response.body\n end",
"def create\n @host = Host.new(params[:host])\n\n if @host.save\n render json: @host, status: :created, location: @host\n else\n render json: @host.errors, status: :unprocessable_entity\n end\n end",
"def index\n @hostnesses = Hostness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @hostnesses }\n end\n end",
"def create\n @host = Host.new(host_params)\n\n if @host.save\n render json: @host, status: :created, location: @host\n else\n render json: @host.errors, status: :unprocessable_entity\n end\n end",
"def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n end",
"def create\n @configuration = current_host.configuration_parameters.build(params[:configuration])\n\n respond_to do |format|\n if @configuration.save\n flash[:notice] = 'hostConfiguration was successfully created.'\n format.html { redirect_to host_url(current_host) }\n format.xml { head :created, :location => host_url(current_host) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @host_configuration.errors.to_xml }\n end\n end\n end",
"def send_xml(out_xml)\n uri = URI.parse(@url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n\n @logger.error \"#$%$ #{@user}\"\n request.basic_auth @user, @password\n request.body = out_xml\n\n log(\"Sending request: #{request.inspect}\")\n response = http.request(request)\n\n log(\"Response: #{response}\")\n return response.body\n end",
"def post_config(url_prefix, xml)\n url_prefix = URI.escape(\"#{@jenkins_path}#{url_prefix}\")\n http = Net::HTTP.start(@server_ip, @server_port)\n request = Net::HTTP::Post.new(\"#{url_prefix}\")\n puts \"[INFO] PUT #{url_prefix}\" if @debug\n request.basic_auth @username, @password\n request.body = xml\n request.content_type = 'application/xml'\n response = http.request(request)\n response.code\n end",
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end",
"def post\n response = HTTParty.post(servlet_url,\n :body => to_xml,\n :headers => { 'Content-Type' => 'application/xml' }\n ).response\n\n return Dhl::Shipment::Response.new(response.body)\n rescue Exception => e\n request_xml = if @to_xml.to_s.size>0\n @to_xml\n else\n '<not generated at time of error>'\n end\n\n response_body = if (response && response.body && response.body.to_s.size > 0)\n response.body\n else\n '<not received at time of error>'\n end\n\n log_level = if e.respond_to?(:log_level)\n e.log_level\n else\n :critical\n end\n\n log_request_and_response_xml(log_level, e, request_xml, response_body )\n raise e\n end",
"def post(body)\n request = Net::HTTP::Post.new(bind_uri)\n request.body = body\n request.content_length = request.body.size\n request[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\n Jabber.debug(\"Sending POST request - #{body.strip}\")\n\n response = Net::HTTP.new(domain, port).start { |http| http.request(request) }\n\n Jabber.debug(\"Receiving POST response - #{response.code}: #{response.body.inspect}\")\n\n unless response.is_a?(Net::HTTPSuccess)\n raise Net::HTTPBadResponse, \"Net::HTTPSuccess expected, but #{response.class} was received\"\n end\n\n response\n end",
"def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'text/xml'\n request['Accept-Language'] = locale if locale\n request.body = body\n\n response = http.request(request)\n\n Response.new(response, uri)\n end",
"def new\n @hostness = Hostness.new\n form_vars\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hostness }\n end\n end",
"def remote_create(content)\n content = content.to_xml unless content.kind_of? String\n remote_post content\n end",
"def run(host, key, user, port)\n xml = build_command(@action, @object, @params, @cookie)\n\n md5_signature = Digest::MD5.hexdigest(\n Digest::MD5.hexdigest(\n xml + key\n ) + key\n )\n\n headers = {\n 'Content-Type' => 'text/xml',\n 'X-Username' => user,\n 'X-Signature' => md5_signature,\n 'Content-Length' => xml.size.to_s\n }\n\n http = Net::HTTP.new(URI.encode(host), port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n #http.ca_file = File.join(File.dirname(__FILE__), \"../..\", \"cacert.pem\")\n res = http.post(URI.encode(\"/\"), xml, headers)\n\n @returned_parameters = parse_response(res.body)\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n \n # Create integer copy of IP address\n params[:host][:ip_int] = Host.ip_as_int params[:host][:ip]\n\n @search = Host.search params[:search]\n @host = Host.new(params[:host])\n\n respond_to do |format|\n if @host.save\n flash[:notice] = 'Host was successfully created.'\n format.html { redirect_to(@host) }\n format.xml { render :xml => @host, :status => :created, :location => @host }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @host.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\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 response.body\n end",
"def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end",
"def post_request(params, useSSL=false)\n # get a server handle\n port = (useSSL == true) ? 443 : 80\n http_server = Net::HTTP.new(API_HOST, port)\n http_server.use_ssl = useSSL\n \n # build a request\n http_request = Net::HTTP::Post.new(API_PATH_REST)\n http_request.form_data = params\n \n # get the response XML\n return http_server.start{|http| http.request(http_request)}.body\n end",
"def create\n @host_address = HostAddress.new(host_address_params)\n respond_to do |format|\n if @host_address.save\n format.html { redirect_to @host_address, notice: 'Host address was successfully created.' }\n format.json { render :show, status: :created, location: @host_address }\n else\n format.html { render :new }\n format.json { render json: @host_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(data)\n uri = URI(@host)\n res = Net::HTTP.post_form(uri, {shell: data})\n # puts res.body\nend",
"def posttestrail(runId, caseId, statusId, versionId, elapsedseconds)\r\n\r\n uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=#{runId}&case_id=#{caseId}&status_id=#{statusId}&version=#{versionId}&elapsed_seconds=#{elapsedseconds}&sharedSecret=thI5iSourSHAREDsecret\"\r\n #uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=110324&case_id=665022&status_id=1&version=Test&elapsed_seconds=12&sharedSecret=thI5iSourSHAREDsecret\"\r\n\r\n uri = uri.gsub(\" \", \"%20\")\r\n xml_data = open(uri).read\r\n if(xml_data.include? '\"test_id\":')\r\n recorded = xml_data.split('\"test_id\":')[1]\r\n testID = recorded.split(',\"status_id\"')[0]\r\n puts \"TestID:\"+testID\r\n else\r\n puts xml_data\r\n fail \"Cannot Post result to Testrail, check Webservice\"\r\n end\r\n\r\n timeStamp = Time.now.strftime (\"posted at %H:%M %d/%m/%Y\")\r\n files = \"//zgbwcfs3005.jupiter.bbc.co.uk/QA/Jenkins/Jupiter/ICETEAresultupdatelog.txt\"\r\n f = File.open(files,'a')\r\n f.write \"#{testID} #{timeStamp}\"\r\n f.close\r\nend",
"def post(method, params = {})\n url = make_url method, params\n query = url.query\n url.query = nil\n\n req = Net::HTTP::Post.new url.path\n req.body = query\n req.content_type = 'application/x-www-form-urlencoded'\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body) { |cfg| cfg.strict }\n check_error xml\n raise CommunicationError.new(e)\n end",
"def create\n @host = Host.new(params[:host])\n @host.deleted = false\n\n respond_to do |format|\n if @host.save\n format.html { redirect_to hosts_path, notice: 'Host was successfully created.' }\n format.json { render json: @host, status: :created, location: @host }\n else\n format.html { render :new }\n format.json { render json: @host.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hostness = Hostness.find(params[:id])\n\n respond_to do |format|\n if @hostness.update_attributes(params[:hostness])\n format.html { redirect_to(hostnesses_path, :notice => 'Hostness was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { form_vars; render :action => \"edit\" }\n format.xml { render :xml => @hostness.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @host = Host.new(host_params)\n respond_to do |format|\n if @host.save\n format.html { redirect_to data_source_hosts_path(@host.data_source_id), notice: 'Host was successfully created.' }\n format.json { render :show, status: :created, location: @host }\n else\n format.html { render :new }\n format.json { render json: @host.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_report(json, cookbookname)\n data = File.read(json)\n uri = URI.parse($SPEC_ENDPOINT)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(\"/api/reports\")\n request.add_field('Content-Type', 'application/json')\n request.body = {\n :spec_result => data,\n :hostname => `hostname`.chomp,\n :cookbook_name => cookbookname\n }.to_json\n response = http.request(request)\n end",
"def as_host_xml\n xml = \"\"\n hosts.each do |host|\n xml = xml + \"<host mac='#{host[:mac]}' name='#{host[:name]}' ip='#{host[:ip]}' />\"\n end\n xml\n end",
"def post_check(excon, body)\n excon.request(\n method: :post,\n path: '/check',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def do_submission(path, xml = nil)\n if xml.nil?\n form = create(:form, question_types: %w(integer integer))\n form.publish!\n xml = build_odk_submission(form)\n end\n\n # write xml to file\n require 'fileutils'\n FileUtils.mkpath('test/fixtures')\n fixture_file = Rails.root.join('test/fixtures/', ODK_XML_FILE)\n File.open(fixture_file.to_s, 'w') { |f| f.write(xml) }\n\n # Upload and do request.\n uploaded = fixture_file_upload(fixture_file, 'text/xml')\n post(path, {:xml_submission_file => uploaded, :format => 'xml'}, 'HTTP_AUTHORIZATION' => encode_credentials(@user.login, 'password'))\n assigns(:response)\n end",
"def create\n @node_config = NodeConfig.new(params[:node_config])\n\n respond_to do |format|\n if @node_config.save\n format.xml { render :xml => @node_config, :status => :created, :location => @node_config }\n format.any { render :json => @node_config, :status => :created, :location => @node_config }\n else\n format.xml { render :xml => @node_config.errors, :status => :unprocessable_entity }\n format.any { render :json => @node_config.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def send_post(address, params = {})\n\t\t\turi = URI.parse create_url(address)\n\n\t\t\treq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' => 'application/json'})\n\t\t\treq.body = params.to_json\n\n\t\t\tcurrTime = ::Time.now.to_i\n\t\t\treq['Date'] = currTime.to_s\n\t\t\treq['Sig'] = Digest::MD5.hexdigest(\"#{params.to_json}--#{currTime}--#{GameServer.account_server_private_key}\")\n\n\t\t\tres = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }\n\n\t\t\tdata = JSON.parse(res.body).deep_symbolize_keys\n\t\t\tp \"--- account server data ---\", data\n\t\t\tdata\n\t\tend",
"def host_params\n params.require(:host).permit(:name, :web_link, :market_info)\n end",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n @server_rack = ServerRack.new(params[:server_rack])\n\n respond_to do |format|\n if @server_rack.save\n format.html { redirect_to(@server_rack, :notice => 'Server rack was successfully created.') }\n format.xml { render :xml => @server_rack, :status => :created, :location => @server_rack }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @server_rack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def POST; end",
"def destroy\n @hostness = Hostness.find(params[:id])\n @hostness.destroy\n\n respond_to do |format|\n format.html { redirect_to(hostnesses_url) }\n format.xml { head :ok }\n end\n end",
"def host_params\n params.fetch(:host, {}).permit(:ip, :fqdn, :netbios_name, :mac_address, :cpe, :platform, :operating_system, :system_type, :data_source_id)\n end",
"def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end",
"def post_stomp(msg,headers)\n \n response_header = {\"Content-type\" => \"text/xml\"}\n response_header.merge headers\n ht =Net::HTTP.start(self.host,self.port)\n url = self.url # + \"/\" + self.topic\n puts \"posting to: #{self.host}: #{self.port} #{url} message: #{msg.to_xml}\"\n r=ht.post(url,msg.to_xml,response_header)\n \n puts \"result: #{r.to_s}\"\n r\n end",
"def create\n @hostel_form = HostelForm.new(hostel_form_params)\n\n respond_to do |format|\n if @hostel_form.save\n format.html { redirect_to @hostel_form }\n format.json { render :show, status: :created, location: @hostel_form }\n else\n format.html { render :new }\n format.json { render json: @hostel_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hostela = Hostela.new(params[:hostela])\n\n respond_to do |format|\n if @hostela.save\n format.html { redirect_to @hostela, notice: 'Hostela was successfully created.' }\n format.json { render json: @hostela, status: :created, location: @hostela }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hostela.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n HTTParty.post(create_url, :options => { :headers => HEADERS })\n end",
"def post(attrs = nil)\n attrs ||= attributes\n execute_request do\n faraday_connection.post { |req| req.body = adapter.serialize(attrs) }\n end\n end",
"def add_tenant_to_specified_shard(args = {}) \n post(\"/tenants.json/shard/#{args[:shardId]}\", args)\nend",
"def create\n host_name = begin\n Resolv.getname(request.ip)\n rescue Resolv::ResolvError\n end || 'n/a'\n\n params[:offense].merge!({:ip_address => request.ip, :host_name => host_name})\n\n @offense = Offense.new(offense_params)\n respond_to do |format|\n if @offense.save\n if @offense.email?\n self.email\n end\n if @offense.phone?\n self.sms\n end\n format.html { redirect_to @offense, notice: 'Offense was successfully created.' }\n format.json { render :show, status: :created, location: @offense }\n else\n format.html { render :new }\n format.json { render json: @offense.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send\n post_params = {}\n self.parameters.each { |key, value|\n if value.is_a? Array\n i = 0\n value.each { |value_value|\n post_params[key.to_s + '[' + i.to_s + ']'] = value_value.to_s\n i += 1\n }\n elsif value.is_a? Hash\n value.each { |value_key, value_value|\n post_params[key.to_s + '[' + value_key.to_s + ']'] = value_value.to_s\n }\n else\n post_params[key.to_s] = value.to_s\n end\n }\n\n url = URI.parse(@@API_URL)\n http_request = Net::HTTP::Post.new(url.path)\n http_request.form_data = post_params\n http_request.basic_auth url.user, url.password if url.user\n\n response = Spree::PAYONE::Proxy::Response.new\n connection = Net::HTTP.new(url.host, url.port)\n load_ca_file connection\n connection.use_ssl = true\n connection.start { |http|\n http_response = http.request(http_request)\n response.response_body= http_response.body\n }\n\n response\n end",
"def sendToTrufina(xml)\n puts \"Sending XML to #{domain}#{endpoint}:\\n\\n#{xml}\\n\\n\" if Trufina::Config.debug?\n \n # Connection Info\n api = Net::HTTP.new( domain, 443 )\n api.use_ssl = true\n api.verify_mode = OpenSSL::SSL::VERIFY_NONE # Prevent annoying warnings\n \n # Request info\n method_call = Net::HTTP::Post.new( endpoint, {'Content-Type' => 'text/xml'} )\n method_call.body = xml\n\n if Config.staging?\n method_call.basic_auth(Config.staging_access[:username], Config.staging_access[:password])\n end\n \n # OK, execute the actual call\n response = api.request(method_call)\n raise Exceptions::NetworkError.new(response.msg) unless response.is_a?(Net::HTTPSuccess)\n parseFromTrufina(response.body)\n end",
"def ems\n GatewayMessage.store( params[:xml] )\n render :text => 'OK'\n end",
"def create\n return unless restrict_to_admin\n\n @event_host = @event.event_hosts.new(event_host_params)\n\n respond_to do |format|\n if @event_host.save\n format.html { redirect_to [@event, @event_host], notice: 'Event host was successfully created.' }\n format.json { render :show, status: :created, location: [@event, @event_host] }\n else\n format.html { render :new }\n format.json { render json: @event_host.errors, status: :unprocessable_entity }\n end\n end\n end",
"def postSignal( entity_id, country, gen_id, signal_type, data_type, inactive_reason, inactive_description, feedback)\n params = Hash.new\n params['entity_id'] = entity_id\n params['country'] = country\n params['gen_id'] = gen_id\n params['signal_type'] = signal_type\n params['data_type'] = data_type\n params['inactive_reason'] = inactive_reason\n params['inactive_description'] = inactive_description\n params['feedback'] = feedback\n return doCurl(\"post\",\"/signal\",params)\n end",
"def write_host_file\n puts \"Writing Apocalypse host file...\"\n host_config = {\n :hostname => @hostname,\n :server_address => @address, \n :port => @port, \n :username => @username, \n :password => @password\n }\n file = File.open(::Apocalypse::Client.host_file, \"w\") do |f|\n f.write host_config.to_yaml\n end \n end",
"def run(host, key, user, port)\n @returned_parameters = Faraday.new(:url => \"https://#{host}:#{port}\", :ssl => {:verify => true}) do |c|\n c.request :open_srs_xml_builder, @action, @object, @cookie, @params, key, user\n c.response :parse_open_srs\n c.response :open_srs_errors\n c.adapter :net_http\n end.post.body\n end",
"def new\n @hostel = Hostel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hostel }\n end\n end",
"def create_params\n params.require(:registry).permit(:name, :hostname, :use_ssl, :external_hostname)\n end",
"def create_params\n params.require(:registry).permit(:name, :hostname, :use_ssl, :external_hostname)\n end",
"def post\n uri = URI.parse(self.url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.open_timeout = 10\n http.read_timeout = 10\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n data = self.params.collect { |k, v| \"#{k}=#{CGI.escape(v.to_s)}\" }.join(\"&\")\n Freemium.log_test_msg(\"POST\\n url: #{self.url}\\n query: #{data}\")\n http.post(uri.request_uri, data).body\n end",
"def hostname_params\n params.require(:hostname).permit(:name, :ipaddress)\n end",
"def create_server_xml_vars\n @client_id = \"${cloud.services.#{@service_name}.connection.clientId}\"\n @client_secret = \"${cloud.services.#{@service_name}.connection.secret}\"\n @auth_url = \"${cloud.services.#{@service_name}.connection.authorizationEndpointUrl}\"\n @token_url = \"${cloud.services.#{@service_name}.connection.tokenEndpointUrl}\"\n @scope = \"${cloud.services.#{@service_name}.connection.serverSupportedScope}\"\n @issuer_identifier = \"${cloud.services.#{@service_name}.connection.issuerIdentifier}\"\n #YD 11102016 start - add PingFederate attributes\n puts '-----> Creating openidConnectClient configuration in server.xml for PingFederate'\n @grantType = \"${cloud.services.#{@service_name}.connection.grantType}\"\n @jwkEndpointUrl = \"${cloud.services.#{@service_name}.connection.jwkEndpointUrl}\"\n @signatureAlgorithm = \"${cloud.services.#{@service_name}.connection.signatureAlgorithm}\"\n @userIdentityToCreateSubject = \"${cloud.services.#{@service_name}.connection.userIdentityToCreateSubject}\"\n #YD 11102016 end - add PingFederate attributes\n parsed_vcap_app_data = JSON.parse(ENV['VCAP_APPLICATION'])\n @logger.debug(\"parsed_vcap_app_data is #{parsed_vcap_app_data}\")\n @host = parsed_vcap_app_data['uris'][0]\n end",
"def run_host(ip)\n\n\t\tverbs = [\n\t\t\t\t'get',\n\t\t\t\t'active',\n\t\t\t\t'create',\n\t\t\t\t'change',\n\t\t\t\t'set',\n\t\t\t\t'put',\n\t\t\t\t'do',\n\t\t\t\t'go',\n\t\t\t\t'resolve',\n\t\t\t\t'start',\n\t\t\t\t'recover',\n\t\t\t\t'initiate',\n\t\t\t\t'negotiate',\n\t\t\t\t'define',\n\t\t\t\t'stop',\n\t\t\t\t'begin',\n\t\t\t\t'end',\n\t\t\t\t'manage',\n\t\t\t\t'administer',\n\t\t\t\t'modify',\n\t\t\t\t'register',\n\t\t\t\t'log',\n\t\t\t\t'add',\n\t\t\t\t#'delete', # Best to be safe!\n\t\t\t]\n\n\t\tnouns = [\n\t\t\t\t'password',\n\t\t\t\t'task',\n\t\t\t\t'pass',\n\t\t\t\t'administration',\n\t\t\t\t'account',\n\t\t\t\t'admin',\n\t\t\t\t'login',\n\t\t\t\t'token',\n\t\t\t\t'credentials',\n\t\t\t\t'credential',\n\t\t\t\t'key',\n\t\t\t\t'guid',\n\t\t\t\t'message',\n\t\t\t\t'user',\n\t\t\t\t'username',\n\t\t\t\t'load',\n\t\t\t\t'list',\n\t\t\t\t'name',\n\t\t\t\t'file',\n\t\t\t\t'path',\n\t\t\t\t'directory',\n\t\t\t\t'configuration',\n\t\t\t\t'config',\n\t\t\t\t'setting',\n\t\t\t\t'settings',\n\t\t\t\t'registry',\n\t\t\t\t'on',\n\t\t\t\t'off',\n\t\t\t]\n\n\t\ttarget_port = datastore['RPORT']\n\t\tvhost = datastore['VHOST'] || wmap_target_host || ip\n\n\t\tbegin\n\t\t\t# Check service exists\n\t\t\tres = send_request_raw({\n\t\t\t\t'uri' => datastore['PATH'],\n\t\t\t\t'method' => 'GET',\n\t\t\t\t'vhost' => vhost,\n\t\t\t}, 10)\n\n\t\t\tif (res.code == 200)\n\t\t\t\tprint_status(\"PATH appears to be OK.\")\n\n\t\t\t\tverbs.each do |v|\n\t\t\t\t\tnouns.each do |n|\n\n\t\t\t\t\t\t# This could be cleaned up - patrickw\n\t\t\t\t\t\tdata = '<?xml version=\"1.0\" encoding=\"utf-8\"?>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '<soap:Envelope xmlns:xsi=\"' + datastore['XMLINSTANCE'] + '\" xmlns:xsd=\"' + datastore['XMLSCHEMA'] + '\" xmlns:soap=\"' + datastore['XMLSOAP'] + '\">' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '<soap:Body>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << \"<#{v}#{n}\" + \" xmlns=\\\"#{datastore['XMLNAMESPACE']}\\\">\" + \"\\r\\n\"\n\t\t\t\t\t\tdata << \"</#{v}#{n}>\" + \"\\r\\n\"\n\t\t\t\t\t\tdata << '</soap:Body>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '</soap:Envelope>' + \"\\r\\n\\r\\n\"\n\n\t\t\t\t\t\tres = send_request_raw({\n\t\t\t\t\t\t\t'uri' => datastore['PATH'] + '/' + v + n,\n\t\t\t\t\t\t\t'method' => 'POST',\n\t\t\t\t\t\t\t'vhost' => vhost,\n\t\t\t\t\t\t\t'data'\t\t=> data,\n\t\t\t\t\t\t\t'headers' =>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'Content-Length' => data.length,\n\t\t\t\t\t\t\t\t\t'SOAPAction'\t=> '\"' + datastore['XMLNAMESPACE'] + v + n + '\"',\n\t\t\t\t\t\t\t\t\t'Expect'\t=> '100-continue',\n\t\t\t\t\t\t\t\t\t'Content-Type'\t=> datastore['CONTENTTYPE'],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, 15)\n\n\t\t\t\t\t\tif (res && !(res.body.empty?))\n\t\t\t\t\t\t\tif (res.body =~ /method name is not valid/)\n\t\t\t\t\t\t\t\tprint_status(\"Server rejected SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\telsif (res.message =~ /Cannot process the message because the content type/)\n\t\t\t\t\t\t\t\tprint_status(\"Server rejected CONTENTTYPE: HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\t\tres.message =~ /was not the expected type\\s\\'([^']+)'/\n\t\t\t\t\t\t\t\tprint_status(\"Set CONTENTTYPE to \\\"#{$1}\\\"\")\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\telsif (res.code == 404)\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tprint_status(\"Server responded to SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\t\t## Add Report\n\t\t\t\t\t\t\t\treport_note(\n\t\t\t\t\t\t\t\t\t:host\t=> ip,\n\t\t\t\t\t\t\t\t\t:proto\t=> 'HTTP',\n\t\t\t\t\t\t\t\t\t:port\t=> rport,\n\t\t\t\t\t\t\t\t\t:type\t=> \"SOAPAction: #{v}#{n}\",\n\t\t\t\t\t\t\t\t\t:data\t=> \"SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\"\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif datastore['DISPLAYHTML']\n\t\t\t\t\t\t\t\t\tprint_status(\"The HTML content follows:\")\n\t\t\t\t\t\t\t\t\tprint_status(res.body + \"\\r\\n\")\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\telse\n\t\t\tprint_status(\"Server did not respond with 200 OK.\")\n\t\t\tprint_status(res.to_s)\n\t\tend\n\t\trescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout\n\t\trescue ::Timeout::Error, ::Errno::EPIPE\n\t\tend\n\tend",
"def create\n res = self.class.post('/', body: attrs)\n res.created?\n end",
"def send\n @system = \"\"\n yield @system\n\n result = 'qf=xml&xml=' + render_template( 'auth' )\n\n @url.post( @uri.path, result, @headers.merge('Content-length' => result.length.to_s) )\n end",
"def post_data; end",
"def post\n resource.post(request, response)\n end",
"def create\n @host_execution = HostExecution.new(host_execution_params)\n\n respond_to do |format|\n if @host_execution.save\n format.html { redirect_to @host_execution, notice: 'Host execution was successfully created.' }\n format.json { render :show, status: :created, location: @host_execution }\n else\n format.html { render :new }\n format.json { render json: @host_execution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def hosts\n @job = Job.find(params[:id])\n host_array = []\n @job.nodes.each do |node|\n host_array << \"#{node.private_dns_name} #{node.private_dns_name.split('.')[0]}\"\n end\n send_data host_array.join(\"\\n\"), :type => 'text/html; charset=utf-8'\n end",
"def commit(xml)\n url = (test? ? test_url : live_url)\n\n response = parse(ssl_post(url, post_data(xml), 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'))\n\n Response.new(\n success_from(response),\n message_from(response),\n response,\n authorization: authorization_from(response),\n test: test?,\n error_code: error_code_from(response)\n )\n end",
"def create\n @host_state = HostState.new(host_state_params)\n\n respond_to do |format|\n if @host_state.save\n format.html { redirect_to @host_state, notice: 'Host state was successfully created.' }\n format.json { render :show, status: :created, location: @host_state }\n else\n format.html { render :new }\n format.json { render json: @host_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @demo_host_setting = Demo::HostSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @demo_host_setting }\n end\n end",
"def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params.to_xml, signature_params)\n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, 'rack.input' => rack_input\nend",
"def create\n @discovery = Discovery.new(params[:discovery])\n\n respond_to do |format|\n if @discovery.save\n flash[:notice] = 'Discovery was successfully created.'\n format.html { redirect_to(@discovery) }\n format.xml { render :xml => @discovery, :status => :created, :location => @discovery }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @discovery.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def zabbix_server_params\n params.require(:zabbix_server).permit(:fqdn, :username, :password, :details)\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def create_server(zone: \"fi-hel1\", title:, hostname:, core_number: 1,\n memory_amount: 1024, storage_devices:, ip_addresses: :all)\n data = {\n \"server\" => {\n \"zone\" => zone,\n \"title\" => title,\n \"hostname\" => hostname,\n \"core_number\" => core_number,\n \"memory_amount\" => memory_amount,\n \"storage_devices\" => { \"storage_device\" => storage_devices }\n }\n }\n\n if ip_addresses != :all\n ips = []\n ips << { \"access\" => \"public\", \"family\" => \"IPv4\" } if ip_addresses.include? :public\n ips << { \"access\" => \"private\", \"family\" => \"IPv4\" } if ip_addresses.include? :private\n ips << { \"access\" => \"public\", \"family\" => \"IPv6\" } if ip_addresses.include? :ipv6\n\n data[\"server\"][\"ip_addresses\"] = {}\n data[\"server\"][\"ip_addresses\"][\"ip_address\"] = ips\n end\n\n json = JSON.generate data\n response = post \"server\", json\n response\n end",
"def host_params\n params.require(:host).permit(:fullname, :email, :image, :contact)\n end",
"def create(params)\n http.post(\"/nfse\", { body: params }) do |response|\n respond_with_entity(response)\n end\n end",
"def create\n @quirk = Quirk.accessible_by(current_ability).new(params[:quirk])\n\n respond_to do |format|\n if @quirk.save\n flash[:notice] = 'Quirk was successfully created.'\n format.html { redirect_to(@quirk) }\n format.xml { render :xml => @quirk, :status => :created, :location => @quirk }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quirk.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def serveOAI\n content_type 'text/xml;charset=utf-8'\n provider = EscholProvider.new\n provider.process_request(params)\n end"
] | [
"0.5698757",
"0.55954844",
"0.5579512",
"0.5578174",
"0.5548586",
"0.5535028",
"0.54966384",
"0.54574406",
"0.5428928",
"0.5425906",
"0.54229516",
"0.5422574",
"0.5414821",
"0.5387365",
"0.5379054",
"0.53437716",
"0.53436977",
"0.5343105",
"0.5320054",
"0.52994925",
"0.52985454",
"0.5284432",
"0.52683467",
"0.5255996",
"0.52236205",
"0.51892215",
"0.51801974",
"0.5161771",
"0.5150002",
"0.51467013",
"0.51425225",
"0.5139714",
"0.5132734",
"0.5124693",
"0.51226676",
"0.50625455",
"0.5059117",
"0.5055781",
"0.50544983",
"0.50466967",
"0.50411785",
"0.50282",
"0.5015354",
"0.5012975",
"0.5006895",
"0.49967462",
"0.49920076",
"0.49753428",
"0.49696386",
"0.49659368",
"0.4962935",
"0.49417514",
"0.49414286",
"0.49383745",
"0.49332938",
"0.49304292",
"0.49159682",
"0.48965126",
"0.48922983",
"0.48890784",
"0.4882871",
"0.487581",
"0.48731455",
"0.48633835",
"0.486313",
"0.4853889",
"0.48522398",
"0.4844387",
"0.48373184",
"0.48345712",
"0.48318478",
"0.48264703",
"0.48263097",
"0.48193118",
"0.47960824",
"0.47960824",
"0.47954974",
"0.4793864",
"0.4793835",
"0.4791947",
"0.4774192",
"0.47645682",
"0.47603193",
"0.4751131",
"0.47505015",
"0.4748165",
"0.4743509",
"0.4742512",
"0.47420958",
"0.47369093",
"0.47343057",
"0.47323507",
"0.47307596",
"0.47297797",
"0.47279644",
"0.47235534",
"0.47222736",
"0.47134194",
"0.4712265",
"0.47074288"
] | 0.6325835 | 0 |
PUT /hostnesses/1 PUT /hostnesses/1.xml | def update
@hostness = Hostness.find(params[:id])
respond_to do |format|
if @hostness.update_attributes(params[:hostness])
format.html { redirect_to(hostnesses_path, :notice => 'Hostness was successfully updated.') }
format.xml { head :ok }
else
format.html { form_vars; render :action => "edit" }
format.xml { render :xml => @hostness.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 opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @host = Host.find(params[:id])\n\n respond_to do |format|\n if @host.update_attributes(params[:host])\n flash[:notice] = 'Host was successfully updated.'\n format.html { redirect_to(@host) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @host.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @host = Host.find(params[:id])\n\n respond_to do |format|\n if @host.update_attributes(params[:host])\n flash[:notice] = 'Host was successfully updated.'\n format.html { redirect_to host_url(@host) }\n format.xml { head :ok }\n else\n format.html { render action: 'edit' }\n format.xml { render xml: @host.errors.to_xml }\n end\n end\n end",
"def update\n @host = Host.find(params[:id])\n\n respond_to do |format|\n if @host.update_attributes(params[:host])\n flash[:notice] = 'Host was successfully updated.'\n format.html { redirect_to host_url(@host) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @host.errors.to_xml }\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 @hostel = Hostel.find(params[:id])\n\n respond_to do |format|\n if @hostel.update_attributes(params[:hostel])\n format.html { redirect_to(@hostel, :notice => 'Hostel was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @hostel.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 update\n @host = Host.find(params[:id])\n\n if @host.update(params[:host])\n head :no_content\n else\n render json: @host.errors, status: :unprocessable_entity\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_transportXML(carbon_home,https_port) \n\n\n\tFile.open(File.join(carbon_home , 'conf','transports.xml')) do |config_file|\n\t\t# Open the document and edit the port (transport.xml)\n\t\tdoc= Document.new(config_file)\n\t\t\t\n\t\tif doc.root.elements['transport'].attributes['name'].eql? \"https\"\n\t\t\tdoc.root.elements['transport'].elements[\"parameter\"].text=https_port\n\t\telse\n\t\t\tputs \"Cannot find https transport element\"\n\t\t\texit\n\t\tend\t\t\n\n\t\t# Write the result to a new file.\n\t\tformatter = REXML::Formatters::Default.new\n\t\tFile.open(File.join(carbon_home , 'conf','result_transports.xml'), 'w') do |result|\n\t\tformatter.write(doc, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','transports.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_transports.xml'),File.join(carbon_home , 'conf','transports.xml') )\nend",
"def edit_transportXML(carbon_home,https_port) \n\n\tFile.open(File.join(carbon_home , 'conf','transports.xml')) do |config_file|\n\t\t# Open the document and edit the port (transport.xml)\n\t\tdoc= Document.new(config_file)\n\t\t\t\n\t\tif doc.root.elements['transport'].attributes['name'].eql? \"https\"\n\t\t\tdoc.root.elements['transport'].elements[\"parameter\"].text=https_port\n\t\telse\n\t\t\tputs \"Cannot find https transport element in transport.xml\"\n\t\t\texit\n\t\tend\t\t\n\n\t\t# Write the result to a new file.\n\t\tformatter = REXML::Formatters::Default.new\n\t\tFile.open(File.join(carbon_home , 'conf','result_transports.xml'), 'w') do |result|\n\t\tformatter.write(doc, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','transports.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_transports.xml'),File.join(carbon_home , 'conf','transports.xml') )\nend",
"def update\n @host = Host.find(params[:id])\n\n respond_to do |format|\n if @host.update_attributes(params[:host])\n format.html { redirect_to @host, notice: 'Host was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @host.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def update\n @host = Host.find_by(hostname: params[:id]) ||\n Host.create(host_params.merge({hostname: params[:id]}))\n\n if @host.update(host_params)\n head :no_content\n else\n render json: @host.errors, status: :unprocessable_entity\n end\n end",
"def update\n @node_rack = @object\n\n respond_to do |format|\n if @node_rack.update_attributes(params[:node_rack])\n flash[:notice] = 'NodeRack was successfully updated.'\n format.html { redirect_to node_rack_url(@node_rack) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node_rack.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def update\n\t @host = Host.find(params[:id])\n\t @domain = Setting.get 'domain'\n\n\t respond_to do |format|\n\t if @host.update_attributes(params[:host])\n\t flash[:notice] = 'Host was successfully updated.'\n\t format.html { redirect_to(@host) }\n\t format.xml { head :ok }\n\t else\n\t format.html { render :action => \"edit\" }\n\t format.xml { render :xml => @host.errors, :status => :unprocessable_entity }\n\t end\n\t end\n\tend",
"def update\n @demo_host_setting = Demo::HostSetting.find(params[:id])\n\n respond_to do |format|\n if @demo_host_setting.update_attributes(params[:demo_host_setting])\n format.html { redirect_to(@demo_host_setting, :notice => 'Host setting was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @demo_host_setting.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :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 401\r\n end",
"def update\n connection.put(element_path, to_xml)\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 @server_rack = ServerRack.find(params[:id])\n\n respond_to do |format|\n if @server_rack.update_attributes(params[:server_rack])\n format.html { redirect_to(@server_rack, :notice => 'Server rack was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @server_rack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @host.update(host_params)\n format.html { redirect_to @host, notice: 'Host was successfully updated.' }\n format.json { render :show, status: :ok, location: @host }\n else\n format.html { render :edit }\n format.json { render json: @host.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n obj = JSON.parse(node.elements.first.content)\n fqdn = obj['fqdn'].downcase\n forbidden! unless from_system?(fqdn)\n\n id = \"system:#{fqdn}\"\n system = System.find(id) || System.new(id: id)\n system.ohai = obj\n system.save\n storage.index(system)\n System.notify_members(stream, node.from, [{'name' => fqdn}])\n send_result\n end",
"def doUpdate(startState)\n if (new_resource.rackID.nil? || new_resource.rackID.empty?)\n return\n end\n \n json = \"{\\\"rackId\\\" : \\\"#{new_resource.rackID}\\\"}\"\n \n response = putRequest(\"/hosts/#{new_resource.hostname}\", json)\n \n unless response.code.to_i.between?(200,299)\n raise Exception.new(\"Host update of #{new_resource.hostname} failed with #{response.code} code. Body: #{response.body}\")\n end\n \n unless response.body == startState\n new_resource.updated_by_last_action true\n end\nend",
"def update\n \n # Create integer copy of IP address\n params[:host][:ip_int] = Host.ip_as_int params[:host][:ip]\n\n @search = Host.search params[:search]\n @host = Host.find(params[:id])\n\n respond_to do |format|\n if @host.update_attributes(params[:host])\n flash[:notice] = 'Host was successfully updated.'\n format.html { redirect_to(@host) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @host.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def solveticket(assigneeid, ticketidxml)\n\n raise ArgumentError.new(\"no assignee is present\") if assigneeid.empty?\n raise ArgumentError.new(\"ticketid is present text provided\") if ticketidxml.empty?\n\n xml = createsolvedticketxml(assigneeid)\n\n begin\n resource = RestClient::Resource.new @hostname, @username, @password\n url = 'tickets/'+ ticketidxml\n httpresponse = resource[url].put xml.to_s, :content_type => 'application/xml', :accept => '*/*'\n processresponse(httpresponse) # call success handler\n rescue => e\n processerror(e) # call error handler\n end\n\n end",
"def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end",
"def updateX\n @server = Server.find(params[:id])\n\n respond_to do |format|\n if @server.update_attributes(params[:server])\n format.html { redirect_to(@server, :notice => 'Server was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @server.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"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 update_host(host, args = {})\n modify_host(host, args, 'update')\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @configuration = current_host.configuration_parameters.find(params[:id])\n\n respond_to do |format|\n if @configuration.update_attributes(params[:configuration])\n flash[:notice] = 'hostConfiguration was successfully updated.'\n format.html { redirect_to host_url(current_host) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @configuration.errors.to_xml }\n end\n end\n end",
"def put(*args)\n request :put, *args\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 update_hosts_info()\n all_nodes = \"\"\n @nodes.each_with_index { |node, index|\n all_nodes << \"#{HelperFunctions.convert_fqdn_to_ip(node.private_ip)} appscale-image#{index}\\n\"\n }\n \n new_etc_hosts = <<HOSTS\n127.0.0.1 localhost.localdomain localhost\n127.0.1.1 localhost\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\nff02::3 ip6-allhosts\n#{all_nodes}\nHOSTS\n\n etc_hosts = \"/etc/hosts\"\n File.open(etc_hosts, \"w+\") { |file| file.write(new_etc_hosts) } \n\n etc_hostname = \"/etc/hostname\"\n my_hostname = \"appscale-image#{@my_index}\"\n File.open(etc_hostname, \"w+\") { |file| file.write(my_hostname) }\n\n Djinn.log_run(\"/bin/hostname #{my_hostname}\")\n end",
"def test_putway_update_valid\n way = create(:way_with_nodes, :nodes_count => 3)\n cs_id = way.changeset.id\n user = way.changeset.user\n\n assert_not_equal({ \"test\" => \"ok\" }, way.tags)\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version, way.id, way.nds, { \"test\" => \"ok\" }, [], {}]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({}, result[4])\n assert_equal way.version + 1, result[5]\n assert_equal({}, result[6])\n assert_equal({}, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 1, new_way.version\n assert_equal way.nds, new_way.nds\n assert_equal({ \"test\" => \"ok\" }, new_way.tags)\n\n # Test changing the nodes in the way\n a = create(:node).id\n b = create(:node).id\n c = create(:node).id\n d = create(:node).id\n\n assert_not_equal [a, b, c, d], way.nds\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version + 1, way.id, [a, b, c, d], way.tags, [], {}]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({}, result[4])\n assert_equal way.version + 2, result[5]\n assert_equal({}, result[6])\n assert_equal({}, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 2, new_way.version\n assert_equal [a, b, c, d], new_way.nds\n assert_equal way.tags, new_way.tags\n\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version + 2, way.id, [a, -1, b, c], way.tags, [[4.56, 12.34, -1, 0, { \"test\" => \"new\" }], [12.34, 4.56, b, 1, { \"test\" => \"ok\" }]], { d => 1 }]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n new_node_id = result[4][\"-1\"].to_i\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({ \"-1\" => new_node_id }, result[4])\n assert_equal way.version + 3, result[5]\n assert_equal({ new_node_id.to_s => 1, b.to_s => 2 }, result[6])\n assert_equal({ d.to_s => 1 }, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 3, new_way.version\n assert_equal [a, new_node_id, b, c], new_way.nds\n assert_equal way.tags, new_way.tags\n\n new_node = Node.find(new_node_id)\n assert_equal 1, new_node.version\n assert_equal true, new_node.visible\n assert_equal 4.56, new_node.lon\n assert_equal 12.34, new_node.lat\n assert_equal({ \"test\" => \"new\" }, new_node.tags)\n\n changed_node = Node.find(b)\n assert_equal 2, changed_node.version\n assert_equal true, changed_node.visible\n assert_equal 12.34, changed_node.lon\n assert_equal 4.56, changed_node.lat\n assert_equal({ \"test\" => \"ok\" }, changed_node.tags)\n\n deleted_node = Node.find(d)\n assert_equal 2, deleted_node.version\n assert_equal false, deleted_node.visible\n end",
"def update\n # returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response|\n returning connection.put(element_path(prefix_options), to_ssj, self.class.headers) do |response|\n load_attributes_from_response(response)\n end\n end",
"def update\n respond_to do |format|\n if @host.update(host_params)\n format.html { redirect_to data_source_hosts_path(@host.data_source_id), notice: 'Host was successfully updated.' }\n format.json { render :show, status: :ok, location: @host }\n else\n format.html { render :edit }\n format.json { render json: @host.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(uri, params = {})\n send_request(uri, :put, params)\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def edit_axis2XML(carbon_home,http_port,https_port) \n\n\tFile.open(File.join(carbon_home , 'conf','axis2.xml')) do |config_file|\n\t\t# Open the document and edit the port (axis2.xml)\n\t\tconfig = Document.new(config_file)\n\t\t\n\t\tconfig.root.elements[25].elements[1].text=http_port\n\t\tconfig.root.elements[26].elements[1].text=https_port\n\t\n\t\t\n\t\t# Write the result to a new file.\n\t\tformatter = REXML::Formatters::Default.new\n\t\tFile.open(File.join(carbon_home , 'conf','result_axis2.xml'), 'w') do |result|\n\t\tformatter.write(config, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','axis2.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_axis2.xml'),File.join(carbon_home , 'conf','axis2.xml') )\n\nend",
"def update\n @node_config = NodeConfig.find(params[:id])\n\n respond_to do |format|\n if @node_config.update_attributes(params[:node_config])\n format.html { redirect_to(@node_config, :notice => 'NodeConfig was successfully updated.') }\n format.json { render :json => @node_config, :status => :ok }\n format.xml { render :xml => @node_config, :status => :ok }\n else\n format.xml { render :xml => @node_config.errors, :status => :unprocessable_entity }\n format.any { render :json => @node_config.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_config_xml_File\n Puppet.alert(\" begin: update_config_xml_File \")\n file_name = get_value4key(\"ps_config_home\", resource[:web_location_attrib]) + \"/webserv/\"\n file_name += get_value4key(\"webdomainname\", resource[:webdomain_attrib]) + \"/config/config.xml\"\n text = File.read(file_name)\n ##new_contents = text.gsub(/listen-port>443/, \"listen-port>\" + get_value4key(\"webadminserverhttps\", resource[:webadmin_server_attrib] ) )\n new_contents1 = text.gsub(/9999/, get_value4key(\"webadminserverhttp\", resource[:webadmin_server_attrib] ) )\n\n File.open(file_name, \"w\") {|file| file.puts new_contents1 }\n Puppet.alert(\" end : update_config_xml_File \")\n end",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def update\n @hostela = Hostela.find(params[:id])\n\n respond_to do |format|\n if @hostela.update_attributes(params[:hostela])\n format.html { redirect_to @hostela, notice: 'Hostela was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hostela.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(id:, hosts:)\n id_check(:id, id)\n non_empty_array_check(:hosts, hosts) unless hosts.nil?\n\n data = {hosts: hosts}\n\n cf_patch(path: \"/zones/#{zone_id}/ssl/certificate_packs/#{id}\", data: data)\n end",
"def post_config(url_prefix, xml)\n url_prefix = URI.escape(\"#{@jenkins_path}#{url_prefix}\")\n http = Net::HTTP.start(@server_ip, @server_port)\n request = Net::HTTP::Post.new(\"#{url_prefix}\")\n puts \"[INFO] PUT #{url_prefix}\" if @debug\n request.basic_auth @username, @password\n request.body = xml\n request.content_type = 'application/xml'\n response = http.request(request)\n response.code\n end",
"def offer\n @offer = @host.offers.find(params[:id])\n @offer.update(offer_params) if request.put?\n redirect_to offers_host_path if request.put?\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 update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update!(**args)\n @host = args[:host] if args.key?(:host)\n @node_id = args[:node_id] if args.key?(:node_id)\n @parameters = args[:parameters] if args.key?(:parameters)\n @port = args[:port] if args.key?(:port)\n @state = args[:state] if args.key?(:state)\n @zone = args[:zone] if args.key?(:zone)\n end",
"def put_facts(name, environment:, facts:)\n formatter = Puppet::Network::FormatHandler.format_for(Puppet[:preferred_serialization_format])\n\n headers = add_puppet_headers(\n 'Accept' => get_mime_types(Puppet::Node::Facts).join(', '),\n 'Content-Type' => formatter.mime\n )\n\n response = @client.put(\n with_base_url(\"/facts/#{name}\"),\n serialize(formatter, facts),\n headers: headers,\n params: { environment: environment },\n )\n\n process_response(response)\n\n response\n end",
"def put_facts(name, environment:, facts:)\n formatter = Puppet::Network::FormatHandler.format_for(Puppet[:preferred_serialization_format])\n\n headers = add_puppet_headers(\n 'Accept' => get_mime_types(Puppet::Node::Facts).join(', '),\n 'Content-Type' => formatter.mime\n )\n\n response = @client.put(\n with_base_url(\"/facts/#{name}\"),\n serialize(formatter, facts),\n headers: headers,\n params: { environment: environment },\n )\n\n process_response(response)\n\n response\n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def _update(type, current_name, metadata={})\n type = type.to_s.camelize\n request :update do |soap|\n soap.body = {\n :metadata => {\n :current_name => current_name,\n :metadata => prepare(metadata),\n :attributes! => { :metadata => { 'xsi:type' => \"ins0:#{type}\" } }\n }\n }\n end\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @draft_partnership = DraftPartnership.find(params[:id])\n\n respond_to do |format|\n if @draft_partnership.update_attributes(params[:partnership])\n\n format.xml \n else\n \n format.xml { render :xml => @draft_partnership.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_axis2XML(carbon_home,http_port,https_port) \n\n\tFile.open(File.join(carbon_home , 'conf','axis2.xml')) do |config_file|\n\t\t# Open the document and edit the port (axis2.xml)\n\t\tconfig = Document.new(config_file)\n\t\t\n\t\tconfig.root.elements[25].elements[1].text=http_port\n\t\tconfig.root.elements[26].elements[1].text=https_port\n\t\n\t\tconfig.root.elements['clustering'].attributes['enable']='true'\n\t\tconfig.root.elements['clustering'].elements[4].text=\"wso2.org.esb\"\n\n\t\tele1=Element.new(\"parameter\")\n\t\tele1.text = \"127.0.0.1\"\n\t\tele1.add_attribute(\"name\", \"mcastBindAddress\")\n\n\t\tele2=Element.new(\"parameter\")\n\t\tele2.text = \"127.0.0.1\"\n\t\tele2.add_attribute(\"name\", \"localMemberHost\")\n\n\t\tele3=Element.new(\"parameter\")\n\t\tele3.add_attribute(\"name\", \"domain\")\n\n\t\tconfig.root.elements.each('//parameter') {|element| \n\t\t\t\n\t\t\tif(element.attributes == ele1.attributes)\n\t\t\t\telement.parent.delete(element)\n\t\t\tend\n\n\t\t\tif(element.attributes == ele2.attributes)\n\t\t\t\telement.parent.delete(element)\n\t\t\tend\n\n\t\t\t\n\t\t}\n\t\t\n\n\t\t# Write the result to a new file.\n\t\tformatter = REXML::Formatters::Default.new\n\t\tFile.open(File.join(carbon_home , 'conf','result_axis2.xml'), 'w') do |result|\n\t\tformatter.write(config, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','axis2.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_axis2.xml'),File.join(carbon_home , 'conf','axis2.xml') )\n\nend",
"def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => '[email protected]',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def update!(**args)\n @description = args[:description] if args.key?(:description)\n @etag = args[:etag] if args.key?(:etag)\n @multi_cluster_routing_use_any = args[:multi_cluster_routing_use_any] if args.key?(:multi_cluster_routing_use_any)\n @name = args[:name] if args.key?(:name)\n @single_cluster_routing = args[:single_cluster_routing] if args.key?(:single_cluster_routing)\n end",
"def update_hosts\n return unless File.exist?(hosts_path)\n return if File.readlines(hosts_path)\n .grep(/#{new_fqdn} #{new_hostname}/)\n .any?\n hosts_body = File.read(hosts_path).gsub(\n /^127\\.0\\.0\\.1.*/,\n \"127\\.0\\.0\\.1 #{new_fqdn} #{new_hostname} localhost\"\n )\n puts \"Adding \\\"#{new_fqdn}\\\" to #{hosts_path}...\"\n write_file(hosts_path, hosts_body)\n end",
"def put(uri, parameters)\n response = Unirest.put uri, parameters: parameters\n response.body\n end",
"def update\n @witness = Witness.find(params[:id])\n\n respond_to do |format|\n if @witness.update_attributes(params[:witness])\n # commented so hosts font receive emails off season\n # if(params[:witness][:host_id].present?)\n # HostMailer.witness_assigned(\n # params[:witness][:host_id],\n # @witness.id,\n # I18n.locale\n # ).deliver\n\n #@host = Host.find(params[:witness][:host_id])\n #@host.update_attributes(assignment_time: Time.now.utc.localtime)\n #end\n\n\n \n format.json { render json: @witness, status: :created, location: @witness }\n else\n format.json { render json: @witness.errors, status: :unprocessable_entity }\n end\n end\n end",
"def run_host(ip)\n\n\t\tverbs = [\n\t\t\t\t'get',\n\t\t\t\t'active',\n\t\t\t\t'create',\n\t\t\t\t'change',\n\t\t\t\t'set',\n\t\t\t\t'put',\n\t\t\t\t'do',\n\t\t\t\t'go',\n\t\t\t\t'resolve',\n\t\t\t\t'start',\n\t\t\t\t'recover',\n\t\t\t\t'initiate',\n\t\t\t\t'negotiate',\n\t\t\t\t'define',\n\t\t\t\t'stop',\n\t\t\t\t'begin',\n\t\t\t\t'end',\n\t\t\t\t'manage',\n\t\t\t\t'administer',\n\t\t\t\t'modify',\n\t\t\t\t'register',\n\t\t\t\t'log',\n\t\t\t\t'add',\n\t\t\t\t#'delete', # Best to be safe!\n\t\t\t]\n\n\t\tnouns = [\n\t\t\t\t'password',\n\t\t\t\t'task',\n\t\t\t\t'pass',\n\t\t\t\t'administration',\n\t\t\t\t'account',\n\t\t\t\t'admin',\n\t\t\t\t'login',\n\t\t\t\t'token',\n\t\t\t\t'credentials',\n\t\t\t\t'credential',\n\t\t\t\t'key',\n\t\t\t\t'guid',\n\t\t\t\t'message',\n\t\t\t\t'user',\n\t\t\t\t'username',\n\t\t\t\t'load',\n\t\t\t\t'list',\n\t\t\t\t'name',\n\t\t\t\t'file',\n\t\t\t\t'path',\n\t\t\t\t'directory',\n\t\t\t\t'configuration',\n\t\t\t\t'config',\n\t\t\t\t'setting',\n\t\t\t\t'settings',\n\t\t\t\t'registry',\n\t\t\t\t'on',\n\t\t\t\t'off',\n\t\t\t]\n\n\t\ttarget_port = datastore['RPORT']\n\t\tvhost = datastore['VHOST'] || wmap_target_host || ip\n\n\t\tbegin\n\t\t\t# Check service exists\n\t\t\tres = send_request_raw({\n\t\t\t\t'uri' => datastore['PATH'],\n\t\t\t\t'method' => 'GET',\n\t\t\t\t'vhost' => vhost,\n\t\t\t}, 10)\n\n\t\t\tif (res.code == 200)\n\t\t\t\tprint_status(\"PATH appears to be OK.\")\n\n\t\t\t\tverbs.each do |v|\n\t\t\t\t\tnouns.each do |n|\n\n\t\t\t\t\t\t# This could be cleaned up - patrickw\n\t\t\t\t\t\tdata = '<?xml version=\"1.0\" encoding=\"utf-8\"?>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '<soap:Envelope xmlns:xsi=\"' + datastore['XMLINSTANCE'] + '\" xmlns:xsd=\"' + datastore['XMLSCHEMA'] + '\" xmlns:soap=\"' + datastore['XMLSOAP'] + '\">' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '<soap:Body>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << \"<#{v}#{n}\" + \" xmlns=\\\"#{datastore['XMLNAMESPACE']}\\\">\" + \"\\r\\n\"\n\t\t\t\t\t\tdata << \"</#{v}#{n}>\" + \"\\r\\n\"\n\t\t\t\t\t\tdata << '</soap:Body>' + \"\\r\\n\"\n\t\t\t\t\t\tdata << '</soap:Envelope>' + \"\\r\\n\\r\\n\"\n\n\t\t\t\t\t\tres = send_request_raw({\n\t\t\t\t\t\t\t'uri' => datastore['PATH'] + '/' + v + n,\n\t\t\t\t\t\t\t'method' => 'POST',\n\t\t\t\t\t\t\t'vhost' => vhost,\n\t\t\t\t\t\t\t'data'\t\t=> data,\n\t\t\t\t\t\t\t'headers' =>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'Content-Length' => data.length,\n\t\t\t\t\t\t\t\t\t'SOAPAction'\t=> '\"' + datastore['XMLNAMESPACE'] + v + n + '\"',\n\t\t\t\t\t\t\t\t\t'Expect'\t=> '100-continue',\n\t\t\t\t\t\t\t\t\t'Content-Type'\t=> datastore['CONTENTTYPE'],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, 15)\n\n\t\t\t\t\t\tif (res && !(res.body.empty?))\n\t\t\t\t\t\t\tif (res.body =~ /method name is not valid/)\n\t\t\t\t\t\t\t\tprint_status(\"Server rejected SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\telsif (res.message =~ /Cannot process the message because the content type/)\n\t\t\t\t\t\t\t\tprint_status(\"Server rejected CONTENTTYPE: HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\t\tres.message =~ /was not the expected type\\s\\'([^']+)'/\n\t\t\t\t\t\t\t\tprint_status(\"Set CONTENTTYPE to \\\"#{$1}\\\"\")\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\telsif (res.code == 404)\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tprint_status(\"Server responded to SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\")\n\t\t\t\t\t\t\t\t## Add Report\n\t\t\t\t\t\t\t\treport_note(\n\t\t\t\t\t\t\t\t\t:host\t=> ip,\n\t\t\t\t\t\t\t\t\t:proto\t=> 'HTTP',\n\t\t\t\t\t\t\t\t\t:port\t=> rport,\n\t\t\t\t\t\t\t\t\t:type\t=> \"SOAPAction: #{v}#{n}\",\n\t\t\t\t\t\t\t\t\t:data\t=> \"SOAPAction: #{v}#{n} with HTTP: #{res.code} #{res.message}.\"\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tif datastore['DISPLAYHTML']\n\t\t\t\t\t\t\t\t\tprint_status(\"The HTML content follows:\")\n\t\t\t\t\t\t\t\t\tprint_status(res.body + \"\\r\\n\")\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\telse\n\t\t\tprint_status(\"Server did not respond with 200 OK.\")\n\t\t\tprint_status(res.to_s)\n\t\tend\n\t\trescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout\n\t\trescue ::Timeout::Error, ::Errno::EPIPE\n\t\tend\n\tend",
"def update\n @interface = Interface.find(params[:id])\n @virtualmachine = Virtualmachine.find(@interface.virtualmachine_id)\n position_networkcard = `cat /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml | grep -n \"slot='0x#{@interface.pci_slot}\" | cut -d ':' -f1`\n begin_networkcard = position_networkcard.to_i - 4\n end_networkcard = position_networkcard.to_i + 1\n\n delete_networkcard = `sed -i '#{begin_networkcard},#{end_networkcard}d' /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml`\n filesize = `cat /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml | wc -l`\n filesize = filesize.to_i - 2 \n\n #inserts interface definition\n\n #place xml insertions here\n respond_to do |format|\n if @interface.update_attributes(params[:interface])\n interface_network_id = @interface.network_id\n @network = Network.find(interface_network_id)\n ifacedata = \"<interface type='network'>\\n<mac address='#{@interface.macaddress}'/>\\n<source network='#{@network.name}'/>\\n<model type='pcnet'/>\\n<address type='pci' domain='0x0000' bus='0x00' slot='0x#{@interface.pci_slot}' function='0x0'/>\\n</interface>\"\n write_at(\"/etc/libvirt/qemu/#{@virtualmachine.hostname}.xml\", filesize, ifacedata)\n format.html { redirect_to @interface, :notice => 'Interface was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interface.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!\n request! :put\n end",
"def put(*args)\n request(:put, *args)\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 put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update\n respond_to do |format|\n if @host_address.update(host_address_params)\n format.html { redirect_to @host_address, notice: 'Host address was successfully updated.' }\n format.json { render :show, status: :ok, location: @host_address }\n else\n format.html { render :edit }\n format.json { render json: @host_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end",
"def update_current_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update!(**args)\n @constraint = args[:constraint] if args.key?(:constraint)\n @etag = args[:etag] if args.key?(:etag)\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\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 do_put(uri = \"\", body = \"\")\n @connection.put do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Error trying to send a PUT to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Request sent: #{body}\"\n Faraday::Response.new\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(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def update!(**args)\n @deployed_model_id = args[:deployed_model_id] if args.key?(:deployed_model_id)\n @endpoint = args[:endpoint] if args.key?(:endpoint)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def update\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n if @cluster.update_attributes(params[:cluster])\n flash[:notice] = 'Cluster was successfully updated.'\n format.html { redirect_to(@cluster) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cluster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topiccluster = Topiccluster.find(params[:id])\n\n respond_to do |format|\n if @topiccluster.update_attributes(params[:topiccluster])\n format.html { redirect_to(@topiccluster, :notice => 'Topiccluster was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topiccluster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @host_org.update(host_org_params)\n format.html { redirect_to @host_org, notice: 'Host org was successfully updated.' }\n format.json { render :show, status: :ok, location: @host_org }\n else\n format.html { render :edit }\n format.json { render json: @host_org.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6754589",
"0.6555582",
"0.60603553",
"0.59828085",
"0.5975185",
"0.59656584",
"0.5785308",
"0.57744956",
"0.5686697",
"0.5661723",
"0.5655726",
"0.56341565",
"0.5629273",
"0.5625961",
"0.5614185",
"0.5588911",
"0.55689406",
"0.55587876",
"0.54896235",
"0.5488187",
"0.5479778",
"0.5470533",
"0.5463847",
"0.5438244",
"0.54309475",
"0.5424201",
"0.5420531",
"0.54146373",
"0.53985405",
"0.53830206",
"0.53384954",
"0.5332825",
"0.5329403",
"0.5317622",
"0.53105074",
"0.53104645",
"0.5309767",
"0.5309548",
"0.52843785",
"0.5255206",
"0.5245818",
"0.5232154",
"0.523104",
"0.52279025",
"0.5218113",
"0.52157104",
"0.5212605",
"0.519707",
"0.5196939",
"0.51762766",
"0.5165926",
"0.51623243",
"0.51483864",
"0.5145055",
"0.514086",
"0.51246464",
"0.5123442",
"0.5120228",
"0.51197255",
"0.5117943",
"0.5117325",
"0.5117086",
"0.51091826",
"0.5108172",
"0.5095255",
"0.5095138",
"0.50951326",
"0.5091745",
"0.50897276",
"0.5079823",
"0.50767434",
"0.50767434",
"0.50767434",
"0.50762635",
"0.50699306",
"0.50633526",
"0.50627196",
"0.50614375",
"0.5059201",
"0.5058441",
"0.5057706",
"0.5057496",
"0.50404274",
"0.50357103",
"0.50357103",
"0.50357103",
"0.50357103",
"0.50357103",
"0.50357103",
"0.50357103",
"0.50357103",
"0.50333756",
"0.5033112",
"0.503245",
"0.5017901",
"0.5015671",
"0.5015671",
"0.5014779",
"0.50122774",
"0.5006595"
] | 0.59360385 | 6 |
DELETE /hostnesses/1 DELETE /hostnesses/1.xml | def destroy
@hostness = Hostness.find(params[:id])
@hostness.destroy
respond_to do |format|
format.html { redirect_to(hostnesses_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @host = Host.find(params[:id])\n @host.destroy\n\n respond_to do |format|\n format.html { redirect_to(hosts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @host = Host.find(params[:id])\n @host.destroy\n\n respond_to do |format|\n format.html { redirect_to(hosts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @hostel = Hostel.find(params[:id])\n @hostel.destroy\n\n respond_to do |format|\n format.html { redirect_to(hostels_url) }\n format.xml { head :ok }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end",
"def destroy\n\t @host = Host.find(params[:id])\n\t @host.destroy\n\n\t respond_to do |format|\n\t format.html { redirect_to(hosts_url) }\n\t format.xml { head :ok }\n\t end\n\tend",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def destroy\n @host = Host.find_by(hostname: params[:id])\n @host.destroy\n\n head :no_content\n end",
"def destroy\n @host = Host.find(params[:id])\n @host.destroy\n\n respond_to do |format|\n flash[:notice] = 'Host was successfully deleted.'\n format.html { redirect_to hosts_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @host = Host.find(params[:id])\n @host.destroy\n\n respond_to do |format|\n flash[:notice] = 'Host was successfully deleted.'\n format.html { redirect_to hosts_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @demo_host_setting = Demo::HostSetting.find(params[:id])\n @demo_host_setting.destroy\n\n respond_to do |format|\n format.html { redirect_to(demo_host_settings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @host = Host.find(params[:id])\n @host.destroy\n\n head :no_content\n end",
"def host_delete(host)\n curl = setup_curl(\"#{@foreman_url}/api/hosts/#{host}\", true)\n curl.http_delete\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @configuration = current_host.configuration_parameters.find(params[:id])\n @configuration.destroy\n\n respond_to do |format|\n flash[:notice] = 'hostConfiguration was successfully deleted.'\n format.html { redirect_to host_url(current_host) }\n format.xml { head :ok }\n end\n end",
"def test_delete_nonexistent\n assert_raise(ArgumentError) { cmk.delete_host('does not exist', 'folder1')}\n end",
"def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end",
"def destroy\n name, type = resource[:name].split('/')\n case type\n when 'MX'\n @dnsres.each do |res|\n preference = res.preference\n target = res.to_rdata\n nsupdate(\"server #{server}\n update delete #{name} MX #{preference} #{target}.\n send\")\n end\n when 'SRV'\n @dnsres.each do |res|\n priority = res.priority\n weight = res.weight\n port = res.port\n target = res.to_rdata\n nsupdate(\"server #{server}\n update delete #{name} SRV #{priority} #{weight} #{port} #{target}\n send\")\n end\n else\n rdata = @dnsres.to_rdata\n nsupdate(\"server #{server}\n update delete #{name} #{type} #{rdata}\n send\")\n end\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete(*uris); end",
"def destroy\n @host = Host.find(params[:id])\n @host.deleted = true\n @host.save\n\n respond_to do |format|\n format.html { redirect_to hosts_url }\n format.json { head :no_content }\n end\n end",
"def delete!\n\t\t\tClient.delete @root\n\t\tend",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @helibasis = Helibase.find(params[:id])\n @helibasis.destroy\n\n respond_to do |format|\n format.html { redirect_to(helibases_url) }\n format.xml { head :ok }\n end\n end",
"def delete_host(host)\n validate_list([[\"Host\", host, :presence]])\n options = {\"Host\" => host}\n\n connection = Connection.new\n connection.post(\"Domain/Host/Delete\", options)\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete\n delete_from_server single_url\n end",
"def destroy\n @browsenodeid = Browsenodeid.find(params[:id])\n @browsenodeid.destroy\n\n respond_to do |format|\n format.html { redirect_to(browsenodeids_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @server_rack = ServerRack.find(params[:id])\n @server_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to(server_racks_url) }\n format.xml { head :ok }\n end\n end",
"def destroyX\n @server = Server.find(params[:id])\n @server.destroy\n\n respond_to do |format|\n format.html { redirect_to(servers_url) }\n format.xml { head :ok }\n end\n end",
"def del_host(wspace, address, comm='')\n\t\thost = wspace.hosts.find_by_address_and_comm(address, comm)\n\t\thost.destroy if host\n\tend",
"def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def destroy\n @node_config = NodeConfig.destroy(params[:id])\n xml=@node_config.to_xml\n json=@node_config.to_json\n @node_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(node_configs_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end",
"def destroy\n @helibase = Helibase.find(params[:id])\n @helibase.destroy\n\n respond_to do |format|\n format.html { redirect_to(helibases_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @discovery = Discovery.find(params[:id])\n @discovery.destroy\n\n respond_to do |format|\n format.html { redirect_to(discoveries_url) }\n format.xml { head :ok }\n end\n end",
"def delete_trust(xml) \n if current_user \n trust_root = xml.root.get_elements('TrustRoot').first.text \n unless trust_root.empty? \n @trust = current_user.trusts.find(:first, :conditions => ['trust_root = ?', trust_root]) \n if @trust \n @trust.destroy \n return render(:text => \"<Response>success</Response>\") \n end \n end \n end \n render :text => '<Response>trust root does not exist</Response>' \n end",
"def delete(path)\n make_call(mk_conn(path), :delete)\n end",
"def delete_host(host)\n raise MogileFS::ReadOnlyError if readonly?\n ! @backend.delete_host(:host => host).nil?\n end",
"def destroy\n @redes = Rede.all\n @host.destroy\n respond_to do |format|\n format.html { redirect_to hosts_url, notice: 'Host deletado com sucesso' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete_host\n load_service\n return if (@service.blank?)\n\n @host = Host.where(:_id => params[:host_id]).first\n\n # Does the host exist?\n if (@host.blank?)\n flash[:error] = t(\"services.error.host_not_found\")\n redirect_to service_hosts_path()\n return\n end\n\n # Disassociate the host from the service\n @service.hosts.delete(@host)\n\n respond_to do |format|\n format.html{\n if (@service.save)\n flash[:notice] = t(\"services.notice.host_deleted\", :name => @host.name, :service => @service.name)\n else\n flash[:error] = t(\"services.error.host_not_deleted\", :name => @host.name, :service => @service.name)\n end\n redirect_to service_hosts_path()\n return\n }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @erratum = Erratum.find(params[:id])\n @erratum.destroy\n\n respond_to do |format|\n format.html { redirect_to(errata_url) }\n format.xml { head :ok }\n end\n end",
"def destroy; delete end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @installation = Installation.find(params[:installation_id]) \n @onpost = Onpost.find(params[:id])\n @onpost.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n @installation = Installation.find(params[:installation_id]) \n @eat = Eat.find(params[:id])\n @eat.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @colonoscopytest = Colonoscopytest.find(params[:id])\n @colonoscopytest.destroy\n\n respond_to do |format|\n format.html { redirect_to(colonoscopytests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hostela = Hostela.find(params[:id])\n @hostela.destroy\n\n respond_to do |format|\n format.html { redirect_to hostelas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @article = Article.find_by_sysname(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to(articles_url) }\n format.xml { head :ok }\n end\n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end",
"def cfdelete(dist_id) # cf://DIST_ID\n send_command \"cfdelete\", dist_id\n end",
"def destroy\n @qx = Qx.find(params[:id])\n @qx.destroy\n\n respond_to do |format|\n format.html { redirect_to(qxes_url) }\n format.xml { head :ok }\n end\n end",
"def delete!\n server.delete(name)\n end",
"def destroy\n @shelf = Shelf.find(params[:id])\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to(shelves_url) }\n format.xml { head :ok }\n end\n end",
"def asr_delete_orphaned_config(agent_host)\n elektron_networking.delete(\"/asr1k/orphans/#{agent_host}\").body\n end",
"def destroy\n # set_chef\n @chef.destroy\n redirect_to chefs_path\n end",
"def destroy\n @host.destroy\n respond_to do |format|\n format.html { redirect_to hosts_url, notice: 'Host was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\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 destroy\n @hostname.destroy\n respond_to do |format|\n format.html { redirect_to hostnames_url, notice: 'Alias was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(name); end",
"def delete(name); end",
"def destroy\n @host.destroy\n respond_to do |format|\n format.html { redirect_to data_source_hosts_path(@host.data_source_id), notice: 'Host was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @ph_specified = PhSpecified.find(params[:id])\r\n @ph_specified.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(ph_specifieds_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def deleteFileFromServer(filepath)\n filepath = filepath[1, filepath.length - 1] \n address = @@host + \"/user/\" + @@conf[\"username\"] + \"/device/\" + @@conf[\"dev_name\"] + \"/files/\" + filepath\n \n res = HttpRequest.new(:delete, address).send(@@host) \n puts res\n puts \"CODE: \" + res.code\n\nend",
"def destroy\n @host_tpl = HostTpl.find(params[:id])\n @host_tpl.destroy\n\n respond_to do |format|\n format.html { redirect_to host_tpls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prd_etc = PrdEtc.find(params[:id])\n @prd_etc.destroy\n\n respond_to do |format|\n format.html { redirect_to(prd_etcs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n request(:delete)\n end",
"def delete\n end",
"def delete(name)\n\n end",
"def destroy\n @cluster = Cluster.find(params[:id])\n @cluster.destroy\n\n respond_to do |format|\n format.html { redirect_to(clusters_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @childmaster = Childmaster.find(params[:id])\n @childmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(childmasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @subway = Subway.find(params[:id])\n @subway.destroy\n\n respond_to do |format|\n format.html { redirect_to(subways_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_file = ConfigFile.find(params[:id])\n @config_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_files_url) }\n format.xml { head :ok }\n end\n end",
"def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end",
"def delete_host(fqdn, url, cookie)\n begin\n # set the headers\n headers = {\n :content_type => :json,\n :accept => :json,\n 'Cookie' => cookie,\n 'Referer' => url\n }\n\n # set the payload\n payload = {\n :method => 'host_del',\n :params => [\n [ fqdn ],\n {\n :continue => false,\n :updatedns => true\n }\n ]\n }\n\n # get response and convert to json\n response = call_rest(:post, url, headers, 'session/json', JSON.generate(payload))\n\n # validate response and return system object\n if response\n log(:info, \"delete_host: Response body: #{response.body}\") if @debug\n if response.code == DELETE_HOST_SUCCESS_CODE\n errors = JSON.parse(response.body)['error']\n log(:info, \"delete_host: The following errors were logged during the previous REST call: #{errors.inspect}\")\n\n # NOTE: success code 4001 indicate the host didn't exist\n if errors.nil? || errors['code'].to_i == 4001\n log(:info, \"delete_host: Successfully deleted host object for system: #{fqdn}\")\n return true\n else\n log(:warn, \"delete_host: Unable to delete system: #{fqdn} from IDM\")\n raise \"Please review the following errors: #{errors.inspect}\"\n end\n else\n log(:warn, \"delete_host: Unable to retrieve node object from PuppetDB for system: #{fqdn}. Returning false\")\n return false\n end\n else\n raise \"Invalid Response: #{response.inspect}\"\n end\n rescue => err\n # log and backtrace the error\n log(:error, \"[#{err}]\\n#{err.backtrace.join(\"\\n\")}\")\n log(:error, \"delete_host: #{err}. Returning false\")\n return false\n end\nend",
"def destroy\n @server = Server.find(params[:id])\n @server.destroy\n \n respond_to do |format|\n format.html { redirect_to(servers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy1\n @compare = Compare.find(params[:id])\n @compare.destroy\n\n respond_to do |format|\n format.html { redirect_to(compares_url) }\n format.xml { head :ok }\n end\n end",
"def _delete(type, *args)\n type = type.to_s.camelize\n metadata = args.map { |full_name| {:full_name => full_name} }\n request :delete do |soap|\n soap.body = {\n :metadata => metadata\n }.merge(attributes!(type))\n end\n end",
"def destroy\n @topiccluster = Topiccluster.find(params[:id])\n @topiccluster.destroy\n\n respond_to do |format|\n format.html { redirect_to(topicclusters_url) }\n format.xml { head :ok }\n end\n end",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend",
"def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend"
] | [
"0.6759713",
"0.6759713",
"0.67567664",
"0.6668124",
"0.6635069",
"0.6596829",
"0.65685165",
"0.65454626",
"0.6481324",
"0.641212",
"0.641212",
"0.6387421",
"0.6386383",
"0.6381551",
"0.63055396",
"0.62727594",
"0.61862683",
"0.61856204",
"0.6154864",
"0.61529523",
"0.6142259",
"0.61375695",
"0.61256343",
"0.61111456",
"0.6076246",
"0.60655344",
"0.6045753",
"0.60336214",
"0.60334027",
"0.6028183",
"0.6025864",
"0.6020158",
"0.601878",
"0.60104537",
"0.60021013",
"0.600023",
"0.59954304",
"0.5987701",
"0.5982478",
"0.5981449",
"0.5977014",
"0.5974901",
"0.59710777",
"0.5952756",
"0.59462535",
"0.5920284",
"0.59167945",
"0.59132785",
"0.591245",
"0.5900669",
"0.589529",
"0.58904415",
"0.5881243",
"0.5874373",
"0.5863603",
"0.58504105",
"0.5834053",
"0.58328444",
"0.5825665",
"0.58213204",
"0.5821191",
"0.58195347",
"0.5819062",
"0.58181167",
"0.5814795",
"0.5812171",
"0.58029324",
"0.58027476",
"0.5802632",
"0.57984096",
"0.57975245",
"0.5779276",
"0.5778904",
"0.5778904",
"0.57728887",
"0.5772514",
"0.57717586",
"0.5770639",
"0.57687664",
"0.57664037",
"0.5764578",
"0.5764171",
"0.5754621",
"0.5753151",
"0.5751543",
"0.57473284",
"0.57473284",
"0.57473284",
"0.57473284",
"0.57423484",
"0.5740515",
"0.57391053",
"0.57383126",
"0.5737962",
"0.5736339",
"0.57281166",
"0.5722321",
"0.5722177",
"0.57213426",
"0.57213426"
] | 0.6853823 | 0 |
+level+ may be 0 or greater, and should be something like an integer. +seq+ is an array with a sequence of steps (:fw, :right, or :left) which will replace each :fw (means: forward) part of the path. A nice default is provided. | def initialize level = 1, seq = nil
super()
@path = [:fw]
seq = [:fw, :left, :fw, :right, :fw, :right, :fw, :left, :fw]
level.times do
@path.map! { |el| el == :fw ? seq.dup : el }.flatten!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level_up\n $levels.push('/..')\nend",
"def turtle level\n if level.zero? then @level_0\n elsif level == 1 then @level_1\n else\n s = ''\n @level_1.each_byte do |b|\n b == @level_0_byte ? s += turtle(level-1) : s += b.chr\n end\n s\n end\n end",
"def level= level\n if (0..6).include? level then @level = level\n elsif LEVEL.include? level.to_s then @level = LEVEL.index level\n else @level = UNKNOWN\n end\n end",
"def current_level=( level )\n if @base_level.nil?\n @base_level = @cur_level = level\n @level[@base_level-1] = @numbering_start-1\n end\n\n if level < @base_level\n raise ::Webby::Error, \"heading tags are not in order, cannot outline\"\n end\n\n if level == @cur_level\n @level[level-1] += 1\n elsif level > @cur_level\n @cur_level.upto(level-1) {|ii| @level[ii] += 1}\n else\n @cur_level.downto(level+1) {|ii| @level[ii-1] = 0}\n @level[level-1] += 1\n end\n\n @cur_level = level\n end",
"def level=(level)\n @level_index = self.class.map_level_to_index(level)\n @level = level\n end",
"def increment_level(level)\n\n if !@last_heading_counter[level] \n @last_heading_counter[level] = 0\n end\n @last_heading_counter[level] += 1\n\n for i in 0..(@last_heading_counter.length - 1) do\n if i > level + 1\n @last_heading_counter[i] = 0\n elsif [0, nil].include?(@last_heading_counter[i])\n @last_heading_counter[i] = 1\n end\n end\nend",
"def level=(level)\n validator = EnumAttributeValidator.new('String', [\"Unknown\", \"Inline\", \"Block\", \"Row\", \"Cell\"])\n if level.to_i == 0\n unless validator.valid?(level)\n raise ArgumentError, \"invalid value for 'level', must be one of #{validator.allowable_values}.\"\n end\n @level = level\n else\n @level = validator.allowable_values[level.to_i]\n end\n end",
"def level=(value)\n @level = value\n end",
"def level=(value)\n @level = value\n end",
"def move(stage,level)\n\tcase read_char\n \twhen \"\\e[C\"\n \t\t#right character \n \t\tif canMoveRight(stage)\n \t\t\treturn moveRight(stage)\n \t\tend\n \twhen \"\\e[D\"\n \t\t#left character \n \t\tif canMoveLeft(stage)\n \t\t\treturn moveLeft(stage)\n \t\tend\n \twhen \"\\e[A\" \n\t\t#up character\n\t\tif canClimb(stage)\n\t\t\treturn climb(stage)\n\t\tend\n\twhen \"\\e[B\"\n \t\t#down character\n \t\tif blockPresent(stage)\n \t\t\treturn moveBlock(stage)\n \t\tend\n \twhen \"\\u0003\"\n \toverwrite($linePrinted, true)\n \texit 0\n when \"r\"\n \toverwrite($linePrinted, true)\n \t\tplayBlockMan(level)\n \twhen \"s\"\n \t\tnumber = read_char\n \t\toverwrite($linePrinted, true)\n \t\tplayBlockMan(number.to_i)\n \telse\n \t\t\n \tend\n \tmove(stage,level)\nend",
"def level=( level )\n super(level || 0)\n end",
"def steps (x, y, path)\n if x == 0 && y == 0\n then puts (path)\n return\n end\n if x > 0\n then steps(x - 1, y, path + \"R\")\n steps(x - 1, y + 1, path + \"L\")\n end\n if y > 0\n then steps(x, y - 1, path + \"H\")\n end\nend",
"def level=(level)\n @state[:fiber][:level] = level\n end",
"def lvlres\n @level = 0\n lvlup\n end",
"def increaseLevels(levels)\n @level += levels\n end",
"def down\n @level += 1\n add_newline\n end",
"def change_level(kod,iw)\n case kod\n when 'y' # povysit level\n $words[iw].addlevel(1)\n when 'r' # reset level=0\n $words[iw].setlevel(0)\n when 'x' # level +3\n $words[iw].addlevel(3)\n end\nend",
"def push_level(x=1) \n x >= 1 ? @level = x : @level = 1\n end",
"def up\n @level -= 1\n add_newline\n end",
"def input_dosing_levels(levels)\n my_levels = levels.split(',')\n for i in 0..my_levels.size()-1\n add_level.click if i > 1\n dosing_factor_levels[i].set my_levels[i]\n end\n end",
"def update_level\n #if is_literal?\n if @left_sentence.nil? && @right_sentence.nil?\n @level = @father.level\n else\n @level = @father.level + 1\n @left_sentence.update_level unless @left_sentence.nil?\n @right_sentence.update_level unless @right_sentence.nil?\n end\n end",
"def level=(level)\n # Check up and down limits\n level = [[level, $data_actors[@actor_id].final_level].min, 1].max\n # Change EXP\n self.exp = @exp_list[level]\n end",
"def decreaseLevels(levels)\n @level = @level - levels >= 1? @level-levels : 1 \n end",
"def up\n \"if (up() .and. current%level == init_level_list%#@level_name-1) call #@level_sub_name\"\n end",
"def turtle_trail dir spaces\n if dir == '0'\n world [x] [y+1] = m\n turtle_trail (dir spaces-1) ##trying to make this recursive\n end\n elsif dir == 90\n world [x+1] [y] = m\n turtle_trail (dir spaces-1)\n end",
"def level(level, context = nil)\n context = context.to_s unless context.nil?\n self.levels[context] = level\n clear_levels_cache!\n end",
"def level=(level)\n @level = level\n @implementation.level = @level if @implementation\n level\n end",
"def level\r\n\tif $lvl == 1\r\n\t\tlevel2\r\n\telse \r\n\t\tif $lvl == 2\r\n\t\t\tlevel3\r\n\t\telse\r\n\t\t\tif $lvl == 3\r\n\t\t\t\tlevel4\r\n\t\t\tend\r\n\t\tend\t\r\n\tend\t\r\nend",
"def normalise_level(level)\n return nil if level.blank?\n\n case level.to_s\n when 'reader', 'read'\n :reader\n when 'writer', 'write'\n :writer\n when 'owner', 'own'\n :owner\n end\n end",
"def levels=(levels)\n @levels = levels\n clear_levels_cache!\n end",
"def level_down\r\r\n return if @level.zero?\r\r\n @level -= 1\r\r\n level_update\r\r\n end",
"def rec_build(level, direction, rotation, fractal_list)\r\n # At the lowest level, add an actual piece to the array\r\n if (level == 0)\r\n fractal_list.push((direction + rotation) % 360)\r\n return\r\n end\r\n \r\n # At higher levels, we need to define the shape of the fractal\r\n for piece_direction in @base_fractal\r\n rec_build(\r\n level - 1, # Drill down to the next level\r\n piece_direction, # Take direction from the base array\r\n (direction + rotation) % 360, # Rotate lower-level according to higher level structure\r\n fractal_list) # Append to the list\r\n end\r\n end",
"def set_level(level) # Sets both level and exp\n kendrick_actor_skill_progression_data_progress_set_level(level)\n @exp = exp_for_level\n end",
"def update!(**args)\n @level = args[:level] if args.key?(:level)\n end",
"def update!(**args)\n @level = args[:level] if args.key?(:level)\n end",
"def level=(new_level)\n super new_level.to_s\n end",
"def move(path)\n\t\tpath.each_char do |direction|\n\t\t\tcase direction\n\t\t\t\twhen 'M' then forward\n\t\t\t\twhen 'R', 'L' then turn(direction)\n\t\t\t\telse next\n\t\t\tend\n\t\tend\n\tend",
"def level(value = nil)\n if value.nil?\n @level\n else\n @level = value\n end\n end",
"def tree_for(stack, level, tree)\n stack.each do |debug_item|\n task = debug_item[0][0]\n\n if debug_item.size == 2 # flat\n introspect = debug_item[0].last\n\n name = (node = introspect[task]) ? node[:id] : task\n\n tree << [ level, name ]\n else # nesting\n tree << [ level, task ]\n\n tree_for(debug_item[1..-2], level + 1, tree)\n\n tree << [ level+1, debug_item[-1][0] ]\n end\n\n tree\n end\n end",
"def print_bump_plan_level(level, bump_info)\n bump_info.bump level\n\n log \"Bump #{level} level\"\n print_version_transition bump_info\n end",
"def level=(lvl)\n @level = if lvl.is_a?(Integer)\n lvl\n else\n Level::NAME_TO_LEVEL.fetch(lvl.to_s.upcase)\n end\n end",
"def level(l)\n @config[:level] = l\n end",
"def log_at(level)\n old_local_level, self.local_level = local_level, level\n yield\n ensure\n self.local_level = old_local_level\n end",
"def update_level_\n end",
"def spielen(levels, start)\r\n\t# next_lvl wird mit dem ersten level (\"start\") initialisiert\r\n\t# diese zusatzvariable brauchen wir, da sonst immer nur \"start\" \r\n\t# als level in der while-Schleife unten nutzen würden. Wir wollen\r\n\t# jedoch die level wechseln können\r\n\tnext_lvl = start\r\n\t\r\n\twhile true\r\n\t\t# lvl wird mit als startlevel aus dem ROOMS initialisiert\r\n\t\t# start entspricht dabei der funktion \"def start\"\r\n\t\tlvl = levels[next_lvl]\r\n\t\tputs \"\\n-- -- -- --\"\r\n\t\tnext_lvl = lvl.call()\r\n\tend\r\nend",
"def menu_level_left\n return if @current_level.length == 1\n arry = @current_level.split('.')\n arry.pop\n @current_level = arry.join('.')\n end",
"def reverse_rtl_chars par\n min_odd_level = max_level = nil\n levels = Hash.new # Where I want to store info about the level\n chars=par['characters']\n last=chars.length - 1\n 0.upto last do |ind|\n char=chars[ind]\n level=char['level']\n min_odd_level = level if level.odd? && (!min_odd_level or level<min_odd_level)\n max_level=level if !max_level or level>max_level\n if !levels[level] then\n hsh = levels[level] = Hash.new\n hsh['start']=ind\n else\n hsh = levels[level]\n end\n hsh['end']=ind\n end # upto\n return unless min_odd_level\n\n done=false\n cur_lvl=max_level\n while !done do\n lvl=cur_lvl - 1\n if cur_lvl > min_odd_level then\n while !levels[lvl] do\n lvl -= 1\n end\n end\n hsh_cur=levels[cur_lvl]\n if lvl >= min_odd_level\n hsh_low=levels[lvl]\n hsh_low['start'] = hsh_cur['start'] if hsh_cur['start'] < hsh_low['start']\n hsh_low['end'] = hsh_cur['end'] if hsh_cur['end'] > hsh_low['end']\n end\n if (cur_lvl==min_odd_level) or (lvl.odd? != cur_lvl.odd?)\n rearrange_level par, cur_lvl, hsh_cur\n end\n\n done=true if cur_lvl == min_odd_level\n cur_lvl=lvl\n end\n end",
"def set_level_names(levels)\n levels.each_with_index do |level, index|\n self['level_' + index.to_s + '_name'] = level\n end\n save\n end",
"def update_depth\n if depth?\n self.update_attribute(:depth, level)\n end\n self\n end",
"def visit(level, visited, out)\n return if level.empty?\n visited += level\n out.puts level.collect(&:name).join(', ')\n next_level = level.collect(&:mutual_mentions).flatten.sort - visited\n visit next_level.uniq, visited, out\n end",
"def each_level\n\t\t\t(1..max_level).each do |level|\n\t\t\t\tyield level if block_given?\n\t\t\tend\n\t\tend",
"def nice_level(incr)\n @commands_and_opts.push \"#{OPTIONAL_OPTS[:nice_level]}=#{incr}\"\n self\n end",
"def level=(new_level)\n @level = LEVELS[new_level.to_sym]\n reset_methods(:close)\n end",
"def change_level\n if Group::LEVEL_TITLES.include?(params[:level])\n params[:level] = Group::LEVELS[Group::LEVEL_TITLES.index(params[:level])]\n end\n unless Group::LEVELS.include?(params[:level])\n flash[:notice] = 'invalid level'\n render(:update) do |page|\n update_flash(page, flash[:notice])\n end\n return\n end\n\n act_on_members do |gi|\n if gi.level == 'leader' && gi.group.leaders.count == 1\n @member_notices << \"Couldn't change #{gi.person.full_name}'s level from a leader, since that would result in a leaderless group!\"\n else\n @levels_to_update << gi.level # update old\n gi.level = params[:level]\n @levels_to_update << gi.level # update new\n @member_notices << \"#{gi.person.full_name} is now a #{params[:level]}\"\n end\n end\n end",
"def next_level\n if @level.level == MAX_LEVEL\n restart_game\n else\n @level.level += 1\n load_level(\"levels/level\" + @level.level.to_s + \".lvl\")\n end\n end",
"def tree_by_levels_rec(node, level, acc)\n return unless node\n\n acc[level].push(node.value)\n tree_by_levels_rec(node.left, level + 1, acc)\n tree_by_levels_rec(node.right, level + 1, acc)\nend",
"def level=(_arg0); end",
"def level=(_arg0); end",
"def path\n html = ''\n a = []\n m = DcBigMenu.find( @parent.page.menu_id )\n a << m\n while m.parent \n m = DcBigMenu.find( m.parent )\n a << m\n end\n# \n (a.size - 1).downto(0) do |i| \n html << \"<span id=menu-path-#{a.size - 1 - i}>\"\n html << link_4menu(a[i]) \n html << (i > 0 ? ' » ' : '') #›➔\n html << '</span>'\n end\n# Save level to parents params object\n @parent.params[:menu_level] = a.size\n html\nend",
"def incrementLevels(l)\n @level += l\n \n if(@level > @@MAXLEVEL)\n @level = 10\n end\n end",
"def at_depth(depth , *strings)\n prefix = \" \" * 2 * depth\n strings.collect{|str| prefix + str}.join(\"\\n\")\n end",
"def populate(level)\n\t\tinitialize\n\t\tself.name = level\n\t\tself.path = \"#{self.path}/#{level}\"\n\n\t\tDir.new(base_dir = \"#{self.path}\").each do |name|\n\t\tpath = \"#{base_dir}/#{name}\"\n\t\t\tif name !~ /^\\./\n\t\t\t\tif FileTest.directory?(path)\n\t\t\t\t\ttemp_dir = Directory.new\n\t\t\t\t\ttemp_dir.populate(\"#{level}/#{name}\")\n\t\t\t\t\tself.directories << temp_dir\n\t\t\t\telse\n\t\t\t\t\tself.files << name\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def build(level)\r\n # Build list of lines to draw\r\n # First level is base fractal, no offset rotation\r\n fractal_list = []\r\n rec_build(level, @base_fractal[0], 0, fractal_list)\r\n \r\n return fractal_list\r\n end",
"def level_order_print(start, traversal = \"\")\n return traversal unless start\n\n queue = Queue.new\n queue << start\n\n while queue.size > 0 do\n node = queue.pop\n traversal += \"#{node.value}-\"\n queue << node.left if node.left\n queue << node.right if node.right\n end\n\n traversal\n end",
"def exec(level)\n raise \"Level must be between 0-27\" unless level >= 0 && level <= 27\n method = \"level#{level}\"\n raise \"Not implemented yet\" if !self.respond_to?(method)\n\n @logger = Logger.new(level)\n begin\n self.method(method).call\n rescue => e\n @logger.error(e)\n end\n end",
"def level_down(s)\nreturn s.split(\"/\").insert(-2, \"*\").join(\"/\")\nend",
"def try_move row, column, path\n if row >= 0 and row < @level.size and\n column >= 0 and column < @level.last.size and\n @level[row] and @level[row][column] and\n path.is_not_yet_explored?(row, column)\n @moves_queue << [row, column, path]\n end\n end",
"def trace(args)\n if solve(args)\n path_stack, current_cell = [], @seen_stack.last\n path_stack.push(current_cell)\n until @seen_stack.empty?\n current_cell = find_steps(current_cell, path_stack)\n end\n path_stack.reverse.each { |cell| print \"-->#{cell} \" }\n puts \"\"\n path_stack\n else nil\n end\n end",
"def level=(value_)\n if value_.kind_of?(Level)\n @level = value_\n else\n level_obj_ = @level_group.get(value_)\n if level_obj_.nil?\n raise Errors::UnknownLevelError, value_\n end\n @level = level_obj_\n end\n end",
"def build_tree(unit, node, level = 0)\r\n return nil if level > @max_depth\r\n \t\r\n unit.next_move(node.current_case).each do |next_case|\r\n next if next_case[0] < 0 || next_case[0] > 7 ||\r\n next_case[1] < 0 || next_case[1] > 7 \r\n \r\n next_node = Node.new(next_case, node)\r\n node.children << next_node\r\n\r\n build_tree(unit, next_node, level + 1)\r\n end \r\n end",
"def aces_level=(level)\n return if level.nil?\n return unless ['full', 'default', 'none'].include? level.downcase\n logging = REXML::XPath.first(@xml, 'ScanTemplate/Logging')\n if logging.nil?\n logging = REXML::Element.new('Logging')\n @xml.add_element(logging)\n end\n aces = REXML::XPath.first(logging, 'aces')\n if aces.nil?\n aces = REXML::Element.new('aces')\n logging.add_element(aces)\n end\n aces.attributes['level'] = level\n end",
"def update_level\n tags = []\n user_level = 0\n tags = labels.with_private_scope\n .map { |l| [l.key, l.value].join ':' }\n\n levels = Level.all.order(id: :asc)\n levels.each do |lvl|\n break unless tags.include?(lvl.key + ':' + lvl.value)\n\n user_level = lvl.id\n end\n\n update(level: user_level)\n end",
"def menu(items, path, level = 0, maxlevel = 1000)\n return '' unless items # No items, nothing to display\n return '' if level >= maxlevel + 1 || level >= items.size # We've gone too deep or there aren't this many levels\n \n val = \"<ul>\";\n # Go through each item on this level and render them as list items\n items[level].each {|item|\n # We're viewing a nav item in the active path, mark it active and show it's children recursively\n if(path && path[level] && item.id == path[level].id)\n val = val + '<li class=\"active\">' + link_to(item.title, item.realpath) + menu(items, path, level+1, maxlevel)\n else\n val = val + '<li>' + link_to(item.title, item.realpath)\n end\n val = val + '</li>'\n }\n return val + \"</ul>\"\n end",
"def playLevel (n)\n\t\n\tlvl = ((n - 1) % NUM_LEVELS)\n\n\toldPoints = $points\n\n\t# start = Time.now\n\n\troundPoints = 0\n\n\tputs \"You have #{$timeAvailable} seconds to score at \" \\\n\t\t\"least #{$currLevel} points.\\nGood luck!\"\n\n\tcase lvl\n\twhen 0\n\t\tputs \"Write the color, not the word\"\n\twhen 1\n\t\tputs \"Write the word, not the color\"\n\twhen 2\n\t\tputs \"Write the color, followed by the word\"\n\twhen 3\n\t\tputs \"Write the word, followed by the color\"\n\twhen 4\n\t\tputs \"Write the first color, then the second word\"\n\twhen 5\n\t\tputs \"Write the first word, then the second color\"\n\twhen 6\n\t\tputs \"Write the complement color\"\n\twhen 7\n\t\tputs \"Write the complement word\"\n\telse\n\t\tputs \"ERROR in playLevel directions\"\n\t\treturn\n\tend\n\n\t#start the level timer\n\tstart = Time.now\n\n\twhile (Time.now < (start + $timeAvailable))\n\n\t\tif (((Time.now - start) % 10) == 0)\n\t\t\tputs \"\\t\\t#{ime.now - start} seconds remaining\"\n\t\tend\n\n\t\tcase lvl\n\t\twhen 0\n\t\t\troundPoints += singleColor()\n\t\twhen 1\n\t\t\troundPoints += singleWord()\n\t\twhen 2\n\t\t\troundPoints += colorThenWord()\n\t\twhen 3\n\t\t\troundPoints += wordThenColor()\n\t\twhen 4\n\t\t\troundPoints += firstColorSecondWord()\n\t\twhen 5\n\t\t\troundPoints += firstWordSecondColor()\n\t\twhen 6\n\t\t\troundPoints += complementColor()\n\t\twhen 7\n\t\t\troundPoints += complementWord()\n\t\telse \n\t\t\tputs \"ERROR in playLevel selection\"\n\t\t\treturn\n\t\tend\n\n\t\t#early exit option if points satisfied\n\t\tif (roundPoints == $currLevel)\n\t \t\tputs \"---POINT LEVEL REACHED---\\nSkip ahead? (y/n)\"\n\t \t\tc = gets.chomp\n\t \t\tif (c == \"y\")\n\t \t\t\tbreak\n\t \t\tend\n\t \tend\n\tend\n\n\tputs \"LEVEL OVER\".cyan()\n\n\t# BUG: Write the color, not the word\n\t# cyan\n\t# red\n\t# LEVEL OVER\n\t# Good job!\n\t# Please enter 's' to start or 'q' to quit\n\n\t# Please enter in a valid command!\n\t# Please enter 's' to start or 'q' to quit\n\t\t#maybe I hit enter twice?\n\n\t#Another BUG:\n\t#User keeps on hitting enter\n\n\n\tif ($currLevel > roundPoints)\n\t\tputs \"You lose!\".red()\n\t\t$continue = false\n\telse\n\t\tputs \"Good job!\".green()\n\t\t$currLevel += 1\n\t\t$points += roundPoints\n\t\tif ($timeAvailable > 10)\n\t\t\t$timeAvailable -= 5\n\t\tend\n\tend\n\nend",
"def level_order_print(tree)\n unless tree\n return\n end\n\n nodes = [tree]\n current_line_count = 1\n next_line_count = 0\n\n while nodes.length != 0\n current_node = nodes.shift\n current_line_count -= 1\n print current_node.key.to_s + ' '\n if current_node.left_child\n nodes.push(current_node.left_child)\n next_line_count += 1\n end\n if current_node.right_child\n nodes.push(current_node.right_child)\n next_line_count += 1\n end\n if current_line_count == 0\n # finished printing current level\n puts ''\n current_line_count = next_line_count\n next_line_count = current_line_count\n end\n end\nend",
"def level_order_traversal(node)\n h = height(node)\n (1..h).each do |n|\n print_given_level(node, n)\n end\nend",
"def level_text2\n \"#{text_get(27, 29)}#@level\"\n end",
"def setDepthLevels(node=@root,stack=nil,level=0)\n if stack == nil\n stack = []\n end\n\n stack.append([node.name, node.level])\n\n node.children.each do |child|\n child.level = level + 1\n setDepthLevels(child, stack, level+1)\n end\n\n nil\n end",
"def format_level(level)\n @level_cache[level] ||= level.to_s.upcase\n end",
"def update_level\n user_level = 0\n tags = labels.with_private_scope\n .map { |l| [l.key, l.value].join ':' }\n\n levels = Level.all.order(id: :asc)\n levels.each do |lvl|\n break unless tags.include?(lvl.key + ':' + lvl.value)\n\n user_level = lvl.id\n end\n\n update(level: user_level)\n end",
"def set_level(level)\n if SEVERITY.has_key? level\n @log_level=level\n else\n raise ArgumentError, \"Invalid log level given\"\n end\n end",
"def set_level(src, level)\n\t\tlog_levels[src] = level.to_i\n\tend",
"def append(path_step)\n\t\[email protected](path_step)\n\tend",
"def move_sequences_for_piece(board, src, depth = 0)\n new_board = Marshal.load(Marshal.dump(board))\n srcpiece = new_board[src[0]][src[1]]\n\n if srcpiece == ' '\n return []\n end\n\n check_forward = (depth == 0) ? true : false \n \n moves = self.moves_for_piece(board, src, check_forward)\n \n if moves.length == 0\n return []\n end\n\n sequence = []\n sequences = [] \n \n for move in moves\n sequence = []\n sequence << move\n was_jump = false \n kinged = false \n \n src, dst = move \n \n # if the move is a jump\n if (src[0] - dst[0]).abs == 2 and (src[1] - dst[1]).abs == 2\n r = (src[0] + dst[0]) / 2\n c = (src[1] + dst[1]) / 2\n\n # remove middle piece \n new_board[r][c] = ' '\n\n # move jumping piece \n new_board[src[0]][src[1]],\n new_board[dst[0]][dst[1]] = new_board[dst[0]][dst[1]], new_board[src[0]][src[1]]\n was_jump = true \n else\n # move piece \n new_board[src[0]][src[1]],\n new_board[dst[0]][dst[1]] = new_board[dst[0]][dst[1]], new_board[src[0]][src[1]]\n end\n\n # check if piece became a king\n new_piece = new_board[dst[0]][dst[1]]\n\n if (new_piece == 'b' and dst[0] == new_board.length - 1) or\n (new_piece == 'r' and dst[0] == 0)\n kinged = true \n end\n \n # Check if more jumps are available\n # if the piece was not kinged\n if was_jump and not kinged \n new_sequence = move_sequences_for_piece(new_board, dst, depth + 1)\n if new_sequence.length > 0\n sequence.concat new_sequence[0]\n end\n end\n \n sequences << sequence\n new_board = Marshal.load(Marshal.dump(board))\n end\n\n return sequences \n end",
"def draw_route\n # Delete all sprites in drawing of path\n @arrow_path.each{|a| a.dispose}\n @arrow_path = []\n \n return if @passed_positions.empty?\n start_pos = [@unit.x, @unit.y]\n new_pos = start_pos\n type = \"\"\n # Get direction from unit to first tile in path\n last_dir = case [@passed_positions[0].x - @unit.x, @passed_positions[0].y - @unit.y]\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n # Loop through path positions, evaluating two elements at a time\n for i in 0...@passed_positions.size\n p1 = @passed_positions[i]\n p1 = [p1.x, p1.y]\n p2 = (@passed_positions[i+1] == nil ? 0 : @passed_positions[i+1])\n if p2.is_a?(MoveTile)\n p2 = [p2.x, p2.y] \n # Figure out the direction taken to get from p1 to p2\n dir = [p2[0] - p1[0], p2[1] - p1[1]]\n dir = case dir\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n else\n dir = 0\n end\n # Evaluate the last direction taken to get to current spot\n case last_dir\n when 2\n new_pos[1] += 1\n type = case dir\n when 0 then \"d\"\n when 2 then \"v\"\n when 4 then \"ru\"\n when 6 then \"lu\"\n end\n when 4\n new_pos[0] -= 1\n type = case dir\n when 0 then \"l\"\n when 2 then \"ld\"\n when 4 then \"h\"\n when 8 then \"lu\"\n end\n when 6\n new_pos[0] += 1\n type = case dir\n when 0 then \"r\"\n when 2 then \"rd\"\n when 6 then \"h\"\n when 8 then \"ru\"\n end\n when 8\n new_pos[1] -= 1\n type = case dir\n when 0 then \"u\"\n when 4 then \"rd\"\n when 6 then \"ld\"\n when 8 then \"v\"\n end\n end\n last_dir = dir\n @arrow_path.push(Arrow_Sprite.new($spriteset.viewport1, type, new_pos))\n end\n end",
"def level_up\r\n\t\tif @level == 100\r\n\t\t\tputs \"#{@nickname} is at max level\"\r\n\t\telse\r\n\t\t\t@level+= 1\r\n\t\t\tputs \"#{@nickname} grew to level #{@level}!\"\r\n\t\tend\r\n\tend",
"def begin_backtrack(level)\n # System.out.println(\"enter backtrack \"+level);\n @num_backtrack_decisions += 1\n end",
"def decrementLevels(l)\n @level -= l\n \n if(@level <= 0)\n @level = 1\n end\n end",
"def unfinish(paths)\n if paths.empty?\n raise Plan::Advice.new('please drill down to a level to unfinish')\n end\n # go to the right depth and unfinish\n item = path_tree.descend(paths)\n item.unfinish!\n save_path_tree\n # print what happened here\n print_depth item\n end",
"def label\n rv = @level.dup\n rv.delete(0)\n rv.join('.')\n end",
"def turtle_location world [x][y]\n x = 0\n y = 0\n if world [x][y] == 'turtle trail'\n return x\n return y\n x += 1\n else\n turtle_location (world [x+1] [y]) \n turtle_location (world [x] [y+1])\n end\n\n##takes direction 0, 90, 180, 270\n## goal here is to decide the direction of the turtle and the number of spaces I want to move it\n## this assumes there is only one 'm' in the system and then it changes the character to m in adjacent spaces \ndef turtle_trail dir spaces\n if dir == '0'\n world [x] [y+1] = m\n turtle_trail (dir spaces-1) ##trying to make this recursive\n end\n elsif dir == 90\n world [x+1] [y] = m\n turtle_trail (dir spaces-1)\n end\nelsif dir == 180\n world [x] [y+1] = m\n turtle_trail (dir spaces-1)\n end",
"def level=(level)\n init unless @initialized\n unless @level_frozen\n new_level = case level\n when Symbol then level_from_sym(level)\n when String then level_from_sym(level.to_sym)\n else level\n end\n if new_level != @level\n @logger.info(\"[setup] setting log level to #{level_to_sym(new_level).to_s.upcase}\")\n @logger.level = @level = new_level\n end\n end\n level = level_to_sym(@level)\n end",
"def enter_level(new_level = level)\n old_level = level\n self.level = new_level\n yield\n ensure\n self.level = old_level\n end",
"def draw_level_text\n reset_font_settings\n level = QuestData::LEVEL_SIGNALS && QuestData::LEVEL_SIGNALS[@quest.level - 1] ? \n QuestData::LEVEL_SIGNALS[@quest.level - 1] : @quest.level.to_s\n align = QuestData::HEADING_ALIGN[:level]\n tw = text_size(QuestData::VOCAB[:level]).width + 4\n tw2 = text_size(level).width + 2\n space = contents_width - tw - tw2\n x = align == 2 ? space : align == 1 ? space / 2 : 0\n clear_and_draw_text(x, @draw_y, tw, line_height, QuestData::VOCAB[:level])\n set_data_font(:level_signal)\n clear_and_draw_text(x + tw, @draw_y, tw2, line_height, level, 2)\n end",
"def level_up\r\r\n return unless can_level\r\r\n return if @level == @max_level\r\r\n @level += 1\r\r\n if @special == nil then\r\r\n @special = 0\r\r\n end\r\r\n level_update\r\r\n end",
"def tree2path_helper(tree, current, path)\n path << '/' << current\n if !tree.children.empty?\n set = []\n # use reverse to be consistent with the sample in the problem\n tree.children.reverse_each do |child|\n set << child.data unless child.data.include?('-')\n end\n acc = set.inject('') {|acc, e| acc + e + '|'}[0..-2]\n tree2path_helper(tree.children[0], acc, path)\n end\n end",
"def safe_level(*) end",
"def startlevel_set (level)\n execute(:startlevel, level)\n end",
"def draw_route\n # Delete all sprites in drawing of path\n if @arrow_path != nil\n @arrow_path.each{|a|\n a.dispose\n }\n end\n # Initialize variables\n @arrow_path = []\n return if @passed_positions.empty?\n start_pos = [@selected_unit.x, @selected_unit.y]\n new_pos = start_pos\n type = \"\"\n # Get direction from unit to first tile in path\n last_dir = case [@passed_positions[0].x - @selected_unit.x, @passed_positions[0].y - @selected_unit.y]\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n # Loop through path positions, evaluating two elements at a time\n for i in 0...@passed_positions.size\n p1 = @passed_positions[i]\n p1 = [p1.x, p1.y]\n p2 = (@passed_positions[i+1] == nil ? 0 : @passed_positions[i+1])\n if p2.is_a?(MoveTile)\n p2 = [p2.x, p2.y] \n # Figure out the direction taken to get from p1 to p2\n dir = [p2[0] - p1[0], p2[1] - p1[1]]\n dir = case dir\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n else\n dir = 0\n end\n # Evaluate the last direction taken to get to current spot\n case last_dir\n when 2\n new_pos[1] += 1\n case dir\n when 0 then type = \"d\"\n when 2 then type = \"v\"\n when 4 then type = \"ru\"\n when 6 then type = \"lu\"\n end\n when 4\n new_pos[0] -= 1\n case dir\n when 0 then type = \"l\"\n when 2 then type = \"ld\"\n when 4 then type = \"h\"\n when 8 then type = \"lu\"\n end\n when 6\n new_pos[0] += 1\n case dir\n when 0 then type = \"r\"\n when 2 then type = \"rd\"\n when 6 then type = \"h\"\n when 8 then type = \"ru\"\n end\n when 8\n new_pos[1] -= 1\n case dir\n when 0 then type = \"u\"\n when 4 then type = \"rd\"\n when 6 then type = \"ld\"\n when 8 then type = \"v\"\n end\n end\n last_dir = dir\n @arrow_path.push(Arrow_Sprite.new(@arrows_viewport, type, new_pos))\n end\n end",
"def level=(new_lvl)\n @level = new_lvl\n $game_party.quests.add_to_sort_array(:level, @id) if $game_party && \n $game_party.quests\n end"
] | [
"0.5314205",
"0.5260916",
"0.5234392",
"0.51740676",
"0.50891215",
"0.49452057",
"0.49185005",
"0.4801137",
"0.4801137",
"0.47863123",
"0.47711605",
"0.47627452",
"0.4758066",
"0.47531688",
"0.47139624",
"0.47053957",
"0.47049835",
"0.46991277",
"0.468896",
"0.46480274",
"0.4638592",
"0.46226776",
"0.4604629",
"0.45901635",
"0.4579477",
"0.45436013",
"0.45398393",
"0.45244655",
"0.451987",
"0.45042348",
"0.4484467",
"0.44663283",
"0.44283888",
"0.4417691",
"0.4417691",
"0.44103158",
"0.4410282",
"0.44097435",
"0.43973738",
"0.43847895",
"0.4377324",
"0.43721592",
"0.43546695",
"0.43500867",
"0.4341731",
"0.4334519",
"0.43332383",
"0.4330663",
"0.43284658",
"0.43209946",
"0.43110526",
"0.4302807",
"0.4293967",
"0.42928728",
"0.42808297",
"0.42796403",
"0.42795673",
"0.42795673",
"0.42792085",
"0.4276566",
"0.42650178",
"0.4263176",
"0.42573258",
"0.42537525",
"0.42531633",
"0.4247401",
"0.4246022",
"0.42255253",
"0.42230865",
"0.42219833",
"0.42041403",
"0.42037982",
"0.42022097",
"0.42021388",
"0.41974953",
"0.41808712",
"0.41721538",
"0.4171129",
"0.41485038",
"0.41345736",
"0.41281253",
"0.41280514",
"0.41244763",
"0.41242546",
"0.41230932",
"0.41156712",
"0.41112447",
"0.41099435",
"0.4106364",
"0.4098165",
"0.40915623",
"0.40913245",
"0.40886965",
"0.4085295",
"0.40790436",
"0.40762174",
"0.40761304",
"0.40749615",
"0.40715137",
"0.40653324"
] | 0.678769 | 0 |
get form authenticity_token hack of CSRF | def get_token
render :text => form_authenticity_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_authenticity_token() 'token' end",
"def form_authenticity_token\n \"foo\"\n end",
"def authenticity_token\n @authenticity_token || helper.form_authenticity_token\n end",
"def authenticity_token\n @authenticity_token || helper.form_authenticity_token\n end",
"def form_authenticity_token(form_options: T.unsafe(nil)); end",
"def form_authenticity_token\n @form_authenticity_token ||= if !session.respond_to?(:session_id)\n raise InvalidAuthenticityToken, \"Request Forgery Protection requires a valid session. Use #allow_forgery_protection to disable it, or use a valid session.\"\n elsif request_forgery_protection_options[:secret]\n authenticity_token_from_session_id\n elsif session.respond_to?(:dbman) && session.dbman.respond_to?(:generate_digest)\n authenticity_token_from_cookie_session\n else\n raise InvalidAuthenticityToken, \"No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).\"\n end\n end",
"def submitted_csrf_token\n request.env['HTTP_X_CSRF_TOKEN'] || params['csrf_token']\n end",
"def auth_token\n (protect_against_forgery? ? form_authenticity_token : nil)\n end",
"def masked_authenticity_token(session, form_options: T.unsafe(nil)); end",
"def authenticity_token\n render json: { token: form_authenticity_token }\n end",
"def rails_csrf_token\n rails_controller_instance.send(:form_authenticity_token)\n end",
"def auth_csrf_token\n request.env['HTTP_X_AUTH_CSRF']\n end",
"def rails_csrf_token\n rails_controller_instance.send(:form_authenticity_token)\n end",
"def form_authenticity_param; end",
"def form_authenticity_token(body)\n regex = /type=\"hidden\" name=\"authenticity_token\" value=\"(?<token>.+)\"/\n parts = response.body.match(regex)\n parts['token'] if parts\n end",
"def authenticity_token_from_cookie_session\n session[:csrf_id] ||= CGI::Session.generate_unique_id\n session.dbman.generate_digest(session[:csrf_id])\n end",
"def rails_csrf_param\n rails_controller.request_forgery_protection_token\n end",
"def rails_csrf_param\n rails_controller.request_forgery_protection_token\n end",
"def csrf_token_hash(action=nil)\n vc = @controller.view_context\n # :nocov:\n if vc.protect_against_forgery?\n # :nocov:\n {vc.request_forgery_protection_token.to_s=>vc.form_authenticity_token}\n end\n end",
"def csrf_token\n session[:csrf] ||= SecureRandom.hex 32\n end",
"def csrf_token\n env[\"rack.session\"].fetch(:csrf)\nend",
"def request_authenticity_tokens; end",
"def yield_authenticity_token\n if protect_against_forgery?\n <<JAVASCRIPT\n <script type='text/javascript'>\n //<![CDATA[\n window._auth_token_name = \"#{request_forgery_protection_token}\";\n window._auth_token = \"#{form_authenticity_token}\";\n //]]>\n </script>\nJAVASCRIPT\n end\n end",
"def rails_csrf_tag\n %(<input type=\"hidden\" name=\"#{rails_csrf_param}\" value=\"#{rails_csrf_token}\">)\n end",
"def rails_csrf_tag\n %(<input type=\"hidden\" name=\"#{rails_csrf_param}\" value=\"#{rails_csrf_token}\">)\n end",
"def append_csrf_token_in_params\n params[:authenticity_token] ||= request.headers.env['HTTP_X_CSRF_TOKEN']\n end",
"def csrf_field\n csrf_options[:field]\n end",
"def verify_authenticity_token; end",
"def csrf_params_hash\n return { request_forgery_protection_token => form_authenticity_token }\n end",
"def csrf_metatag\n \"<meta name=\\\"#{csrf_field}\\\" content=\\\"#{csrf_token}\\\" \\/>\"\n end",
"def set_csrf_cookie\n cookies['CSRF-TOKEN'] = form_authenticity_token\n end",
"def csrf; end",
"def csrf_meta_tags; end",
"def authenticity_token\n @context.registers[:authenticity_token]\n end",
"def yield_authenticity_token\n if protect_against_forgery?\n <<-JAVASCRIPT\n <script type='text/javascript'>\n //<![CDATA[\n var AUTH_TOKEN = \"#{form_authenticity_token}\";\n //]]>\n </script>\n JAVASCRIPT\n end\n end",
"def csrf_token(path=nil, method=('POST' if path))\n token = SecureRandom.random_bytes(31)\n token << csrf_hmac(token, method, path)\n Base64.strict_encode64(token)\n end",
"def any_authenticity_token_valid?; end",
"def set_csrf_cookie\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def auth_token(context)\n controller = context.registers[:controller]\n value = controller.send(:form_authenticity_token)\n\n %(<input type=\"hidden\" name=\"authenticity_token\" value=\"#{value}\"> <input autocomplete=\"off\" type=\"text\" name=\"shoperb_first_last_name_1\" value=\"\" style=\"color: black; display: none;\" />)\n end",
"def masked_authenticity_token(session)\n one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN_LENGTH)\n encrypted_csrf_token = xor_byte_strings(one_time_pad, real_csrf_token(session))\n masked_token = one_time_pad + encrypted_csrf_token\n Base64.strict_encode64(masked_token)\n end",
"def clean_up_csrf?; end",
"def clean_up_csrf?; end",
"def protect_against_forgery?; end",
"def set_csrf_cookie_for_ng\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def set_csrf_cookie_for_ng\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def set_csrf_cookie_for_ng\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def set_csrf_cookie_for_ng\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def set_csrf_cookie_for_ng\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def set_csrf_cookie_for_ng\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def set_csrf_cookie_for_ng\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def set_csrf_cookie_for_ng\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def check_csrf?\n true\n end",
"def csrf=(_arg0); end",
"def check_csrf?\n true\n end",
"def csrf_header\n csrf_options[:header]\n end",
"def set_csrf_headers\n if request.xhr?\n cookies['XSRF-TOKEN'] = form_authenticity_token if cookies['XSRF-TOKEN'].blank?\n end\n end",
"def verified_request?\r\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\r\n end",
"def rails_check_csrf!\n rails_controller_instance.send(:verify_authenticity_token)\n end",
"def rails_check_csrf!\n rails_controller_instance.send(:verify_authenticity_token)\n end",
"def set_csrf_cookie_for_ng\n\t\tcookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n\tend",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def verified_request?\n super || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n end",
"def check_csrf\n rails_check_csrf!\n end",
"def check_csrf\n rails_check_csrf!\n end",
"def verify_csrf_token?\n false\n end",
"def csrf_token_from_response(response)\n # raises some exceptions here for parsing\n t = ::Nokogiri::HTML(response.body).xpath('//meta[@name=\"csrf-param\"]/@content')\n {\"X-CSRF-Token\" => ((t && t.first)? t.first.value : 'NULL')}\n end",
"def handle_unverified_request\n logger.warn \" Form token: #{params[request_forgery_protection_token]}\" if logger\n logger.warn \" Header token: #{request.headers['X-CSRF-Token']}\" if logger\n logger.warn \" Session token: #{session[:_csrf_token]}\" if logger\n super\n end",
"def set_csrf_headers\n response.headers['X-CSRF-Token'] = form_authenticity_token\n end",
"def csrf_tag(*)\n rails_csrf_tag\n end",
"def set_xsrf_token_cookie\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n end",
"def csrf_tag(*)\n rails_csrf_tag\n end",
"def valid_authenticity_token?(session, encoded_masked_token); end",
"def xsrf_token\n SecureRandom.urlsafe_base64 + SecureRandom.urlsafe_base64 + SecureRandom.urlsafe_base64\n end",
"def csrf_invalid_message(opts)\n opts = opts.empty? ? csrf_options : csrf_options.merge(opts)\n method = request.request_method\n\n unless opts[:check_request_methods].include?(method)\n return\n end\n\n unless encoded_token = opts[:token]\n encoded_token = case opts[:check_header]\n when :only\n env[opts[:env_header]]\n when true\n return (csrf_invalid_message(opts.merge(:check_header=>false)) && csrf_invalid_message(opts.merge(:check_header=>:only)))\n else\n @_request.params[opts[:field]]\n end\n end\n\n unless encoded_token.is_a?(String)\n return \"encoded token is not a string\"\n end\n\n if (rack_csrf_key = opts[:upgrade_from_rack_csrf_key]) && (rack_csrf_value = session[rack_csrf_key]) && csrf_compare(rack_csrf_value, encoded_token)\n return\n end\n\n # 31 byte random initialization vector\n # 32 byte HMAC\n # 63 bytes total\n # 84 bytes when base64 encoded\n unless encoded_token.bytesize == 84\n return \"encoded token length is not 84\"\n end\n\n begin\n submitted_hmac = Base64.strict_decode64(encoded_token)\n rescue ArgumentError\n return \"encoded token is not valid base64\"\n end\n\n random_data = submitted_hmac.slice!(0...31)\n\n if csrf_compare(csrf_hmac(random_data, method, @_request.path), submitted_hmac)\n return\n end\n\n if opts[:require_request_specific_tokens]\n \"decoded token is not valid for request method and path\"\n else\n unless csrf_compare(csrf_hmac(random_data, '', ''), submitted_hmac)\n \"decoded token is not valid for either request method and path or for blank method and path\"\n end\n end\n end",
"def authenticity_token_value(onclick)\n return unless onclick && onclick.include?(\"s.setAttribute('name', 'authenticity_token');\") &&\n onclick =~ /s\\.setAttribute\\('value', '([a-f0-9]{40})'\\);/\n $LAST_MATCH_INFO.captures.first\n end",
"def csrf_secret\n key = session[csrf_options[:key]] ||= SecureRandom.base64(32)\n Base64.strict_decode64(key)\n end",
"def set_csrf_cookie\n csrf_cookie_key = 'XSRF-TOKEN'\n cookies[csrf_cookie_key] = form_authenticity_token if protect_against_forgery? && current_user\n end",
"def csrf_options\n opts[:route_csrf]\n end",
"def invalid_authenticity_request\n sign_out(current_user)\n cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?\n render error: 'invalid token', status: :unprocessable_entity\n end",
"def respond_with_csrf_header\n # Only return the authenticity token to approved origins.\n return unless request.headers['HTTP_ORIGIN'] && origin_is_whitelisted?\n # Only return the authenticity token for JSON requests to approved API actions\n if(API_ACTIONS.include?(action_name) && formats.include?(:json))\n response.headers['X-CSRF-Token'] = form_authenticity_token\n end\n end",
"def protect_from_forgery\n end",
"def verified_request?\n\t\tsuper || form_authenticity_token == request.headers['X-XSRF-TOKEN']\n\tend",
"def check_json_authenticity\n return unless request.format.js? or request.format.json?\n return unless protect_against_forgery?\n return unless params[request_forgery_protection_token]\n auth_token = params[request_forgery_protection_token]\n unless (auth_token and form_authenticity_token == URI.unescape(auth_token))\n raise(ActionController::InvalidAuthenticityToken)\n end\n end",
"def check_json_authenticity\n return unless request.format.js? or request.format.json?\n return unless protect_against_forgery?\n auth_token = params[request_forgery_protection_token]\n unless (auth_token and form_authenticity_token == URI.unescape(auth_token))\n raise(ActionController::InvalidAuthenticityToken)\n end\n end",
"def check_json_authenticity\n return unless request.format.js? or request.format.json?\n return unless protect_against_forgery?\n auth_token = params[request_forgery_protection_token]\n unless (auth_token and form_authenticity_token == URI.unescape(auth_token))\n raise(ActionController::InvalidAuthenticityToken)\n end\n end",
"def protect_against_forgery?\n end",
"def use_request_specific_csrf_tokens?\n csrf_options[:require_request_specific_tokens]\n end",
"def clean_up_csrf?\n true\n end",
"def clean_up_csrf?\n true\n end",
"def authenticity_token_from_session_id\n key = if request_forgery_protection_options[:secret].respond_to?(:call)\n request_forgery_protection_options[:secret].call(@session)\n else\n request_forgery_protection_options[:secret]\n end\n digest = request_forgery_protection_options[:digest] ||= 'SHA1'\n OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(digest), key.to_s, session.session_id.to_s)\n end",
"def generate_csrf_token\n SecureRandom.hex(32)\n end",
"def clean_up_csrf?\n false\n end",
"def allow_forgery_protection\n true\n end",
"def check_json_authenticity\n\t\treturn unless request.format.js? or request.format.json?\n\t\treturn unless protect_against_forgery?\n\t\tauth_token = params[request_forgery_protection_token]\n\t\tunless (auth_token and form_authenticity_token == URI.unescape(auth_token))\n\t\t\traise(ActionController::InvalidAuthenticityToken)\n\t\tend\n\tend",
"def protect_against_forgery?\n\n end",
"def csrf_tag(*args)\n \"<input type=\\\"hidden\\\" name=\\\"#{csrf_field}\\\" value=\\\"#{csrf_token(*args)}\\\" \\/>\"\n end",
"def protect_against_forgery?\n false\nend",
"def set_csrf_headers\n if request.xhr?\n # Add the newly created csrf token to the page headers\n # These values are sent on 1 request only\n response.headers['X-CSRF-Token'] = \"#{form_authenticity_token}\"\n response.headers['X-CSRF-Param'] = \"#{request_forgery_protection_token}\"\n end\n end"
] | [
"0.83122253",
"0.81716126",
"0.81558424",
"0.81546754",
"0.7946493",
"0.78806067",
"0.7771748",
"0.77306855",
"0.7704565",
"0.76784277",
"0.7641175",
"0.7593425",
"0.7561072",
"0.75298667",
"0.7473944",
"0.740587",
"0.7388497",
"0.7337628",
"0.73260564",
"0.729371",
"0.7289964",
"0.7286101",
"0.70789164",
"0.70466095",
"0.70402527",
"0.7038453",
"0.698596",
"0.6965333",
"0.69491637",
"0.69400066",
"0.68903875",
"0.68791705",
"0.6872046",
"0.6868523",
"0.6860751",
"0.6860056",
"0.68120474",
"0.6784401",
"0.67506266",
"0.6727749",
"0.67216927",
"0.67216927",
"0.6708247",
"0.6697178",
"0.6697178",
"0.6697178",
"0.6697178",
"0.6697178",
"0.6697178",
"0.6697178",
"0.6697178",
"0.669172",
"0.6679303",
"0.66424793",
"0.6621007",
"0.6615341",
"0.6577123",
"0.6572852",
"0.65701216",
"0.65599036",
"0.655056",
"0.655056",
"0.655056",
"0.655056",
"0.6532979",
"0.6519569",
"0.65098125",
"0.6500432",
"0.6485702",
"0.64785427",
"0.6467573",
"0.64666617",
"0.6459126",
"0.6435439",
"0.63814497",
"0.633543",
"0.6326839",
"0.6321527",
"0.63167584",
"0.6287191",
"0.62802297",
"0.6260439",
"0.6252455",
"0.62458766",
"0.62411517",
"0.62297964",
"0.62297964",
"0.6229394",
"0.6228253",
"0.621734",
"0.621734",
"0.6212655",
"0.6211379",
"0.6169768",
"0.6157819",
"0.6148331",
"0.61398464",
"0.6132958",
"0.6120637",
"0.6115407"
] | 0.7741136 | 7 |
PUT /theme/1 PUT /theme/1.xml | def update
@site = Site.find_by_id( @site.id)
if @site.nil? || @site.site_layout.nil?
respond_to do |format|
@themes = Layout::Theme.load.sort {|a,b| a.order <=> b.order }
@selected_theme = @themes.find_by_name(@site.site_layout.theme)
flash[:notice] = I18n.t("not_found", :scope => TRANSLATION_SCOPE)
format.html {
render :action => "index" }
format.xml { render :xml => @site.errors,
:status => :unprocessable_entity }
return
end
end
# 属性設定
# @site.user_id = current_user.id
@site.site_layout.attributes = params[:site_layout]
@site.user = current_user
respond_to do |format|
# 変更されていれば、履歴を作成
if @site.site_layout.save(:validate => true)
format.html { redirect_to(index_url,
:notice => I18n.t("updated", :scope => TRANSLATION_SCOPE))}
format.xml { head :ok }
else
@themes = Layout::Theme.load
@selected_theme = @themes.find_by_name(@site.site_layout.theme)
format.html { render :action => "index" }
format.xml { render :xml => @site.errors,
:status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @theme.update_attributes(params[:theme])\n flash[:notice] = 'Theme was successfully updated.'\n format.html { redirect_to(@theme) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @theme.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @theme = Theme.find(params[:id])\n\n respond_to do |format|\n if @theme.update_attributes(params[:theme])\n format.html { redirect_to @theme, notice: 'Theme was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @theme = Theme.find(params[:id])\n\n respond_to do |format|\n if @theme.update_attributes(params[:theme])\n format.html { redirect_to @theme, notice: 'Theme was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @theme = Theme.find(params[:id])\n\n respond_to do |format|\n if @theme.update_attributes(params[:theme])\n format.html { redirect_to @theme, notice: 'Theme was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @theme = TemplateTheme.find(params[:id])\n\n respond_to do |format|\n if @theme.update_attributes(params[:theme])\n format.html { redirect_to(@theme, :notice => 'TemplateTheme was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @theme.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_theme user\n user.theme = Theme.get(params[\"theme\"])\n end",
"def update\n respond_to do |format|\n if @theme.update(theme_params)\n format.html { redirect_to @theme, notice: 'Theme was successfully updated.' }\n format.json { render :show, status: :ok, location: @theme }\n else\n format.html { render :edit }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @theme = Theme.find(params[:id])\n\n respond_to do |format|\n if @theme.update_attributes(params[:theme])\n format.html { redirect_to themes_path, notice: '修改成功.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n theme = Theme.find(params[:idTheme])\n if theme.update(params_theme)\n render json: theme, status: 200\n else\n render json: theme.errors, status: 422\n end\n\n end",
"def update\n @theme = Theme.find(params[:id])\n @theme.service_ids = params[\"theme\"][\"theme_services\"].reject!{ |c| !c.present? }\n respond_to do |format|\n if @theme.update_attributes(theme_params)\n format.html { redirect_to themes_path, notice: I18n.t('commons.successfully_updated') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if !current_group.shapado_version.has_custom_js?\n params[:theme].delete(:javascript)\n end\n if !current_group.shapado_version.has_custom_themes?\n params[:theme].delete(:javascript)\n params[:theme].delete(:layout_html)\n params[:theme].delete(:questions_index_html)\n params[:theme].delete(:questions_show_html)\n end\n @theme = Theme.find(params[:id])\n @theme.ready = false\n @theme.set_has_js(params[:theme][:javascript])\n\n respond_to do |format|\n if @theme.update_attributes(params[:theme])\n Jobs::Themes.async.generate_stylesheet(@theme.id).commit!(4)\n format.html { redirect_to(edit_theme_path(@theme), :notice => 'Theme was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @theme.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @theme.update(params[:theme])\n # After uploaded a new zip file delete old exctract and extract the content of the new file.\n # @theme.extract_new_preview\n\n format.html { redirect_to themes_url, notice: 'Theme was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @wtheme = Wtheme.find(params[:id])\n\n respond_to do |format|\n if @wtheme.update_attributes(params[:wtheme])\n format.html { redirect_to @wtheme, notice: 'Wtheme was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wtheme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @jquery_theme = JqueryTheme.find(params[:id])\n\n respond_to do |format|\n if @jquery_theme.update_attributes(params[:jquery_theme])\n format.html { redirect_to @jquery_theme, :notice => 'Jquery theme was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @jquery_theme.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @node_has_theme.update(node_has_theme_params)\n format.html { redirect_to @node_has_theme, notice: 'Node has theme was successfully updated.' }\n format.json { render :show, status: :ok, location: @node_has_theme }\n else\n format.html { render :edit }\n format.json { render json: @node_has_theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @theme1.update(theme1_params)\n format.html { redirect_to @theme1, notice: 'Theme1 was successfully updated.' }\n format.json { render :show, status: :ok, location: @theme1 }\n else\n format.html { render :edit }\n format.json { render json: @theme1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cms_theme.update(cms_theme_params)\n format.html { redirect_to cms_themes_path, notice: \"Theme #{@cms_theme.name} was successfully updated.\" }\n format.json { render :index, status: :ok, location: @cms_theme }\n else\n format.html { render :edit }\n format.json { render json: @cms_theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @attribute = nil\n @message = nil\n respond_to do |format|\n now = Time.now.strftime(\"%Y-%m-%d %H:%M\")\n format.js do\n @theme.update(theme_params)\n end\n format.html do\n if @theme.update!(theme_params)\n flash[:success] = 'Theme was successfully updated.'\n redirect_to admin_theme_url(@theme)\n else\n format.html { render :edit }\n end\n end\n end\n end",
"def update\n @forumtheme = Forumtheme.find(params[:id])\n\n respond_to do |format|\n if @forumtheme.update_attributes(params[:forumtheme])\n format.html { redirect_to(:action => 'index' , :id => @forumtheme.forumroot_id) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @forumtheme.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_theme\n @theme = Theme.find(params[:id])\n end",
"def set_theme\n @theme = Theme.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @theme.update(adminthemes_params)\n format.html { redirect_to @admintheme, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @admintheme }\n else\n format.html { render :edit }\n format.json { render json: @admintheme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subtheme = Subtheme.find(params[:id])\n\n if @subtheme.update(subtheme_params)\n head :no_content\n else\n render json: @subtheme.errors, status: :unprocessable_entity\n end\n end",
"def edit\n @theme = Theme.find(params[:id])\n end",
"def set_theme\n @theme = params[:id].to_i.zero? ? Theme.new : Theme.find(params[:id])\n end",
"def set_theme\n @theme = Theme.find_by(name: params[:name])\n end",
"def change_theme\n @theme = Theme.find(params[:theme_id])\n @business.theme_id = @theme.id\n @business.save\n render :json => @business.to_json, :callback => params['callback']\n end",
"def set_theme\n # @theme = Theme.find(params[:id])\n @theme = Theme.current_theme\n end",
"def apply_theme( theme)\n self.theme_id= theme.id \n save!\n end",
"def set_theme1\n @theme1 = Theme1.find(params[:id])\n end",
"def update\n respond_to do |format|\n session[:return_to] ||= request.referer\n if @theme_name.update(theme_name_params)\n format.html { redirect_to session.delete(:return_to), notice: 'Saved' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @theme_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def respond_with_saved_theme!(theme, attrs)\n theme.name = attrs[:name]\n theme.blocks = attrs[:blocks].map { |block| Block.new(block) }\n theme.regions = attrs[:regions].map { |region| Region.new(region) }\n theme.templates = attrs[:templates].map { |template| Template.new(template) }\n theme.style = attrs[:style]\n\n if theme.save\n theme.archive_job_id = generate_theme_archive(theme)\n\n status 200\n respond_with theme\n else\n status 400\n respond_with theme.errors\n end\n end",
"def save_theme\n theme = Theme.new(params[:name])\n if theme.active?\n flash[:notice] = 'That theme is already active.'\n else\n theme.activate!\n flash[:success] = 'Theme changed.'\n end\n redirect_to :action => 'theme'\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def create\n @theme = Theme.new(params[:theme])\n\n respond_to do |format|\n if @theme.save\n format.html { redirect_to @theme, notice: 'Theme was successfully created.' }\n format.json { render json: @theme, status: :created, location: @theme }\n else\n format.html { render action: \"new\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(cms_site_params)\n\n format.html { redirect_to cms.sites_url, notice: '站点已修改.' }\n format.json { head :no_content }\n else\n @cms_theme = Cms::Theme.all\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_theme_intere\n @theme_intere = ThemeIntere.find(params[:id])\n end",
"def create\n @theme = Theme.new(params[:theme])\n\n respond_to do |format|\n if @theme.save\n format.html { redirect_to themes_path, notice: '添加成功.' }\n format.json { render json: @theme, status: :created, location: @theme }\n else\n format.html { render action: \"new\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_team_theme\n @team_theme = TeamTheme.find(params[:id])\n end",
"def set_theme\n @theme = Theme.find_by(id: params[:id],site_id: @site.id)\n redirect_to admin_errors_url(error_template: '403') unless @theme\n end",
"def create\n @wtheme = Wtheme.new(params[:wtheme])\n\n respond_to do |format|\n if @wtheme.save\n format.html { redirect_to wthemes_url }\n format.json { head :no_content }\n end\n end\n end",
"def create\n @theme = TemplateTheme.new(params[:theme])\n\n respond_to do |format|\n if @theme.save\n format.html { redirect_to(@theme, :notice => 'TemplateTheme was successfully created.') }\n format.xml { render :xml => @theme, :status => :created, :location => @theme }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @theme.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_current_theme(name, options = {})\n self.class.renders_theme(name, options)\n Rails.application.config.theme.name = current_theme_name\n Rails.application.config.theme.layout = current_theme_layout\n ShinyThemes::Engine.theme_config.save unless options[:dont_save]\n self.class.theme # return current theme object\n end",
"def create\n @theme = Theme.new(theme_params)\n respond_to do |format|\n if @theme.save\n flash[:success] = 'Theme was successfully created.'\n format.html { redirect_to admin_theme_url(@theme) }\n format.json { render :show, status: :created, location: @theme }\n else\n flash[:danger] = 'Theme was successfully created.'\n format.html { render :new }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_theme_name\n @theme_name = ThemeName.find(params[:id])\n end",
"def create\n @theme = Theme.new(params[:theme])\n \n @theme.save ##UNCOMMENT LATER\n @theme.init_blanks\n \n respond_to do |format|\n if @theme.save\n format.html { redirect_to @theme, notice: 'Theme was successfully created.' }\n format.json { render json: @theme, status: :created, location: @theme }\n else\n format.html { render action: \"new\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_box_theme(id, theme)\n @themes[id] = theme.to_i\n end",
"def theme\n @theme ||= Theme.unscoped.find(params[:id])\n halt 404 unless @theme\n @theme\n end",
"def destroy\n @theme.destroy\n\n respond_to do |format|\n format.html { redirect_to(themes_url) }\n format.xml { head :ok }\n end\n end",
"def create\n @theme = Theme.new(theme_params)\n\n respond_to do |format|\n if @theme.save\n format.html { redirect_to @theme, notice: 'Theme was successfully created.' }\n format.json { render :show, status: :created, location: @theme }\n else\n format.html { render :new }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n unless @organization_theme.update(organization_theme_params)\n render json: @organization_theme.errors\n end\n end",
"def show\n @theme = TemplateTheme.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @theme }\n end\n end",
"def create\n params[:theme] ||= {}\n params[:theme][:theme_name] = params[:theme][:name]\n params[:theme][:staged] = true\n\n unless ThemePackage.themes.include?(theme_params[:name])\n render(nothing: true, status: :not_found) and return\n end\n\n if @user.standard_themes.count >= 10\n @message = \"Your account only allows 5 themes.\"\n elsif (theme = @user.standard_themes.find_by_theme_name(theme_params[:name]))\n @user.standard_themes.update_all(:staged => false)\n theme.staged = true\n theme.save\n\n @status = \"good\"\n @message = \"'#{theme.theme_name}' theme is now staged\"\n else\n @user.standard_themes.update_all(:staged => false)\n if theme = @user.standard_themes.create(theme_params)\n @status = \"good\"\n @message = \"'#{theme.theme_name}' theme is now staged\"\n else\n @message = theme.errors.to_a.join(' ')\n end\n end\n\n serve_json_response\n end",
"def set_theme_mod(name, value)\n # TS_INFO: Manage themes not implemented\n end",
"def destroy\n @theme = Theme.find(params[:id])\n @theme.destroy\n\n respond_to do |format|\n format.html { redirect_to themes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @theme = Theme.find(params[:id])\n @theme.destroy\n\n respond_to do |format|\n format.html { redirect_to themes_url }\n format.json { head :no_content }\n end\n end",
"def settheme\n ct = Theme.find_by_filename(params[:preference][:theme])\n unless ct.wallpaper\n session[:wallpaper] = false\n current_user.preference.wallpaper = false\n end\n \n respond_to do |format|\n if current_user.preference.update_attributes(params[:preference])\n set_session\n format.html {redirect_to :back}\n format.js {render \"reminder_save\"}\n else\n format.js {render \"shared/save_failed\"}\n end\n end\n end",
"def change_theme\n cookies[:theme] = { value: params[:id].replace_non_alphanumeric, expires: Time.now + 1825.days }\n redirect_back(fallback_location: index)\n end",
"def apply\n SpreeTheme.site_class.current.apply_theme @template_theme \n respond_with(@template_theme) \n end",
"def theme_changed\n assert_privileges('my_settings_visuals')\n # ui1 theme changed\n @edit = session[:edit]\n @edit[:new][:display][:theme] = params[:theme] # Capture the new setting\n session[:changed] = (@edit[:new] != @edit[:current])\n @changed = session[:changed]\n render :update do |page|\n page << javascript_prologue\n page.replace('tab_div', :partial => 'ui_1')\n end\n end",
"def show\n @theme = Theme.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @theme }\n end\n end",
"def create\n @theme = Theme.new(theme_params)\n @theme.service_ids = params[\"theme\"][\"theme_services\"].reject!{ |c| !c.present? }\n respond_to do |format|\n if @theme.save\n format.html { redirect_to themes_path, notice: I18n.t('commons.successfully_created') }\n format.json { render json: @theme, status: :created, location: @theme }\n else\n format.html { render action: \"new\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @theme = Theme.new(params[:theme])\n @theme.user_id = current_user.id\n respond_to do |format|\n if @theme.save\n # After uploaded zip file extract the content of the file\n #@theme.extract_preview\n\n format.html { redirect_to themes_url, notice: 'Theme was successfully created.' }\n format.json { render action: 'index', status: :created, location: @theme }\n else\n format.html { render action: 'new' }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @theme_group.update(theme_group_params)\n format.html {redirect_to @theme_group, notice: 'Theme group was successfully updated.'}\n format.json {render :show, status: :ok, location: @theme_group}\n else\n format.html {render :edit}\n format.json {render json: @theme_group.errors, status: :unprocessable_entity}\n end\n end\n end",
"def show\n @theme = Theme.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render :json => @theme }\n end\n end",
"def destroy\n @theme = TemplateTheme.find(params[:id])\n @theme.destroy\n\n respond_to do |format|\n format.html { redirect_to(template_themes_url) }\n format.xml { head :ok }\n end\n end",
"def show\n @theme = Theme.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @theme }\n end\n end",
"def show\n @theme = Theme.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @theme }\n end\n end",
"def get_theme\n @theme = Theme.find(params[:theme_id])\n end",
"def create\n @theme1 = Theme1.new(theme1_params)\n\n respond_to do |format|\n if @theme1.save\n format.html { redirect_to @theme1, notice: 'Theme1 was successfully created.' }\n format.json { render :show, status: :created, location: @theme1 }\n else\n format.html { render :new }\n format.json { render json: @theme1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if !current_group.shapado_version.has_custom_js?\n params[:theme].delete(:javascript)\n end\n if !current_group.shapado_version.has_custom_themes?\n params[:theme].delete(:javascript)\n params[:theme].delete(:layout_html)\n params[:theme].delete(:questions_index_html)\n params[:theme].delete(:questions_show_html)\n end\n @theme = Theme.new(params[:theme])\n @theme.group = current_group\n @theme.ready = false\n @theme.set_has_js(params[:theme][:javascript])\n\n respond_to do |format|\n if @theme.save\n Jobs::Themes.async.generate_stylesheet(@theme.id).commit!(4)\n format.html { redirect_to(@theme, :notice => 'Theme was successfully created.') }\n format.json { render :json => @theme, :status => :created, :location => @theme }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @theme.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n tname = @cms_theme.name\n @cms_theme.destroy\n respond_to do |format|\n format.html { redirect_to cms_themes_url, notice: \"Theme #{tname} was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def get_theme\n respond theme, 200, {'Content-Type' => 'text/plain'}\n end",
"def update\n @content = Content.find(params[:id])\n\n\n if @content.update_attributes(@content)\n format.html { redirect_to [@theme, @content], notice: 'Content was successfully updated.' }\n end\n\n end",
"def update\n session[:app_id]=params[:theme_color][:app_id]\n respond_to do |format|\n if @theme_color.update(theme_color_params)\n @theme_color.color = @theme_color.color.gsub(\"#\", \"0x\")\n @theme_color.save\n format.html { redirect_to theme_colors_path(:app_id => @theme_color.app_id), notice: 'Theme color was successfully updated.' }\n format.json { render :show, status: :ok, location: @theme_color }\n else\n format.html { render :edit }\n format.json { render json: @theme_color.errors, status: :unprocessable_entity }\n end\n end\n end",
"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 new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @theme }\n end\n end",
"def destroy\n @theme.destroy\n respond_to do |format|\n flash[:success] = 'Theme was successfully deleted.'\n format.html { redirect_to themes_url }\n format.json { head :no_content }\n end\n end",
"def create\n @theme = Theme.new(params[:theme])\n\n respond_to do |format|\n if @theme.save\n format.html { \n redirect_to controller: \"posts\", action: \"new\", emotion: params[:emotion]\n \n }\n format.json { render json: @theme, status: :created, location: @theme }\n else\n format.html { render action: \"new\" }\n format.json { render json: @theme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @theme.destroy\n respond_to do |format|\n format.html { redirect_to themes_url, notice: 'Theme was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def switch_theme(stylesheet)\n # TS_INFO: Manage themes not implemented\n end",
"def destroy\n @theme = Theme.find(params[:id])\n @theme.destroy\n\n respond_to do |format|\n format.html { redirect_to themes_path, notice: '删除成功.' }\n format.json { head :no_content }\n end\n end",
"def update\n @whylearn = Whylearn.find(params[:id])\n\n respond_to do |format|\n if @whylearn.update_attributes(params[:whylearn])\n format.html { redirect_to(@whylearn, :notice => 'Whylearn was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @whylearn.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @theme = TemplateTheme.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @theme }\n end\n end",
"def destroy\n @wtheme = Wtheme.find(params[:id])\n @wtheme.destroy\n\n respond_to do |format|\n format.html { redirect_to wthemes_url }\n format.json { head :no_content }\n end\n end",
"def update\n @archetype = Archetype.find(params[:id])\n\n respond_to do |format|\n if @archetype.update_attributes(params[:archetype])\n format.html { redirect_to @archetype, notice: 'Archetype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @archetype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @schema = Schema.find(params[:id])\n\n respond_to do |format|\n if @schema.update_attributes(params[:schema])\n format.html { redirect_to @schema, notice: 'Schema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schema.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @metabolite = Metabolite.find(params[:id])\n\n respond_to do |format|\n if @metabolite.update_attributes(params[:metabolite])\n flash[:notice] = 'Metabolite was successfully updated.'\n format.html { redirect_to(@metabolite) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @metabolite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @theme = current_group.themes.find(params[:id])\n @theme.destroy\n respond_to do |format|\n format.html { redirect_to(themes_url) }\n format.json { head :ok }\n end\n end",
"def update\n\n Stylesheet.update_all(:active => \"0\")\n\n @stylesheet = Stylesheet.find(params[:id]) \n @stylesheet.update_attributes(:active => \"1\")\n redirect_to stylesheets_path, :notice => 'Template modified!'\n\n end",
"def update\n @schema = Schema.find(params[:id])\n\n respond_to do |format|\n if @schema.update_attributes(params[:schema])\n format.html { redirect_to @schema, :notice => 'Schema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @schema.errors, :status => :unprocessable_entity }\n end\n end\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 trash_theme\n @theme = Theme.find(params[:id])\n @theme.destroy\n\n render :text => \"success\"\n end",
"def new\n @theme = Theme.new\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render :json => @theme }\n end\n end",
"def destroy\n @theme.destroy\n # After deletion of the zip file, delete the theme as well.\n # @theme.delete_extract\n\n respond_to do |format|\n format.html { redirect_to themes_url }\n format.json { head :no_content }\n end\n end",
"def replace_skin(skin_id, file: nil, **params)\n client.put do |request|\n request.url \"skins/#{skin_id}\", params\n if file\n request.headers[\"Content-Type\"] = \"application/zip\"\n request.body = File.read(file)\n end\n end\n end",
"def create\n @theme = Theme.new(params[:theme])\n @copy_theme = Theme.find_by_id(params[:copy_theme_id])\n if @copy_theme\n @theme.clone_colors_from(@copy_theme)\n end\n\n respond_to do |format|\n if @theme.save\n flash[:notice] = 'Theme was successfully created.'\n format.html { redirect_to(@theme) }\n format.xml { render :xml => @theme, :status => :created, :location => @theme }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @theme.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @theme_name = ThemeName.new(theme_name_params)\n\n respond_to do |format|\n if @theme_name.save\n format.html { redirect_to admin_theme_edit_path(@theme_name), notice: 'Saved' }\n format.json { render action: 'show', status: :created, location: @theme_name }\n else\n format.html { render action: 'new' }\n format.json { render json: @theme_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_theme_color\n @theme_color = ThemeColor.find(params[:id])\n end",
"def destroy\n @theme = TemplateTheme.find(params[:id])\n @theme.destroy\n \n respond_to do |format|\n format.html { redirect_to(admin_template_themes_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.7322025",
"0.7128681",
"0.7128681",
"0.7128681",
"0.7128341",
"0.6991868",
"0.6907588",
"0.681075",
"0.68104094",
"0.6758635",
"0.6749063",
"0.6746038",
"0.67352057",
"0.6732127",
"0.66134316",
"0.658973",
"0.6568242",
"0.64616096",
"0.6418009",
"0.64179015",
"0.64179015",
"0.6326441",
"0.62812465",
"0.62579167",
"0.6248856",
"0.6211728",
"0.61752254",
"0.61663806",
"0.6123922",
"0.59418553",
"0.59414226",
"0.59390795",
"0.5926545",
"0.5904341",
"0.588064",
"0.5815995",
"0.5784393",
"0.57798135",
"0.5756425",
"0.5707093",
"0.57070136",
"0.568903",
"0.5687507",
"0.5675477",
"0.5666942",
"0.56541526",
"0.5638438",
"0.56254005",
"0.5620226",
"0.5613272",
"0.5606414",
"0.5601741",
"0.55966365",
"0.5578108",
"0.5577696",
"0.5577696",
"0.5572901",
"0.5559627",
"0.55419534",
"0.5538188",
"0.5534647",
"0.5524559",
"0.55213773",
"0.55159956",
"0.5491468",
"0.54901505",
"0.5483908",
"0.5483908",
"0.5467361",
"0.54559165",
"0.54422617",
"0.54384905",
"0.5430491",
"0.5428652",
"0.54266214",
"0.54251254",
"0.54129755",
"0.53977096",
"0.5385469",
"0.53847086",
"0.53840196",
"0.5382443",
"0.53823453",
"0.53629607",
"0.53518116",
"0.5337642",
"0.5328169",
"0.5326192",
"0.5324829",
"0.5319774",
"0.5311684",
"0.53014493",
"0.529833",
"0.5287884",
"0.5287659",
"0.52699083",
"0.52584636",
"0.52567697",
"0.525521",
"0.5254142"
] | 0.5577075 | 56 |
params method to prevent weird injections from frontend. Only allow parameters required for model initialization. | def product_params
params.permit(:name, :product_id, :price, :category_id, :about, :thumbnail_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize( params )\n super( Parametrization.permit( params, whitelist, model_name ) )\n @params = @params.with_indifferent_access # After building the internal params hash, make it a little friendlier.\n end",
"def valid_params?; end",
"def params\n raise NotImplementedError\n end",
"def valid_params_request?; end",
"def _params\n # params.require(:model).permit(:model:classname, :schema, :tablename, :name)\n params.require(:model).permit(:classname, :schema, :tablename, :name, :default_sort_field)\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 initialize\n @params = {} # Mimics params hash available within controllers in rails app\n end",
"def params=(_); end",
"def some_thing_params\n params.require(:some_thing).permit(:val)\n end",
"def check_params; true; end",
"def params\n @params ||= { }\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 model_params\n mn = @model.model_name.singular.to_sym\n # {user: {name: \"something\", other_column_name: \"somevalue\"}}\n return {} if params[mn].blank? # to allow create for empty items\n\n # params.require(:table_name).permit(:column_name1, :column_name2, etc., array_type: [], array_type2: [])\n params.require(mn).permit(permitted_columns)\n end",
"def unsolved_params\n \n end",
"def params\n @params ||= {}\n end",
"def params\n @params ||= {}\n end",
"def initialize params = nil\n \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 params\n {}\n end",
"def user_params\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\nend",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def params!(params)\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def create_params\n raise(\"missing create_params stub!\")\n end",
"def initialize(params)\n @params = params \n end",
"def user_params\r\n end",
"def obj_params\n params.require(:data).require(:attributes)\n end",
"def params\n @params ||= {}\n end",
"def params\n @params ||= {}\n end",
"def validate_params(params)\n # This will be implemented by Validators which take parameters\n end",
"def params\n @_params ||= ActionController::ManagebleParameters.new(request.parameters)\n end",
"def initialize\n @params = {}\n end",
"def mandatory_params\n return {}\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def initialize(params = {}, required_keys = nil)\n super\n end",
"def initialize(params = {}, required_keys = nil)\n super\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def initialize(params)\n @params = normalize(params)\n end",
"def get_params\r\n #params.require(:widget).permit(:name)\r\n params.require(:widget).permit!\r\n end",
"def initialize\n super()\n @params = {}\n end",
"def request_params; end",
"def check_params\n true\n end",
"def params(*); {}; end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def like_params\n params.require(:real_estate)\n end",
"def set_params(params)\n @params = params\n end",
"def params=(_arg0); end",
"def params=(_arg0); end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def validate_params_present!\n raise ArgumentError, \"Please provide one or more of: #{ACCEPTED_PARAMS}\" if params.blank?\n end",
"def initialize(params)\n @params = params\n end",
"def initialize(params)\n @params = params\n end",
"def kladr_params\n params.require(:str) #address from user\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 user_params #este metodo SE PUEDE LLAMAR COMO QUIERAS, pero es necesario para que al crear un objeto se autorice su creacion (porque si no nos podrían meter codigo malicioso)\n\t\tparams.require(:user).permit(:name, :email, :password)\n\tend",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def thing_params\n @params ||= thing.new.attributes.keys.map(&:to_sym)\n params.require(thing.name.underscore.to_sym).permit(\n @params,\n :page\n )\n end",
"def all_params; end",
"def params\n {}\n end",
"def yogurt_params\n ActiveModelSerializers::Deserialization\n .jsonapi_parse(\n params, only: [\n :name\n ]\n )\n end",
"def init_params(params)\n @client_id = params[:client_id]\n\n @edit_kyc_id = params[:edit_kyc_id]\n\n @user_extended_detail_id = params[:user_extended_detail_id]\n\n @user_kyc_detail_id = params[:user_kyc_detail_id]\n\n @admin_email = params[:admin_email]\n\n @user_id = params[:user_id]\n\n @client = Client.get_from_memcache(@client_id)\n end",
"def params\n @params ||= self.class.params.dup\n end",
"def query_params; 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 resource_params\n params.require(model_name.underscore.intern).permit(*@model.column_names.map(&:intern))\n end",
"def query_params\n raise(\"missing query_params stub!\")\n end",
"def filter_model_params(model_module, params)\n params\n end",
"def initialize(params = {})\n @params = params.symbolize_keys\n end",
"def params\n _params\n end",
"def quote_params\n params.permit!\n end",
"def resource_params\n @resource_params ||= current_model_service.permit params\n end",
"def <%= singular_name %>_params\n params.require(:<%= singular_name %>).permit(<%= attributes_allowed %>)\n end",
"def query_params=(_arg0); end",
"def quote_params(params); end",
"def permitted_params(action, kind=nil)\n params.require(model_name).permit!\n end",
"def room_params\n permited = [:title,\n :description,\n :price,\n :lat,\n :lng,\n :zone_id,\n :category_id,\n :address,\n :currency,\n :phones,\n :services,\n photos: []]\n if params[:usealt] == true || params[:usealt] == \"true\"\n # When use alt don't require an json structured payload\n params.permit(permited)\n else\n params.require(:room).permit(permited)\n end\n end",
"def request_params(params = {})\n params\n end",
"def preco_rotum_params\n params.permit()\n end",
"def init_params(params)\n @client_id = params[:client_id]\n @user_id = params[:user_id]\n @action = params[:action]\n @action_timestamp = params[:action_timestamp]\n\n @admin_id = params[:admin_id]\n @case_id = params[:case_id]\n # NOTE: Called from two places, one time it's hash with indifferent access and another is normal hash\n # so following line is required and can't be changed. Talk to Sunil, before you touch it.\n @extra_data = params[:extra_data].present? ? params[:extra_data].deep_symbolize_keys : nil\n\n @client = Client.get_from_memcache(@client_id)\n @e_extra_data = nil\n end",
"def initialize(params = {})\n parameters(params)\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 intakes_controller_params\n ActionController::Parameters.new(\n rating_issue_reference_id: contestable_issue&.rating_issue_reference_id,\n rating_issue_diagnostic_code: contestable_issue&.rating_issue_diagnostic_code,\n rating_decision_reference_id: contestable_issue&.rating_decision_reference_id,\n decision_text: contestable_issue&.description,\n is_unidentified: unidentified?,\n decision_date: contestable_issue&.approx_decision_date,\n benefit_type: @benefit_type,\n ramp_claim_id: contestable_issue&.ramp_claim_id,\n contested_decision_issue_id: contestable_issue&.decision_issue&.id\n )\n end"
] | [
"0.7256675",
"0.70451313",
"0.7026993",
"0.69838357",
"0.6812983",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.680973",
"0.67843777",
"0.67474836",
"0.67143756",
"0.67107797",
"0.6699526",
"0.6697503",
"0.66785425",
"0.66221225",
"0.6603822",
"0.6603822",
"0.66018295",
"0.659428",
"0.6583747",
"0.65787214",
"0.65786177",
"0.65369976",
"0.65282637",
"0.65246814",
"0.65156347",
"0.65030515",
"0.6486026",
"0.64844465",
"0.64803916",
"0.6479575",
"0.6479575",
"0.64520234",
"0.6429207",
"0.6424691",
"0.64177436",
"0.64063704",
"0.64063686",
"0.64063686",
"0.64016443",
"0.6390329",
"0.6389795",
"0.63765687",
"0.6369979",
"0.63645095",
"0.6363714",
"0.6353614",
"0.635273",
"0.63422596",
"0.6340486",
"0.63320535",
"0.63320535",
"0.6327409",
"0.63245714",
"0.6317596",
"0.6317596",
"0.63025886",
"0.6300167",
"0.6300089",
"0.62841797",
"0.62822604",
"0.6277201",
"0.62765014",
"0.6265643",
"0.6265594",
"0.62593997",
"0.6254454",
"0.62513787",
"0.6249896",
"0.6246645",
"0.6246255",
"0.6243208",
"0.62339664",
"0.6233839",
"0.6230847",
"0.6229677",
"0.6221272",
"0.6213999",
"0.62114155",
"0.6209796",
"0.62070316",
"0.6206332",
"0.62007046",
"0.6199081",
"0.6187798",
"0.61863387"
] | 0.0 | -1 |
Creates a new logical connection to the server. | def initialize(options = {})
@options = DEFAULT_OPTIONS.merge(options)
parse_domain_name
REQUIRED_OPTIONS.each { |key| raise "No #{key} specified" unless @options.key?(key) }
@password = @options.delete(:password)
@session_id = @options[:session_id]
@api_path = @options[:path]
@ca_certs = @options[:ca_certs]
# The temporary file to store the CA certificates will be created when needed:
@ca_file = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect\n @connection.create\n end",
"def new_connection; end",
"def create_tcp_connection(temp: false)\n tcp_connection = Rex::Socket::Tcp.create(\n 'PeerHost' => host,\n 'PeerPort' => port.to_i,\n 'Context' => context,\n 'Timeout' => timeout\n )\n self.connection = tcp_connection unless temp\n tcp_connection\n end",
"def connect(t = -1)\n # If we already have a connection and we aren't pipelining, close it.\n if (self.conn)\n if !pipelining?\n close\n else\n return self.conn\n end\n end\n\n timeout = (t.nil? or t == -1) ? 0 : t\n\n self.conn = Rex::Socket::Tcp.create(\n 'PeerHost' => self.hostname,\n 'PeerPort' => self.port.to_i,\n 'LocalHost' => self.local_host,\n 'LocalPort' => self.local_port,\n 'Context' => self.context,\n 'SSL' => self.ssl,\n 'SSLVersion' => self.ssl_version,\n 'Proxies' => self.proxies,\n 'Timeout' => timeout\n )\n end",
"def connect\n Connection.new\n end",
"def create_connection\n self.setup\n RfmAdaptor::Connection.new(self.server_name)\n end",
"def connect_to_server\n fail \"connect_server called without remote established\" if @remote.nil?\n host, port = @remote\n LOGGER.info \"Establishing new connection with #{host}:#{port}\"\n @server_side = ServerConnection.request(host, port, self)\n @server_side.pending_connect_timeout = @connect_timeout\n @server_side.comm_inactivity_timeout = @inactivity_timeout\n end",
"def connect!\n @connection = Connection::Factory.create(@options[:transport], @options[:transport_wrapper], @current_server, @options[:timeout])\n @connection.connect!\n @client = @client_class.new(@options[:protocol].new(@connection.transport, *@options[:protocol_extra_params]))\n rescue Thrift::TransportException, Errno::ECONNREFUSED => e\n @transport.close rescue nil\n raise e\n end",
"def connection\n @connection = create_connection! unless connected?\n @connection\n end",
"def create_socket\n socket = ::Socket.new(::Socket::AF_INET, ::Socket::SOCK_STREAM, 0)\n sockaddr = ::Socket.sockaddr_in(PORTS.sample, self.hostname)\n begin # emulate blocking connect\n socket.connect_nonblock(sockaddr)\n rescue IO::WaitWritable\n IO.select(nil, [socket]) # wait 3-way handshake completion\n begin\n socket.connect_nonblock(sockaddr) # check connection failure\n rescue Errno::EISCONN\n end\n end\n socket\n end",
"def create_socket\n if @uri.scheme == 'wss'\n create_ssl_socket.tap(&:connect)\n else\n TCPSocket.new(@uri.host, @port)\n end\n end",
"def spawn_connection\n connect\n end",
"def create_new_connection(options, &block)\n if defined?(@connection)\n logger.debug(\"[SSH] shutting previous connection #{@connection}\")\n @connection.close\n end\n\n @connection_options = options\n conn = Connection.new(options, &block)\n\n # Cisco IOS requires a special implementation of `Net:SSH`. This uses the\n # SSH transport to identify the platform, but then replaces SSHConnection\n # with a CiscoIOSConnection in order to behave as expected for the user.\n if defined?(conn.platform.cisco_ios?) && conn.platform.cisco_ios?\n ios_options = {}\n ios_options[:host] = @options[:host]\n ios_options[:user] = @options[:user]\n # The enable password is used to elevate privileges on Cisco devices\n # We will also support the sudo password field for the same purpose\n # for the interim. # TODO\n ios_options[:enable_password] = @options[:enable_password] || @options[:sudo_password]\n ios_options[:logger] = @options[:logger]\n ios_options.merge!(@connection_options)\n conn = CiscoIOSConnection.new(ios_options)\n end\n\n @connection = conn unless conn.nil?\n end",
"def create_new_persistent_connection\n app_name = if @data[:options][:connection_ca_file] ||\n @data[:credentials][:cert] ||\n @data[:credentials][:key]\n 'right_cloud_api_gem_%s' % Utils::generate_token\n else\n 'right_cloud_api_gem'\n end\n connection = Net::HTTP::Persistent.new(app_name)\n set_persistent_connection_options!(connection)\n # Register a callback to close current connection\n @data[:callbacks][:close_current_connection] = Proc::new do |reason|\n connection.shutdown\n log \"Current connection closed: #{reason}\"\n end\n connection\n end",
"def create_new_connection(options, &block)\n cleanup!\n @connection_options = options\n @connection = Kitchen::Transport::Ssh::Connection.new(options, &block)\n end",
"def open_connection\n @connection = TCPSocket.new(server, port)\n @context = OpenSSL::SSL::SSLContext.new\n @context.cert = @cert\n @context.key = @key\n\n @socket = OpenSSL::SSL::SSLSocket.new(@connection, @context) if @connection\n @socket.sync_close = true\n @socket.connect\n\n get_frame\n end",
"def establish_connection(options={})\n\t\tconnection.ensure_tunnel(options)\n\tend",
"def connect_to_server\n @socket = TCPSocket.open(@serverip, @serverport)\n end",
"def create_new_connection(options, &block)\n if @connection\n logger.debug(\"[WinRM] shutting previous connection #{@connection}\")\n @connection.close\n end\n\n @connection_options = options\n @connection = Kitchen::Transport::Winrm::Connection.new(options, &block)\n end",
"def open_connection\n @connection = TCPSocket.new(@server, @port)\n @socket = OpenSSL::SSL::SSLSocket.new(@connection)\n \n # Synchronously close the connection & socket\n @socket.sync_close\n \n # Connect\n @socket.connect\n \n # Get the initial frame\n get_frame\n end",
"def make_new(server)\n if (n = created_count(server)) >= @max_size\n allocated(server).to_a.each{|t, c| release(t, c, server) unless t.alive?}\n n = nil\n end\n if (n || created_count(server)) < @max_size\n raise(Sequel::Error, \"No connection proc specified\") unless @connection_proc\n begin\n conn = @connection_proc.call(server)\n rescue Exception=>exception\n raise Sequel.convert_exception_class(exception, Sequel::DatabaseConnectionError)\n end\n raise(Sequel::DatabaseConnectionError, \"Connection parameters not valid\") unless conn\n conn\n end\n end",
"def create\n conn = EM::Hiredis::Client.new(@host, @port, @password, @database)\n conn.connect\n conn\n end",
"def open_connection\n # FIXME il timeout serve solamente nella versione tcp\n # FIXME perchè utilizzare un'istanza di classe? non sarebbe meglio avere un metodo che genera il transport\n # e successivamente viene utilizzato sempre quello?\n Timeout.timeout @timeout do\n case @transport\n when :tcp\n @connection = KonoEppClient::Transport::TcpTransport.new(server, port)\n when :http\n @connection = KonoEppClient::Transport::HttpTransport.new(server, port,\n ssl_version: ssl_version,\n cookie_file: \"#{@tag.downcase}.cookies.pstore\"\n )\n end\n end\n end",
"def establish_connection\n if @socket.nil?\n @socket = TCPSocket.new(@host, @port)\n end\n end",
"def establish_connection\n if @socket.nil?\n @socket = TCPSocket.new(@host, @port)\n end\n end",
"def connect(temp: false)\n return connection if connection && !temp\n return create_tcp_connection(temp: temp)\n end",
"def init\n # Open a socket for the server to connect on.\n @sock = TCPSocket.new(@address , @server.port)\n @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)\n @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, false)\n unless RUBY_PLATFORM =~ /win32/\n @sock.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK)\n end\n c = Connection.new(@server, @sock)\n if c.init\n log.info \"(#{c.object_id}) Connection made.\"\n publish(c)\n true\n else\n false\n end\n rescue Exception\n log.error \"Connector#init\"\n log.error $!\n false\n end",
"def connect()\n @sock = TCPSocket.open(@server, @port)\n end",
"def new(*args)\n my = self.init\n my.connect(*args)\n end",
"def connect\n @comm.connect(opts.user, opts.password, opts.server)\n end",
"def new_connection(params)\n Pod4.logger.info(__FILE__){ \"Connecting to DB\" }\n client = TinyTds::Client.new(params)\n raise \"Bad Connection\" unless client.active?\n\n client.execute(\"use [#{self.class.db}]\").do\n\n client\n\n rescue => e\n handle_error(e)\n end",
"def establish_connection\n LOG.debug self.inspect\n LOG.debug \"establish_connection:\"\n LOG.debug([@config['CONNECTION_HOST'], @config['CONNECTION_PORT']].inspect)\n @socket = TCPSocket.new(@config['CONNECTION_HOST'], @config['CONNECTION_PORT']) # The port should be an arg.\n handshake_data_hash = {:ident => @config['IDENT'], :pid => Process.pid}\n @socket.write_object(handshake_data_hash)\n end",
"def connect\r\n if @opts[:threadsafe]\r\n @conns = Knj::Threadhandler.new\r\n \r\n @conns.on_spawn_new do\r\n self.spawn\r\n end\r\n \r\n @conns.on_inactive do |data|\r\n data[:obj].close\r\n end\r\n \r\n @conns.on_activate do |data|\r\n data[:obj].reconnect\r\n end\r\n else\r\n @conn = self.spawn\r\n end\r\n end",
"def connect(server)\n Connection.new(self, server, server_opts(server))\n end",
"def create_new_connection(options, &block)\n if @connection\n logger.debug(\"[Dokken] shutting previous connection #{@connection}\")\n @connection.close\n end\n\n @connection = Kitchen::Transport::Dokken::Connection.new(options, &block)\n end",
"def create_connection(body)\n raise Auth0::InvalidParameter, 'Must specify a body to create a connection' if body.to_s.empty?\n request_params = body\n post(connections_path, request_params)\n end",
"def make_conn(conn)\n conn.h_conn = @dbm.make_conn(conn.spec)\n end",
"def initialize(connection_to_socket, args = {})\n @connection = connection_to_socket\n @user = args[:user]\n @password = args[:password]\n\n srv = connection.protocol::Connect.new(\n protocol: 19,\n user: args[:user],\n password: args[:password]\n ).process(connection)\n\n @session = srv[:session] || OrientdbBinary::OperationTypes::NEW_SESSION\n end",
"def create_client_connection(host, port, db)\n Connection.new(host, port, db, @handle)\n end",
"def make_conn(spec)\n case @handling_mode\n when :cache\n cache_connect(spec)\n when :pool\n # not yet implemented\n nil\n else\n nil\n end\n end",
"def open_connection\n # DataObjects::Connection.new(uri) will give you back the right\n # driver based on the DataObjects::URI#scheme\n connection = connection_stack.last || DataObjects::Connection.new(normalized_uri)\n connection_stack << connection\n connection\n end",
"def create_server_socket\n if @hostname\n s = TCPServer.open(@hostname, @port)\n else\n s = TCPServer.open(@port)\n end\n @port = s.addr[1]\n\n s.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)\n\n return s\n end",
"def create(param)\n\t\tsock = nil\n\n\t\t# Notify handlers before we create the socket\n\t\tnotify_before_socket_create(self, param)\n\n\t\tsock = net.socket.create(param)\n\n\t\t# sf: unsure if we should raise an exception or just return nil. returning nil for now.\n\t\t#if( sock == nil )\n\t\t# raise Rex::UnsupportedProtocol.new(param.proto), caller\n\t\t#end\n\n\t\t# Notify now that we've created the socket\n\t\tnotify_socket_created(self, sock, param)\n\n\t\t# Return the socket to the caller\n\t\tsock\n\tend",
"def create_connection(name, connection)\n repo.add(name, connection)\n write \"Loaded a new round called #{name}.\"\n save!\n end",
"def connection\n Connection.new(conn_spec)\n end",
"def create_server\n raise NotImplementedError, \"Implement #{__callee__} in #{self.class.to_s}\"\n end",
"def establish_socket_server\n @socket_server = Uninterruptible::Binder.new(server_configuration.bind).bind_to_socket\n\n if server_configuration.tls_enabled?\n @socket_server = Uninterruptible::TLSServerFactory.new(server_configuration).wrap_with_tls(@socket_server)\n end\n @socket_server\n end",
"def create_server\n\n end",
"def connect()\n @s = @s || TCPsocket.open(@host, @port)\n end",
"def connect\n @connection.open\n end",
"def create_server\n\t\treturn Hglib::Server.new( self.path.to_s )\n\tend",
"def connection\n Connection.new(conn_spec)\n end",
"def connect(server)\n opts = server_opts(server)\n Connection.new(self, opts)\n end",
"def create_server(connection, name, options={})\n raise \"Need to extend create_server method!\"\n end",
"def create(param)\n\t\tsock = nil\n\n\t\t# Notify handlers before we create the socket\n\t\tnotify_before_socket_create(self, param)\n\n\t\tcase param.proto\n\t\t\twhen 'tcp'\n\t\t\t\tsock = net.socket.create(param)\n\t\t\telse\n\t\t\t\traise Rex::UnsupportedProtocol.new(param.proto), caller\n\t\tend\n\n\t\t# Notify now that we've created the socket\n\t\tnotify_socket_created(self, sock, param)\n\n\t\t# Return the socket to the caller\n\t\tsock\n\tend",
"def create_openstack_connection\n Ankus::Openstack.new @credentials[:os_auth_url], @credentials[:os_username], @credentials[:os_password], @credentials[:os_tenant], @log, @mock\n end",
"def open(host, port, connection_options)\n socket = Socket.tcp(proxy_host, proxy_port, nil, nil,\n connect_timeout: connection_options[:timeout])\n ip_addr = IPAddr.new(Resolv.getaddress(host))\n\n packet = [VERSION, CONNECT, port.to_i, ip_addr.to_i, options[:user]].pack(\"CCnNZ*\")\n socket.send packet, 0\n\n version, status, port, ip = socket.recv(8).unpack(\"CCnN\")\n if status != GRANTED\n socket.close\n raise ConnectError, \"error connecting to proxy (#{status})\"\n end\n\n return socket\n end",
"def connect\n connection.tap do |c|\n c.start\n end\n end",
"def connect\n @connection = Net::HTTP.new(@params[:server], @params[:port])\n @connection.use_ssl = true if @params[:scheme] == 'https'\n @connection.start\n end",
"def connect_to_master # :nodoc:\n return unless @master_uri\n\n tcp_server = DRb.start_service\n\n master = DRb::DRbObject.new_with_uri @master_uri\n\n c = DRb::Worm::Connection.new\n c.ca = master.ca\n\n DRb.primary_server = c.start_service\n\n DRb.remove_server tcp_server\n\n tcp_server.stop_service\n\n DRb.primary_server\n end",
"def process_create_connection(connection_id)\n if @connections[connection_id]\n E \"asked to create already open connection #{connection_id}\"\n return\n end\n \n D \"Tunnel #{connection_id} to #{@tunnel_to_host} port #{@tunnel_to_port}\"\n connection = EventMachine.connect(@tunnel_to_host, @tunnel_to_port,\n Client::TunnelConnection, connection_id, @client)\n @connections[connection_id] = connection\n end",
"def create_connection(model)\n credentials = [@options[:socket] || @options.values_at(:host, :port)]\n Rufus::Tokyo::TyrantTable.new(*credentials.flatten)\n end",
"def make_connection\n Rightscale::HttpConnection.new(:user_agent => \"RightLink v#{AgentConfig.protocol_version}\",\n :logger => @logger,\n :proxy_host => @proxy.host,\n :proxy_port => @proxy.port,\n :proxy_username => @proxy.user,\n :proxy_password => @proxy.password,\n :exception => ReposeConnectionFailure,\n :fail_if_ca_mismatch => true,\n :ca_file => get_ca_file)\n end",
"def connect\n TCPSocket.open(@host, @port)\n end",
"def new_connection(relation_name, other_object, bidi)\n return Relation.create(relation_name, self.node, other_object.node, bidi)\n end",
"def connection\n @connection ||= make_connection\n end",
"def create_connect_port(new_name, new_lhs, new_rhs)\n p = Port.new(new_name, direction: direction, \n lhs: new_lhs , rhs: new_rhs, type: type,\n packed: \"\", unpacked: \"\")\n end",
"def connect\n @connector.connect\n @p.set_connection @connector\n end",
"def new_connection(config)\n username = nil\n\n if config[:jndi]\n jndi = config[:jndi].to_s\n ctx = javax.naming.InitialContext.new\n ds = nil\n\n # tomcat needs first lookup method, oc4j (and maybe other application servers) need second method\n begin\n env = ctx.lookup(\"java:/comp/env\")\n ds = env.lookup(jndi)\n rescue\n ds = ctx.lookup(jndi)\n end\n\n # check if datasource supports pooled connections, otherwise use default\n if ds.respond_to?(:pooled_connection)\n @raw_connection = ds.pooled_connection\n else\n @raw_connection = ds.connection\n end\n\n # get Oracle JDBC connection when using DBCP in Tomcat or jBoss\n if @raw_connection.respond_to?(:getInnermostDelegate)\n @pooled_connection = @raw_connection\n @raw_connection = @raw_connection.innermost_delegate\n elsif @raw_connection.respond_to?(:getUnderlyingConnection)\n @pooled_connection = @raw_connection\n @raw_connection = @raw_connection.underlying_connection\n end\n\n # Workaround FrozenError (can't modify frozen Hash):\n config = config.dup\n config[:driver] ||= @raw_connection.meta_data.connection.java_class.name\n username = @raw_connection.meta_data.user_name\n else\n # to_s needed if username, password or database is specified as number in database.yml file\n username = config[:username] && config[:username].to_s\n password = config[:password] && config[:password].to_s\n database = config[:database] && config[:database].to_s || \"XE\"\n host, port = config[:host], config[:port]\n privilege = config[:privilege] && config[:privilege].to_s\n\n # connection using TNS alias, or connection-string from DATABASE_URL\n using_tns_alias = !host && !config[:url] && ENV[\"TNS_ADMIN\"]\n if database && (using_tns_alias || host == \"connection-string\")\n url = \"jdbc:oracle:thin:@#{database}\"\n else\n unless database.match?(/^(:|\\/)/)\n # assume database is a SID if no colon or slash are supplied (backward-compatibility)\n database = \"/#{database}\"\n end\n url = config[:url] || \"jdbc:oracle:thin:@//#{host || 'localhost'}:#{port || 1521}#{database}\"\n end\n\n prefetch_rows = config[:prefetch_rows] || 100\n # get session time_zone from configuration or from TZ environment variable\n time_zone = config[:time_zone] || ENV[\"TZ\"] || java.util.TimeZone.default.getID\n\n properties = java.util.Properties.new\n raise \"username not set\" unless username\n raise \"password not set\" unless password\n properties.put(\"user\", username)\n properties.put(\"password\", password)\n properties.put(\"defaultRowPrefetch\", \"#{prefetch_rows}\") if prefetch_rows\n properties.put(\"internal_logon\", privilege) if privilege\n\n if config[:jdbc_connect_properties] # arbitrary additional properties for JDBC connection\n raise \"jdbc_connect_properties should contain an associative array / hash\" unless config[:jdbc_connect_properties].is_a? Hash\n config[:jdbc_connect_properties].each do |key, value|\n properties.put(key, value)\n end\n end\n\n begin\n @raw_connection = java.sql.DriverManager.getConnection(url, properties)\n rescue\n # bypass DriverManager to work in cases where ojdbc*.jar\n # is added to the load path at runtime and not on the\n # system classpath\n @raw_connection = ORACLE_DRIVER.connect(url, properties)\n end\n\n # Set session time zone to current time zone\n if ActiveRecord.default_timezone == :local\n @raw_connection.setSessionTimeZone(time_zone)\n elsif ActiveRecord.default_timezone == :utc\n @raw_connection.setSessionTimeZone(\"UTC\")\n end\n\n if config[:jdbc_statement_cache_size]\n raise \"Integer value expected for :jdbc_statement_cache_size\" unless config[:jdbc_statement_cache_size].instance_of? Integer\n @raw_connection.setImplicitCachingEnabled(true)\n @raw_connection.setStatementCacheSize(config[:jdbc_statement_cache_size])\n end\n\n # Set default number of rows to prefetch\n # @raw_connection.setDefaultRowPrefetch(prefetch_rows) if prefetch_rows\n end\n\n cursor_sharing = config[:cursor_sharing] || \"force\"\n exec \"alter session set cursor_sharing = #{cursor_sharing}\" if cursor_sharing\n\n # Initialize NLS parameters\n OracleEnhancedAdapter::DEFAULT_NLS_PARAMETERS.each do |key, default_value|\n value = config[key] || ENV[key.to_s.upcase] || default_value\n if value\n exec \"alter session set #{key} = '#{value}'\"\n end\n end\n\n OracleEnhancedAdapter::FIXED_NLS_PARAMETERS.each do |key, value|\n exec \"alter session set #{key} = '#{value}'\"\n end\n\n self.autocommit = true\n\n schema = config[:schema] && config[:schema].to_s\n if schema.blank?\n # default schema owner\n @owner = username.upcase unless username.nil?\n else\n exec \"alter session set current_schema = #{schema}\"\n @owner = schema\n end\n\n @raw_connection\n end",
"def open(host, port, connection_options)\n socket = establish_connection(connection_options[:timeout])\n socket.write \"CONNECT #{host}:#{port} HTTP/1.1\\r\\n\"\n socket.write \"Host: #{host}:#{port}\\r\\n\"\n\n if options[:user]\n credentials = [\"#{options[:user]}:#{options[:password]}\"].pack(\"m*\").gsub(/\\s/, \"\")\n socket.write \"Proxy-Authorization: Basic #{credentials}\\r\\n\"\n end\n\n socket.write \"\\r\\n\"\n\n resp = parse_response(socket)\n\n return socket if resp[:code] == 200\n\n socket.close\n raise ConnectError, resp.inspect\n end",
"def init_socket\n @rcon_socket = RCONSocket.new @ip_address, @port\n @socket = SourceSocket.new @ip_address, @port\n end",
"def initialize\n # we create this particular socket connection just to keep it open\n @soc = dtnsoc\n end",
"def connect!\n host, port = @current_server.split(\":\")\n @socket = TCPSocket.new(host, port)\n @transport = Avro::IPC::SocketTransport.new(@socket)\n @requestor = Avro::IPC::Requestor.new(@options[:protocol], @transport)\n rescue Avro::AvroError, Errno::ECONNREFUSED, Errno::EPIPE, IOError => e\n @transport.close rescue nil\n raise e\n end",
"def socket_setup()\n ctx = { 'Msf' => self.options['Msf'], 'MsfExploit' => self.options['MsfExploit'] }\n self.socket = case self.handle.protocol\n\n when 'ncacn_ip_tcp'\n Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => self.handle.options[0],\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n\n when 'ncacn_np'\n begin\n socket = Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => 445,\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n rescue ::Timeout::Error, Rex::ConnectionRefused\n socket = Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => 139,\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n end\n socket\n else nil\n end\n\n # Add this socket to the exploit's list of open sockets\n options['MsfExploit'].add_socket(self.socket) if (options['MsfExploit'])\n end",
"def connect(options = {})\n conn = self.connection(options[:handler])\n conn.container = self.container_id || generate_uuid\n connector = Connector.new(conn)\n conn.overrides = connector\n if !options[:url].nil?\n connector.address = URLs.new([options[:url]])\n elsif !options[:urls].nil?\n connector.address = URLs.new(options[:urls])\n elsif !options[:address].nil?\n connector.address = URLs.new([Qpid::Proton::URL.new(options[:address])])\n else\n raise ::ArgumentError.new(\"either :url or :urls or :address required\")\n end\n\n connector.heartbeat = options[:heartbeat] if !options[:heartbeat].nil?\n if !options[:reconnect].nil?\n connector.reconnect = options[:reconnect]\n else\n connector.reconnect = Backoff.new()\n end\n\n connector.ssl_domain = SessionPerConnection.new # TODO seems this should be configurable\n\n conn.open\n\n return conn\n end",
"def initialize_connection(conn)\n conn.comm_inactivity_timeout = config.timeout.to_i\n conn.start_tls(config.ssl ? config.ssl.serializable_hash : {}) if ssl?\n # Create a new request\n req = new_request(conn)\n # Connected event\n connect!(req, conn)\n end",
"def open_socket\n @socket = Socket.new(:INET, :DGRAM)\n @socket.connect_nonblock Socket.sockaddr_in(@port, @host)\n end",
"def connect\n @connection_pool.get_connection\n end",
"def establish_connection_with_server\n\t $game_client = GameClient.new\n $scene = Scene_Pong_Client.new\n end",
"def open\n return if @connected\n\n socket = Thrift::Socket.new(@host, @port)\n\n @transport = Thrift::BufferedTransport.new(socket)\n @transport.open\n\n proto = Thrift::BinaryProtocol.new(@transport)\n @service = Protocol::ImpalaService::Client.new(proto)\n @connected = true\n end",
"def connect(*) end",
"def connection\n @connection ||= build_connection\n end",
"def create_ssl_socket\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.set_params ssl_version: :TLSv1_2\n\n socket = TCPSocket.new(@uri.host, @port)\n OpenSSL::SSL::SSLSocket.new(socket, ctx)\n end",
"def connect\n connection = Bunny.new(connection_attributes.\n merge(:pass => connection_attributes[:password]))\n connection.start\n \n # NOTE: This is a super undocumented feature that you will probably know\n # about only from reading AMQP specs. If we want to subscribe, but abort\n # subscription before all messages are read, we need to turn this on,\n # otherwise the server will go on and deliver all remaining messages in\n # turn. See also the :ack => true flag in ServerTransport... 23Dez09, ksc\n connection.qos\n\n connection\n end",
"def connect\n @connection_manager.connect\n return self\n end",
"def establish_connection\n end",
"def connection_for_entity_type(_entity_type)\n connection_manager.connect(tower_hostname, tower_user, tower_passwd)\n end",
"def open()\n begin\n @my = Mysql.connect(@host, @user, @pw, @db)\n # Set the MySQL 'reconnect' flag -> Connection to the database will be\n # automatically maintained even if the Server closes it due to timed-out idle period\n @my.reconnect = true\n debug \" - Open Connection to MYSQL server - reconnect=#{@my.reconnect}\"\n @connected = true\n rescue MysqlError => e\n debug \"SQL error message: #{e.error}.\"\n end\n end",
"def create_connection()\n\t\tconnection_properties = java.util.Properties.new\n\t\[email protected] do |k,v|\n\t\t\tconnection_properties[k] = v\n\t\tend\n\t\treturn java.sql.DriverManager.getConnection(\"jdbc:sqlite:#{@file}\",connection_properties)\n\tend",
"def connect\n @connection_manager.connect\n end",
"def connect\n auth = authentication_prompt()\n\n socket = TCPSocket.new( @server, @port )\n raise RuntimeError, \"Unable to connect to #{@port}\" unless socket\n print \"Connecting at #{Time.now} to #{@port} ... \"\n\n authenticate_with_server( socket, auth[:u], auth[:p] )\n\n return socket\n end",
"def create_tcp_server_channel(params)\n\t\t\treturn SocketSubsystem::TcpServerChannel.open(client, params)\n\tend",
"def connect!; end",
"def connect!; end",
"def connect_to_server\n @service.connect(connect_settings)\n end",
"def connect\n connection.connect\n nil\n end",
"def create_connection\n Fog::Compute.new({\n :provider => 'OpenStack',\n :openstack_api_key => @os_password,\n :openstack_username => @os_username,\n :openstack_auth_url => @os_auth_url,\n :openstack_tenant => @os_tenant,\n })\n rescue Excon::Errors::Unauthorized => ex\n @log.error 'Invalid OpenStack Credentials' + ex.message\n @log.error ex.backtrace\n exit 1\n rescue Excon::Errors::BadRequest => ex\n @log.error 'Malformed connection options' + ex.message\n if ex.response.body\n @log.error JSON.parse(ex.response.body)['badRequest']['message']\n end\n @log.error ex.backtrace\n end",
"def create_sesame_con\n @os_conn = EventMachine::HttpRequest.new($open_sesame_url)\n end",
"def establish(spec)\n @rwlock.write {\n @specification = spec\n @connection = spec.new_connection\n __connect\n }\n end",
"def connect!\n @connection = Net::HTTP.new(@server, 80)\n if @ssl\n @connection.use_ssl = true\n @connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n @connection.start\n end",
"def create_socket\n attempt_number = 0\n\n begin\n attempt_number += 1\n socket = zmq_context.socket(::ZMQ::REQ)\n\n if socket # Make sure the context builds the socket\n server_uri = lookup_server_uri\n socket.setsockopt(::ZMQ::LINGER, 0)\n zmq_error_check(socket.connect(server_uri), :socket_connect)\n socket = socket_to_available_server(socket) if first_alive_load_balance?\n end\n end while socket.try(:socket).nil? && attempt_number < socket_creation_attempts\n\n raise RequestTimeout, \"Cannot create new ZMQ client socket\" if socket.try(:socket).nil?\n socket\n end"
] | [
"0.7175921",
"0.66526514",
"0.6577228",
"0.65604943",
"0.65220433",
"0.64861435",
"0.64453906",
"0.6373857",
"0.6297211",
"0.62688094",
"0.62649953",
"0.6263107",
"0.6260199",
"0.62430567",
"0.6232543",
"0.6217174",
"0.6150901",
"0.61492836",
"0.6146864",
"0.6144577",
"0.6128268",
"0.61275613",
"0.61006945",
"0.60866994",
"0.60866994",
"0.6083697",
"0.60832685",
"0.60786766",
"0.6071197",
"0.60662436",
"0.60384315",
"0.6028443",
"0.59997755",
"0.59899706",
"0.59893876",
"0.5986816",
"0.59795904",
"0.59730345",
"0.59688485",
"0.5946738",
"0.5946363",
"0.5940396",
"0.5914939",
"0.58955127",
"0.58954424",
"0.58950764",
"0.58926237",
"0.5889542",
"0.58628637",
"0.5861428",
"0.58600485",
"0.58486426",
"0.5843461",
"0.5840113",
"0.5839136",
"0.5830015",
"0.58220977",
"0.58092976",
"0.57936853",
"0.57875913",
"0.57748634",
"0.5761389",
"0.57595533",
"0.57487494",
"0.5744855",
"0.5744021",
"0.57367134",
"0.57343036",
"0.5733057",
"0.5732909",
"0.5725206",
"0.57035017",
"0.5702391",
"0.5700849",
"0.5697501",
"0.5694292",
"0.56812114",
"0.5675181",
"0.5662709",
"0.56348914",
"0.56320286",
"0.5631577",
"0.5630707",
"0.56286895",
"0.56107616",
"0.5600569",
"0.55874676",
"0.5579129",
"0.5574674",
"0.55723757",
"0.5571844",
"0.55656385",
"0.55643076",
"0.55643076",
"0.5561792",
"0.556172",
"0.55602443",
"0.55538684",
"0.5542546",
"0.55358535",
"0.55293703"
] | 0.0 | -1 |
Checks if the API is available in the given candidate path. It does so sending a request without authentication. If the API is available there it will respond with the "WWWAutenticate" header and with the "RESTAPI" or "ENGINE" realm. | def probe_api_path(uri, path)
uri = URI.join(uri, path)
request = RestClient::Resource.new(uri.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
begin
request.get
rescue RestClient::Exception => exception
response = exception.response
logger.error "#{self.class.name}#probe_api_path: exception probing uri: '#{uri}'. Exception: #{$ERROR_INFO}"
return false if response.nil?
if response.code == 401
www_authenticate = response.headers[:www_authenticate]
if www_authenticate =~ /^Basic realm="?(RESTAPI|ENGINE)"?$/
return true
end
end
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route_api?\n request.get? && path.match(%r{^/api})\n end",
"def check_api_key\n # Return 403 Forbidden if there is no api key in the request headers\n head :forbidden unless self.current_api_key\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 api_available?\n begin\n response = self.api_status\n if response.is_a?(Hash) && response['ok']\n true\n else\n false\n end\n rescue => e\n false\n end\n end",
"def authenticate_client_access!\n return if api_key_from_params.nil?\n\n return require_api_client if access_from_localhost?\n return require_api_client if access_from_preview_hosting? && restricted_api_access_mode?\n return require_api_client if access_from_production_hosting?\n return require_api_client if access_from_public_hosting?\n\n true # Do not halt otherwise\n end",
"def available?\n resp = get do |req|\n req.url '/'\n end\n resp.status == 200\n end",
"def api_authenticate\n unless params[:api_key] == \"oz\" || api_user\n render :json => {:error => \"API key not found\"}, :status => :unauthorized\n end\n end",
"def check_authorization\n return head :unauthorized if request.env['HTTP_CAPKEY'].nil?\n\n head :forbidden unless request.env['HTTP_CAPKEY'] == Settings.API_KEY\n end",
"def api?(req)\n (req.path.start_with?('/api') || req.path.start_with?('/version.json'))\n end",
"def verify_access_with_api_key\n api_key = request.headers[\"HTTP_API_KEY\"] || params[:api_key]\n andrew_id = request.headers[\"HTTP_ANDREW_ID\"] || params[:andrew_id]\n if (api_key.nil? || andrew_id.nil?)\n render json: {error: \"Error, bad request\"}, status: 400\n elsif !(key_matches?(api_key, andrew_id))\n render json: {error: \"Error, unauthorized user or API key\"}, status: 401\n # Inactive users are not allowed to use their keys for any reason.\n elsif !@cur_user.active\n render json: {error: \"Error, the account associated with this andrew ID has been suspended\"}, status: 401\n end\n end",
"def api_request?\n is_api_request = request.path_info =~ /\\// ||\n request.path_info =~ /\\/fonts/ ||\n request.path_info =~ /\\/connect/\n !is_api_request\n end",
"def authenticate_api!\n find_case\n return true if @case&.public? || current_user\n\n render json: { reason: 'Unauthorized!' },\n status: :unauthorized\n end",
"def cannot_access_api?\n !request.env[\"REQUEST_METHOD\"].eql?(\"GET\") &&\n !request.headers['mw-token'].eql?(ENV[\"api_access_token\"])\n end",
"def check_api_access\n current_resource_owner&.can_use_api?\n end",
"def api_auth\n api_response(403, \"Invalid Authorization header\") unless api_user\n end",
"def check_header\n if ['POST', 'PUT', 'PATCH'].include? request.method\n head :not_acceptable and return unless request.content_type == 'application/vnd.api+json'\n end\n end",
"def setup_api\n if white_listed?(path)\n @api = Api.new\n return\n end\n\n email, password = http_basic_auth_info\n\n if !email.blank? and !password.blank?\n user = User.find_by_email(email)\n if user.password == password\n @api = Api.new(user)\n else\n render(:nothing => true, :status => :unauthorized)\n return\n end\n else\n begin\n if current_user\n @api = Api.new(current_user)\n else\n render(:nothing => true, :status => :unauthorized)\n end\n rescue NameError\n @api = Api.new\n end\n end\n end",
"def authenticate\n @apikey = request.headers[:apikey]\n if @apikey==nil || @apikey!= APIKEY\n json_response={\n error: 'autorization error'\n }\n respond_with json_response, location: nil\n end\n end",
"def can_use_api?\n api_enabled\n end",
"def authenticate_api!\n Rails.logger.info(\"Enter Authenticate Api\")\n \n # just to test we are using HTTP_HOST in test mode as HTTP_ORIGIN cant be set\n Rails.env == \"test\" ? origin = request.env['HTTP_HOST'] : origin = request.env['HTTP_ORIGIN']\n\n if !params[\"token\"].blank? and origin.blank? # API Access\n\n account_id = AccountsCache.access_token(params[\"token\"])\n\n raise et(\"application.unauthorized\") if account_id.blank?\n \n # set account_id in params\n if params[:controller] == \"accounts\" and current_account\n params[:id] = current_account._id.to_s if params[:id].blank?\n else\n params[:account_id] = current_account._id.to_s if params[:account_id].blank?\n end\n\n # set the request type\n params[:request_type] = AppConstants.request_type_api\n\n # mark already authenticated\n set_authenticated\n\n # make api request synchronous as of now\n make_sync_request\n end\n rescue => e \n Rails.logger.error(\"**** ERROR **** #{er(e)}\")\n head :unauthorized\n end",
"def api?\n @controller.start_with?(\"api/\")\n end",
"def api?\n @controller.start_with?(\"api/\")\n end",
"def authenticate_api_key!\n return if current_auth_api_key.present?\n\n render nothing: true, status: :unauthorized\n end",
"def api_authentication_required\n unauthorized unless current_user?\n end",
"def authenticated_master?\n checker = RestfulApiAuthentication::Checker.new(request.headers, request.fullpath)\n if checker.authorized?({:require_master => true})\n return true\n else\n if checker.verbose_errors\n respond_with(checker.errors, :status => 401, :location => nil)\n else\n respond_with([\"not authorized\"], :status => 401, :location => nil)\n end\n end\n end",
"def active_api?\n uri = URI('https://api.bitcoinvenezuela.com/')\n res = Net::HTTP.get_response(uri)\n return res.is_a?(Net::HTTPSuccess) \n end",
"def check_external_authorization(method, path)\n if @authconfigloader_class.nil?\n message = \"Forbidden request: #{path} (method #{method})\"\n raise Puppet::Network::HTTP::Error::HTTPNotAuthorizedError.new(message, Puppet::Network::HTTP::Issues::FAILED_AUTHORIZATION)\n end\n end",
"def verify_api_key\n api_key = request.headers['HB-APIKey']\n if (api_key.nil?)\n api_key = params[:api_key]\n if api_key.nil?\n render :status => 403, :json => {:message => \"Api key missing\"}\n return\n end\n end\n \n api_key_object = ApiKey.find_by_key(api_key)\n if api_key_object.nil?\n render :status => 403, :json => {:message => 'Invalid API Key'}\n return\n end\n end",
"def check_api_key_auth\n User.current = User.find_by_api_key(params[:key])\n unless User.current\n render :text => \"Not Authorized\", :status => 403\n return\n end\n end",
"def api_request?\n false\n end",
"def verify_key\n @user = get_api_user\n if @user.nil?\n render :nothing => true, :status => 503\n else\n render :layout => false\n end\n end",
"def authenticate_manual \n api_key = request.headers['X-Api-Key']\n @app = App.where(api_key: api_key).first if api_key\n\n unless @app\n head status: :unauthorized\n return false\n end\n end",
"def setup_api\n #\n @api = Api.new(current_user)\n\n #\n if white_listed?(path)\n return\n end\n\n #\n token = params[:token] || request.headers['X-Api-Token'] || request.headers['X-API-TOKEN']\n\n unless token.blank?\n user = nil\n token = Token.where(:kind => 'api', :uuid => token.to_s).first\n\n if token and token.context.is_a?(User)\n user = token.context\n end\n\n if user\n @api.user = user\n else\n render(:nothing => true, :status => :unauthorized)\n return\n end\n else\n email, password = http_basic_auth_info\n\n if !email.blank? and !password.blank?\n user = User.where(:email => email).first\n\n if user and user.password == password\n @api.user = user\n else\n headers['WWW-Authenticate'] = ('Basic realm=\"\"' % realm)\n render(:nothing => true, :status => :unauthorized)\n return\n end\n else\n if defined?(current_user) and current_user\n @api.user = current_user\n else\n @api.user = nil\n #headers['WWW-Authenticate'] = ('Basic realm=\"\"' % realm)\n #render(:nothing => true, :status => :unauthorized)\n #return\n end\n end\n end\n\n #\n unless @api.route?(@path) or @path == 'index'\n render :nothing => true, :status => 404\n end\n end",
"def api_request?\n !(@request.path =~ /^\\/assets\\//)\n end",
"def active_api?\n uri = URI('https://api.bitcoinvenezuela.com/DolarToday.php?json=yes')\n res = Net::HTTP.get_response(uri)\n return res.is_a?(Net::HTTPSuccess) \n end",
"def verify_api_key\n # Confirm that it's a json request. This is irrelevant otherwise.\n if request.format && request.format.symbol && request.format.symbol == :json\n # We must have a key, either way. If no key, pass forbidden response.\n if params[:key].nil? && (request.env['HTTP_REFERER'] =~ Regexp.new(request.env['HTTP_HOST'])).nil?\n render :json => { :errors => \"Invalid API key.\" }, :status => :forbidden\n else\n if (request.env['HTTP_REFERER'] =~ Regexp.new(request.env['HTTP_HOST'])).nil?\n # Find by key\n @key = ApiKey.find_by_key(params[:key])\n if @key.nil?\n # Throw error if no key found.\n render :json => { :errors => \"Invalid API key.\" }, :status => :forbidden\n end\n end\n end\n end\n end",
"def api_accessible?\n oauth_token.present? && oauth_secret.present?\n end",
"def restrict_access\n # check if the request has an API key as part of it...\n end",
"def authorize!\n api_key = ApiKey.find_by_access_token(params[:access_token])\n head :unauthorized unless api_key\n return false\n end",
"def whitelist\n if cannot_access_api?\n render json: [], status: :unauthorized\n end\n end",
"def handled_requested_user_app_not_available\n return if app_type_requested_id\n\n msg = 'This app is not available'\n respond_to do |type|\n type.html do\n flash[:warning] = msg\n redirect_to '/'\n end\n type.json do\n render json: { message: msg }, status: 401\n end\n end\n true\n end",
"def is_api?\n false\n end",
"def can_use_api?\n perms.include? Perm.use_api\n end",
"def can_use_api?\n perms.include? Perm.use_api\n end",
"def check(request, response)\n auth = Http::Auth::Bearer.new(\n @realm,\n request,\n response\n )\n\n bearer_token = auth.token\n if bearer_token.blank?\n return [false, \"No 'Authorization: Bearer' header found. Either the client didn't send one, or the server is mis-configured\"]\n end\n\n principal_url = validate_bearer_token(bearer_token)\n if principal_url.blank?\n return [false, \"Bearer token was incorrect\"]\n end\n\n return [true, principal_url]\n end",
"def request_authorization!\n respond_to do |format|\n format.html do\n if request.xhr?\n request_authorization_for_xhr!\n elsif BookingSync::Engine.embedded\n request_authorization_for_embedded!\n else\n request_authorization_for_standalone!\n end\n end\n\n format.json do\n head :unauthorized\n end\n\n format.api_json do\n head :unauthorized\n end\n end\n end",
"def connection_valid?\n client('v1').api_valid?\n rescue StandardError\n false\n end",
"def restrict_access\n\t\t# api_key = ApiKey.find_by_access_token(params[:access_token])\n\t\t# head :unauthorized unless api_key\n\n\t\tauthenticate_or_request_with_http_token do |token, options|\n\t\t\tApiKey.exists?(:access_token => token)\n\t\tend\n\tend",
"def restrict_access\n api_key = ApiKey.find_by_access_token(request.headers[\"token\"])\n head :unauthorized unless api_key \n end",
"def api_authorize\n api_authenticate\n\n unless api_user.api_secret && api_user.api_secret == params[:api_secret]\n render :json => {:error => \"API secret mismatch\"}, :status => :unauthorized\n end\n end",
"def authenticate!\n # if the authentication header is an acceptible value\n if @env['HTTP_X_MY_API'] == 'foobar'\n user = { :id => 1, :name => \"some user\" }\n # warden doesn't care what the user is, so long as it's not nil.\n success! user, \"success\"\n end\n end",
"def check_header\n if ['POST','PUT','PATCH'].include? request.method\n if request.content_type != \"application/vnd.api+json\"\n head 406 and return\n end\n end\n end",
"def authenticate\n unless params[:just_retrieving_resources_to_prove_they_exist_in_client_test]\n render json: { errors: ['You are not authorized'] }, status: :unauthorized\n end\n end",
"def authenticate_if_needed\n # Disable this extra authentication in test mode\n return true if Rails.env.test?\n if (is_hidden || is_staging) && !is_api_or_pdf\n authenticate_or_request_with_http_basic do |username, password|\n username == \"samvera\" && password == \"hyku\"\n end\n end\n end",
"def restrict_access\n\t\tauthenticate_or_request_with_http_token do |token, options|\n\t\t\tapi_token = ApiToken.find_by_access_token(token)\n\t\t\tparam_account = self.get_account\n\t\t\t# Does the api token exist and if so,\n\t\t\t# does it have the same id as the requester supplied?\n\t\t\tapi_token && api_token.account_id == param_account.id\n\t\tend\n\tend",
"def is_api?\n current_user\n @env[API_KEY]\n end",
"def verify_key\n\t\t\tunless (Happyfunrun::app_id==params[:app_id] and Happyfunrun::api_key==params[:api_key])\n\t\t\t\trender :json=>{:status=>'300', :error=>'Access Denied'}\n\t\t\t\treturn\n\t\t\tend\n\t\tend",
"def respond_to?(api_method) # :nodoc:\n HTTPI.get(\"http://#{@console_url}/frontend/#{camelize_api_method_name(api_method.to_s)}.aspx\").code == 200 ? true : false\n end",
"def restrict_access\n authenticate_or_request_with_http_token do |token, options|\n ApiKey.exists?(access_token: token)\n end\n end",
"def check_json_api_headers\n unless request.headers[\"Content-Type\"] && request.headers[\"Content-Type\"].\n include?(\"application/vnd.api+json\")\n return render json: \"\", status: :unsupported_media_type\n end\n\n unless request.headers[\"Accept\"] &&\n request.headers[\"Accept\"].include?(\"application/vnd.api+json\")\n return render json: \"\", status: :not_acceptable\n end\n end",
"def authentication_in_progress?\n request.path_info =~ /^\\/oauth/\n end",
"def authentication_in_progress?\n request.path_info =~ /^\\/oauth/\n end",
"def check candidate_path\n # Convert dynamic segments into regexp captures\n matchable_path = candidate_path.gsub(/:\\w+/, '([^/]+)')\n\n # Don't match a partial segment. For example,\n # don't match /widget for /widgets.\n path.match(Regexp.new(\"^/?#{matchable_path}(?:/|$)\"))\n end",
"def api_version_match?\n ! api_version_negotiated.nil?\n end",
"def authenticate\n token = params['api_key']\n return if token.nil?\n\n @visitor = Visitor.find_by_api_key(token)\n return if @visitor.present?\n\n response_json = { status: Visitor::INVALID_API_KEY }\n respond_with :api, :v1, response_json, status: :unauthorized\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 authorize_api!\n http_basic_authorize!('API', api_username, api_password)\n end",
"def authorize_api!\n http_basic_authorize!('API', api_username, api_password)\n end",
"def restrict_access\n authenticate_or_request_with_http_token do |token, options|\n ApiKey.exists?(access_token: token)\n end\nend",
"def require_api_user_or_token\n case auth_mechanism\n when :system\n authenticate_with_system_token(request.headers[HttpHeaders::MIQ_TOKEN])\n when :token\n authenticate_with_user_token(request.headers[HttpHeaders::AUTH_TOKEN])\n when :ui_session\n raise AuthenticationError unless valid_ui_session?\n auth_user(session[:userid])\n when :jwt\n authenticate_with_jwt(jwt_token)\n when :basic, :basic_async, nil\n success = authenticate_with_http_basic do |u, p|\n begin\n timeout = ::Settings.api.authentication_timeout.to_i_with_method\n\n if oidc_configuration?\n # Basic auth, user/password but configured against OpenIDC.\n # Let's authenticate as such and get a JWT for that user.\n #\n user_jwt = get_jwt_token(u, p)\n token_info = validate_jwt_token(user_jwt)\n user_data, membership = user_details_from_jwt(token_info)\n define_jwt_request_headers(user_data, membership)\n end\n user = User.authenticate(u, p, request, :require_user => true, :timeout => timeout)\n auth_user(user.userid)\n rescue MiqException::MiqEVMLoginError => e\n raise AuthenticationError, e.message\n end\n end\n raise AuthenticationError unless success\n end\n log_api_auth\n rescue AuthenticationError => e\n api_log_error(\"AuthenticationError: #{e.message}\")\n response.headers[\"Content-Type\"] = \"application/json\"\n case auth_mechanism\n when :jwt, :system, :token, :ui_session, :basic_async\n render :status => 401, :json => ErrorSerializer.new(:unauthorized, e).serialize(true).to_json\n when :basic, nil\n request_http_basic_authentication(\"Application\", ErrorSerializer.new(:unauthorized, e).serialize(true).to_json)\n end\n log_api_response\n end",
"def restrict_access\n authenticate_or_request_with_http_token do | token , options |\n ApiKey.exists?(access_token: token)\n end\n end",
"def restrict_access\n\t authenticate_or_request_with_http_token do |token, options|\n\t User.exists?(api_key: token)\n\t end\n\tend",
"def verify_access\n authenticate_or_request_with_http_basic(\"Documents Realm\") do |username, password|\n username == 'rdi' && password == 'btc'\n end\n end",
"def require_auth\n (authorized? && authenticated?) || halt(401)\n end",
"def exist?\n request(:get)\n true\n rescue Stretcher::RequestError::NotFound\n false\n end",
"def authenticate\n config = YAML.load_file(\"#{Rails.root}/config/vcloudair.yml\")[Rails.env]\n\n if config[\"api-shared-secret\"] != request.headers[\"X-Api-Shared-Secret\"]\n render text: \"api-shared-secret/X-Api-Shared-Secret mismatch error\", status: 403\n end\n end",
"def authenticate_json_request\n #return true unless Rails.env.production?\n\n # TODO Turn this back after making it correctly check for API requests\n if false && APIKeysActive == true && Rails.env.production?\n # Is it safe to suppose that ALL JSON requests will be API requests?? -SR\n #we'll check the mime types once 1.0 is deprecated, and 2.0 servers both html and json - RJ\n\n #case request.format\n #when Mime::JSON\n #/^Token token=\"(.+?)\"$/ - This should be integrated in the near future because we want\n # to check for the Token token portion of the header value.\n regex = /^.*\\\"([\\w]+)\\\"$/.match(request.authorization)\n regex ||= Array.new #guarantees the array accessor works on the next line\n key = regex[1]\n render :json => OldApi.error(403, \"Invalid Api Key\"), :status => 403 and return unless ApiKey.exists?(key: key)\n #end\n end\n end",
"def require_user\n if current_user.blank?\n respond_to do |format|\n format.html { authenticate_user!}\n format.all { head(:unauthorized) }\n end\n else\n setup_api_client\n end\n end",
"def authenticate_manual \n api_key = request.headers['X-Api-Key']\n @member = Member.where(api_key: api_key).first if api_key\n\n unless @member\n head status: :unauthorized\n return false\n end\n end",
"def doi_server_reachable?\n # Invoke the API and get response\n true\n end",
"def authorize\n unless params[:token] == Rails.configuration.api_token\n return render(plain: \"Unauthorized API token\\n\", status: :unauthorized)\n end\n end",
"def cors_preflight_check\n logger.info \">>> responding to CORS request\"\n render :text => '', :content_type => 'text/plain'\n end",
"def cors_preflight_check\n logger.info \">>> responding to CORS request\"\n render :text => '', :content_type => 'text/plain'\n end",
"def check_api_key\n return if api_key\n @logger.display('api_key_missing')\n exit 1\n end",
"def require_api_key\n api_key = params[:api_key]\n return if api_key == ENV['ADMIN_API_KEY'] && !ENV['ADMIN_API_KEY'].nil?\n response = {\n status: 'error',\n version: 1,\n error: 'Invalid API key'\n }\n respond_with response, status: :forbidden\n end",
"def ssl_allowed?\n (self.class.read_inheritable_attribute(:ssl_allowed_actions) || []).include?(action_name.to_sym) ||\n request.path.index(\"/zz_api/\") == 0\n end",
"def is_api?\n raise NotImplementedError\n end",
"def is_api?\n raise NotImplementedError\n end",
"def available?\n AvailableResponse.new(request(:get, '/information')).success?\n end",
"def restrict_access\n authenticate_or_request_with_http_token do |token, options|\n ApiKey.exists?(access_token: token)\n end\n end",
"def restrict_access\n authenticate_or_request_with_http_token do |token, options|\n ApiKey.exists?(access_token: token)\n end\n end",
"def developer_key_authentication\n authenticate_or_request_with_http_token do |token|\n Api.exists?(key: token)\n end\n end",
"def check_authentication\n case self.controller_name\n when /^clients/i, /^ingredients/i, /^orders/i, /^pages/i, /^productpresentations/i, /^products/i, /^companies/i\n authenticate\n end\n end",
"def restrict_access \n \t# Não sei o porque, mas é precisa instanciar esse objeto\n \tresponse = nil\n \t\n \t# Verifica se o TOKEN existe\n \t# TODO: Fazer uma validação do TOKEN quando for chamá-lo\n \t# ao invés de fazer isso aqui, pois economiza uma chamada\n \tif params[:token].nil?\n \t\t# bloqueia o acesso\n \t\thead :unauthorized # retirar no futuro quando melhorar a analise do token\n \telse\n \t\t# Faz a chamada pro API da Arich mediante parâmetros no CONFIG da aplicação Rails\n\t\tNet::HTTP.start(Rails.application.config.authentication_location, Rails.application.config.authentication_port) {|http|\n\t\t\t\tresponse = http.head(Rails.application.config.authentication_complement + params[:token])\n\t\t}\n\n\t\t# Analisa o retorno da chamada da API, se algo diferente de\n\t\t# 200 ele rejeita a autenticação\n\t\tif response.code != \"200\"\n\t\t\thead :unauthorized\n\t\tend \n\tend\n end",
"def verify_api_key\n http = Net::HTTP.new(@@detectors[@detector], 80, @proxy_host, @proxy_port)\n resp, data = http.post('/1.1/verify-key', \"key=#{@api_key}&blog=#{@blog}\", STANDARD_HEADERS)\n @verified_key = (data == \"valid\") ? true : :false\n end",
"def cors_preflight_check\n if request.method == :options\n cors_set_access_control_headers\n render text: ''\n end\n end",
"def cors_preflight_check\n if request.method == :options\n cors_set_access_control_headers\n render text: ''\n end\n end",
"def exists?\n conf.has_key? 'api'\n end",
"def check\n # we want to handle cases where the port/target isn't open/listening gracefully\n begin\n # only catch the response if we're going to use it, in this case we do for the version\n # detection.\n res = send_request_cgi(\n 'uri' => normalize_uri(target_uri.path, 'index.php'),\n 'method' => 'GET'\n )\n # gracefully handle if res comes back as nil, since we're not guaranteed a response\n # also handle if we get an unexpected HTTP response code\n fail_with(Failure::UnexpectedReply, \"#{peer} - Could not connect to web service - no response\") if res.nil?\n fail_with(Failure::UnexpectedReply, \"#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}\") if res.code == 200\n\n # here we're looking through html for the version string, similar to:\n # Version 1.2\n /Version: (?<version>[\\d]{1,2}\\.[\\d]{1,2})<\\/td>/ =~ res.body\n\n if version && Gem::Version.new(version) <= Gem::Version.new('1.3')\n vprint_good(\"Version Detected: #{version}\")\n Exploit::CheckCode::Appears\n end\n rescue ::Rex::ConnectionError\n fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\n end\n Exploit::CheckCode::Safe\n end",
"def robots_allowed?(uri); end"
] | [
"0.6675907",
"0.6228955",
"0.61627173",
"0.6135951",
"0.6103222",
"0.6023788",
"0.60127217",
"0.6006747",
"0.59986216",
"0.59982985",
"0.59527326",
"0.59212697",
"0.59128135",
"0.58839536",
"0.58041584",
"0.5770006",
"0.57698023",
"0.5695591",
"0.55857885",
"0.55670345",
"0.55367726",
"0.55367726",
"0.55157745",
"0.54929227",
"0.54833186",
"0.5482888",
"0.5477245",
"0.5457962",
"0.5430437",
"0.54251117",
"0.541034",
"0.5402959",
"0.539042",
"0.5389424",
"0.53558606",
"0.53513986",
"0.53478247",
"0.5344744",
"0.53386354",
"0.53223884",
"0.531175",
"0.5292155",
"0.5291456",
"0.5291456",
"0.52813387",
"0.5277317",
"0.5264132",
"0.5260419",
"0.5255801",
"0.5241534",
"0.5236134",
"0.5226451",
"0.5223949",
"0.52235913",
"0.5223166",
"0.5217773",
"0.52168906",
"0.519934",
"0.5199045",
"0.5185195",
"0.5176425",
"0.5176425",
"0.5174051",
"0.51511145",
"0.514992",
"0.51440805",
"0.51404566",
"0.51404566",
"0.51378495",
"0.5133627",
"0.5133306",
"0.5130644",
"0.51298815",
"0.5124957",
"0.51228267",
"0.51141757",
"0.5107538",
"0.51074535",
"0.5106405",
"0.5105091",
"0.50964195",
"0.5085064",
"0.5085064",
"0.5085023",
"0.5083262",
"0.50797933",
"0.5061921",
"0.5061921",
"0.5053023",
"0.5049863",
"0.5049863",
"0.504019",
"0.501956",
"0.5015247",
"0.5011729",
"0.50101715",
"0.50101715",
"0.49969748",
"0.4994871",
"0.49820068"
] | 0.6123965 | 4 |
Probes all the candidate paths of the API, and returns the first that success. If all probes fail, then the first candidate will be returned. | def find_api_path(uri)
CANDIDATE_API_PATHS.detect { |path| probe_api_path(uri, path) } || CANDIDATE_API_PATHS.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probe\n path = detect_path\n raise Error, 'API path not found' unless path\n\n detect_version(path).map { |version| ProbeResult.new(version: version) }\n end",
"def probe\n path = detect_path\n raise OvirtSDK4::Error.new('API path not found') unless path\n detect_version(path).map { |version| ProbeResult.new(version: version) }\n end",
"def next_candidate\n file_rec = nil\n # loop until a candidate with metadata is retrieved\n loop do\n # Get the next page of results if the previous page has been processed\n fetch_next_page if @result_set.nil? || @result_set.empty?\n\n # Retrieve the next possible candidate path from the page\n next_path = @result_set.shift\n # given that the page was just retrieved, getting a nil path indicates that the retrieved page of\n # candidates is empty and there are no more candidates to iterate at this time.\n return nil if next_path.nil?\n\n logger.debug(\"Retrieved candidate #{next_path}\")\n storage_loc = @app_config.location_manager.get_location_by_path(next_path)\n file_rec = FileRecord.new(next_path, storage_loc)\n\n # Keep seeking until a registered candidate is found, according to the file system.\n if file_rec.metadata_present?\n break\n else\n logger.warn(\"Encountered #{next_path} in index, but path is not registered. Clearing out of synch entry.\")\n @index_manager.remove(file_rec)\n end\n end\n\n @app_config.md_manager.load(file_rec)\n\n file_rec\n end",
"def first_existing(*paths)\n\t\t\tlast_path = nil\n\t\t\tpaths.each do |path|\n\t\t\t\tlast_path = path\n\t\t\t\tbreak if @io.exist?(path)\n\t\t\tend\n\t\t\tlast_path\n\t\tend",
"def all_apf_finder( path_and_file = self.file_name_and_contents.path_and_file, all_apf_arr = [] )\n apf_files = find_apf( path_and_file )\n if apf_files.count > 0\n all_apf_arr << apf_files\n apf_files.each do |apf_file|\n if File.exists? apf_file\n path_and_file = apf_file\n all_apf_finder( path_and_file, all_apf_arr )\n else\n if self.hints_hash['file_does_not_exist']\n self.hints_hash['file_does_not_exist'] << apf_file\n else\n self.hints_hash = self.hints_hash.merge( 'file_does_not_exist' => [ apf_file ] )\n end\n end\n end\n end\n all_apf_arr\n end",
"def find_alternative_paths\n reset\n \n @pairs.reverse!\n find_paths\n @pairs.reverse!\n\n @pairs.map{|pair| pair.path}\n end",
"def find(id)\n puts id\n @candidates.each do |candidate|\n if candidate[:id] == id \n return candidate\n end\n end\n puts \"No candidate found with that ID\"\n return nil\nend",
"def probe(api_map); end",
"def detect(*paths)\n catch(:done){ traverse(*paths){|f| throw(:done, f) if yield f }}\n end",
"def find(id)\n binding.pry\n candidate.each do |candidate|\n if @candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find_nearest_route(path)\n\t\t\tpath_parts = path.parts.dup\n\t\t\tloop do\n\t\t\t\troute = routes.navigate(*path_parts)&.first_route\n\t\t\t\tbreak route if route || path_parts.pop.nil?\n\t\t\tend\n\t\tend",
"def return_solution_found\n @open.select(&:goal).first\n end",
"def pick_candidate(paths, new_path, element)\n # NOTE: order here is important due to early matching\n candidates = [element + \"/\", element + \"[1]\",\n element.sub(/\\[\\d+\\]/, \"\"), element]\n paths.each do |p|\n candidates.each do |c|\n return c if p.start_with?(new_path + c)\n end\n end\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if id == candidate[:id]\n return candidate\n end\n end\n\n nil\nend",
"def find(id)\n # takes single candidate as id :\n @candidates.each do | candidate |\n if candidate[:id] == id \n\n return candidate\n else \n nil\n end\n end\nend",
"def find(id)\n # Your code Here\n # puts \"you are looking for id: #{id}\"\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n return nil\nend",
"def candidate_paths(resolved_path)\n raise NotImplementedError.new\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend",
"def find(id)\nraise \"candidates must be an Array\" if @candidates.nil?\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n nil\nend",
"def list_candidates(path, options = { })\n return path.map { |p| list_candidates(p, options) } if path.is_a?(Array)\n\n command_line = [ '-l' ]\n command_line << '-r' if options[:recursive]\n command_line << '-v' if (verbose = options[:verbose])\n command_line << '-D' if options[:debug]\n\n stripe_group = options[:stripe_group]\n command_line << '-G' << stripe_group if stripe_group\n\n affinity_key = options[:affinity_key]\n command_line << '-K' << affinity_key if affinity_key\n\n minimum_extents = options[:minimum_extents]\n command_line << '-m' << minimum_extents if minimum_extents\n\n command_line << path\n raw_response = execute(command_line)\n return raw_response if options.fetch(:return_raw_response, return_raw_response)\n\n raise raw_response if raw_response.start_with?('Error: ')\n\n candidates = [ ]\n raw_response.each_line { |c| _c = c.strip; next if c.empty? or c.nil?; candidates << _c }\n\n candidates.compact!\n\n return candidates unless verbose and options.fetch(:parse_verbose_data, parse_verbose_data)\n\n candidates.map do |c|\n match = /(.*):\\s?(\\d+)\\sextent[s]?:\\s?(.*)/.match(c)\n next unless match\n { :path => $1, :extent_count => $2, :message => $3}\n end.compact\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if id == candidate[:id]\n end\n nil\nend",
"def find_first(*paths)\n xpath(*paths).first\n end",
"def find(id)\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n return nil\n end\n end\nend",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id]==id\n end\n nil\nend",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id] \n return candidate\n end\nend\n\n nil\nend",
"def find_reachable(start, avoid_sectors = nil, maxcost = nil)\n all_paths(start,avoid_sectors,maxcost)\n end",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id]\n candidate\n end\n end\n nil\nend",
"def get_first_peps(out_files)\n out_files.each do |outf|\n if outf.num_hits > 0\n return outf.hits\n end\n end\n return nil\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n return nil\nend",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n \tif candidate[:id] == id\n \t return candidate\n \tend\n end\n return nil\nend",
"def candidate\n candidates.first\n end",
"def fetch_profiles\n UI.message \"Fetching profiles...#{Sigh.config[:app_identifier]}\"\n results = profile_type.find_by_bundle_id(Sigh.config[:app_identifier])\n\n #Take the provisioning profile name into account\n #if Sigh.config[:provisioning_name].to_s.length > 0\n #filtered = results.select { |p| p.name.strip == Sigh.config[:provisioning_name].strip }\n #if Sigh.config[:ignore_profiles_with_different_name]\n #results = filtered\n #else\n #results = filtered if (filtered || []).count > 0\n #end\n #end\n\n if results \n return [results]\n else\n return []\n end\n \n\n\n #return results if Sigh.config[:skip_certificate_verification]\n\n #return results.find_all do |a|\n ## Also make sure we have the certificate installed on the local machine\n #installed = false\n #a.certificates.each do |cert|\n #file = Tempfile.new('cert')\n #file.write(cert.download_raw)\n #file.close\n #installed = true if FastlaneCore::CertChecker.installed?(file.path)\n #end\n #installed\n #end\n end",
"def lookup(*files, **options)\n result = possible_paths(*files, **options).detect { |file| file.exist? }\n block_given? ? yield(result) : result if result\n end",
"def lookup_file_path\n file_path_list.each do |candidate_file_path|\n next unless File.file?(File.expand_path(candidate_file_path))\n return candidate_file_path\n end\n nil\n end",
"def decide\n result = false\n begin\n @provider.expander.each do |provider|\n @request.expander.each do |request|\n if match(provider, request)\n result = true\n raise StopIteration\n end\n end\n end\n rescue StopIteration\n end\n return result\n end",
"def find (candidate_id)\n @candidates.detect{|candidate| candidate_id == candidate[:id]}\n puts \"No match foud\" if nil \n end",
"def find_profile (profile_name)\n # Find the matching profile\n profile_data = @master_data.select { |p, d| p[/^#{profile_name}/] }\n profile_count = profile_data.count\n if profile_count > 1\n puts \"Profile match not specific enough. Please refine match\"\n exit 1\n elsif profile_count < 1\n puts \"Unable to find profile\"\n exit 1\n end\n return profile_data.first\nend",
"def lookup\n \n # We're not going to add code to check for the existence of files because this is\n # just an example, so we'll keep it short.\n\n files = options[:files]\n\n # The request object has methods for returning the lookup key and namespace for this\n # request\n\n key = request.key\n namespace = request.namespace\n\n # The datasource does not need to be aware if this is a cascading lookup or not, that\n # is to say, whether or not we should continue through the hierarchy or stop at the first\n # result. To return responses we call the answer method as a code block. The answer\n # block will provide an iterator to accept one or many responses depending on the nature\n # of the lookup strategy.\n #\n # Here, for every iteration of answer we will take the next file from the :files array\n # and attempt to lookup and return the value, we do this until the answer iterator\n # finishes (Jerakia does not require further answers) or until we have nothing left to\n # search, in which case we just break from the block.\n #\n\n answer do |response|\n\n filename = files.shift\n\n\n # If filename is nil, there is nothing left to search, we break here and end\n break unless filename\n\n # Load in the JSON document\n data = JSON.load(File.read(filename))\n\n # If the value for the requested key exists in the namespace (see example JSON above)\n # then we return this data by calling the submit method of the response object in\n # this block\n\n if data.has_key(namespace)\n if data[namespace].has_key(key)\n response.submit data[namespace][key]\n end\n end\n\n end\n end",
"def find(key)\n root = root? key.slice(0)\n [].tap { |a| root and probe(0, root, key[1..-1], a) }\n # generate_result([], key) { |rkey, r| r.first.prepend(rkey) }\n end",
"def fetch_results!\n raise NoTargets if targets.empty?\n\n targets.uniq!\n\n puts 'searching the AUR...'\n results = Rpc.new(:multiinfo, *targets).call\n\n # we need the results in the order of our targets (so dependencies\n # are installed first). unfortunately, the rpc returns results\n # alphabetically. assumption is the reordering done here is\n # cheaper than making per-target rpc calls.\n targets.each do |target|\n if result = results.detect {|r| r.name == target}\n @results << result\n else\n raise NoResults.new(target)\n end\n end\n end",
"def discover_roots(url, fetcher)\n robots = begin\n robotsurl = url.clone\n robotsurl.path = '/robots.txt'\n robotstxt = fetcher.call(robotsurl)\n\n discovered = robotstxt.scan(/^Sitemap: (\\S+)/).flatten.map do |url|\n URI.parse(url.strip)\n end\n discovered.presence\n rescue\n nil\n end\n\n # try for files in a handful of known locations\n known_locations = %w(/sitemap_index.xml.gz /sitemap_index.xml /sitemap.xml.gz /sitemap.xml)\n known_locations = known_locations.lazy.map do |path|\n pathurl = url.clone\n pathurl.path = path\n pathurl\n end\n\n robots || known_locations.to_a\n end",
"def find_any(path, options={})\n $LEDGER.find_any(path, options)\n end",
"def scan\n # start with the platform/families who have no families (the top levels)\n top = Train::Platforms.top_platforms\n top.each do |_name, plat|\n # we are doing a instance_eval here to make sure we have the proper\n # context with all the detect helper methods\n next unless instance_eval(&plat.detect)\n\n # if we have a match start looking at the children\n plat_result = scan_children(plat)\n next if plat_result.nil?\n\n # return platform to backend\n @family_hierarchy << plat.name\n return get_platform(plat_result)\n end\n\n raise Train::PlatformDetectionFailed, \"Sorry, we are unable to detect your platform\"\n end",
"def resolve(path, base_path)\n possible_files(path, base_path).each do |file|\n context.resolve(file) { |found| return found if context.asset_requirable?(found) }\n end\n\n nil\n end",
"def request_matching specs\n specs = specs_matching specs\n req = specs && pack_path(specs)\n req\n end",
"def resolve(link)\n self.debug \"starting to resolve #{link}\"\n links, status = @api.list(link)\n return self.push_error_result(link, status) unless links or status.should_probe?\n\n if links\n # if it was a folder or crypter, resolve all found links\n self.debug \"folder/crypter contained #{links}. recursing\"\n threads = links.map do |link|\n Thread.new do\n self.resolve(link)\n end\n end\n threads.each do |thread|\n thread.join\n end\n else\n self.debug \"resolving single link #{link}\"\n info, status = @api.probe(link)\n return self.push_error_result(link, status) unless info\n\n self.debug \"found #{info}\"\n resolvable = Plowshare::Resolvable.new(link, info)\n @results << resolvable\n end\n end",
"def find(id)\n raise '@candidates must be an array' if @candidates.nil?\n @candidates.detect {|candidate| candidate[:id] == id}\n\nend",
"def find_file(path_info, accept_encoding:)\n each_candidate_filepath(path_info) do |filepath, content_type|\n if response = try_files(filepath, content_type, accept_encoding: accept_encoding)\n return response\n end\n end\n end",
"def processNextStart()\n while true\n path = starts.next\n if building_path\n if compare.call path.first, building_path.first\n add_path path\n else\n return next_path(path)\n end\n else\n next_path(path)\n end\n end\n rescue Pacer::EmptyPipe, java.util.NoSuchElementException\n if building_path\n r = building_path\n self.building_path = nil\n r\n else\n raise EmptyPipe.instance\n end\n end",
"def find(id)\n @candidates.each do | candidate |\n if candidate[:id] == id\n return candidate \n end\n end\nend",
"def find_server!\n @client.clients.each do |client|\n client.force_status! do |status|\n if status == :primary && [:primary, :primary_preferred, :secondary_preferred].include?(@client.read_pref)\n @pending_server = false\n server_found!\n elsif status == :secondary && [:secondary, :primary_preferred, :secondary_preferred].include?(@client.read_pref)\n @pending_server = false\n server_found!\n end\n end\n end\n end",
"def find_best_way(xx,yy)\n pf = Pathfinder.new($map)\n pf.ignore_obs_target = true # permit to calculate a path to a case with an ennemy on it\n path = pf.find([x,y],[xx,yy])\n end",
"def find(id)\n # Your code Here\n @candidates.each do |el|\n # logic to check if id match else null\n if el[:id] == id\n puts 'found match'\n return el\n end\n end\n return nil\nend",
"def probe(url)\n # @todo Create args options Hash to dynamically configure settings.\n raise ArgumentError.new, \"Incorrect number of arguments: expected 1.\" if url.nil? \n\n # Associate argument with @uri element tag for future logging purposes.\n # Will also serve for faster clash checking (aka w/o DBMS)\n url = URI.parse(url)\n @uri = url\n\n #Create NET::HTTP request to the specified IP\n http = Net::HTTP.new(url.host, url.port)\n http.read_timeout, http.open_timeout = 3\n \n request = Net::HTTP::Get.new(url)\n request['User-Agent'] = \"Gerridae Gem\"\n request['Accept'] = \"*/*\"\n \n # Gather response, switch code to string, add it to content hash.\n response = http.request(request)\n code = response.code.to_s \n @content[:return_code] = code\n\n\n # todo Abstract to own method within Helpers module.\n if Helpers::is_good_http_response? code.to_i \n @content = { :http_version => response.http_version, :message => response.message }\n\n # @todo Use JSON parsing method here\n response.each do |key, value|\n @content[key.to_sym] = value unless key.nil? && value.nil? \n end\n #todo Return HTTP code to indicate success.\n end\n #todo Return nil or other failure indicator for failure.\n\n end",
"def findMappedResource(resources)\n obj=nil\n resources.each { |uri|\n if uri\n case uri.scheme\n when \"file\"\n file=uri.path\n if File.exists?(file)\n obj=File.open(file)\n end\n when \"http\"\n resp=Net::HTTP.get_response(uri)\n obj=resp.body if resp.code==\"200\"\n end\n if obj\n print \"found mapped resource #{uri}\\n\"\n break\n end\n end\n }\n obj\nend",
"def test_sets_options_from_passed_options_and_ups_min_id\n connection.expects(:get).with(api_url, target_first_params).returns(get_response)\n search_query.next_results_page\n connection.expects(:get).with(api_url, target_subsequent_params).returns(get_response)\n search_query.next_results_page\n end",
"def find(id)\n @candidates.detect do |candidate|\n candidate[:id] === id\n end\nend",
"def preferred_version(api)\n if !api.kind_of?(String) && !api.kind_of?(Symbol)\n raise TypeError,\n \"Expected String or Symbol, got #{api.class}.\"\n end\n api = api.to_s\n # TODO(bobaman): Update to use directory API.\n return self.discovered_apis.detect do |a|\n a.name == api && a.preferred == true\n end\n end",
"def find_working_trackers\n # We could pass an array in, but the purpose is to do 5 scrapes and see\n # how often the host responds. Using different ones looks less like abuse.\n hashes = [\n '867bdcaec9b522809aebc1e7085ef8f0a1e7f290',\n '1354AC45BFB3E644A04D69CC519E83283BD3AC6A',\n '66FC47BF95D1AA5ECA358F12C70AF3BA5C7E8F9A',\n '39eac8c9fcb529d518184d45cdaa558771089835',\n '3C7534B034FE8FD46B5AF3A52AC3AA1B89DDEF03'\n ]\n\n results = {}\n\n hashes.each do |hash|\n puts \"Fetching hash #{hash}...\"\n scrape_all(hash).each do |res|\n tracker = res[:tracker]\n status = res[:status]\n if results.has_key?(tracker)\n results[tracker] << status\n else\n results[tracker] = [status]\n end\n end\n end\n \n puts \"Finished scanning #{hashes.size} hashes across #{results.size} trackers...\"\n results.each do |tracker, res|\n puts \"#{res}: #{tracker}\"\n success = res.select{|x| x == :success}.count * 20\n if success > 0\n puts \"GOOD: #{tracker} (#{success}%)\"\n else\n puts \"BAD: #{tracker} (0%)\"\n end\n end\n nil\n end",
"def resolve_url url_array\n url_array.each do |url_str|\n url = URI.parse(url_str)\n req = Net::HTTP.new(url.host, url.port)\n\n begin\n Timeout.timeout(5) do\n res = req.request_head(url.path)\n\n if res.code == \"200\"\n return url_str\n end\n end\n rescue Timeout::Error\n puts \"URL #{url_str} did not respond in 5 seconds.\"\n next\n end\n end\n return \"\"\nend",
"def find(id)\n found = nil\n @candidates.each do |candidate|\n if candidate[:id] == id\n found = candidate\n end\n end\n found\nend",
"def gather_endpoints_to_check\n Rails.application.routes.routes.map do |route|\n verb = route.verb.downcase.to_sym\n example_path = route.path.spec\n .to_s.gsub('(.:format)', '')\n .gsub(/:([^\\/]+)/,'SOME_PLACEHOLDER_PARAM')\n .gsub('*path', 'SOME_PLACEHOLDER_PATH')\n .gsub('*filename','SOME_PLACEHOLDER_FILENAME')\n next unless verb.present?\n [verb, example_path]\n end.compact\n end",
"def find(interface, rs_or_rq = RS)\r\n # if the interface is not specified, return false\r\n if !interface then\r\n return nil\r\n end\r\n # check the existence of the base_dir\r\n if !FileTest.directory?(base_dir) then\r\n return nil\r\n end\r\n # scan the response file in the directory\r\n dir_list = [base_dir]\r\n until dir_list.empty?\r\n # get the dir from the list\r\n current_dir = dir_list.shift\r\n current_dir << \"/\" unless current_dir[-1].chr == \"/\"\r\n # begin to traversa this dir, if find, reuslt will be the path, otherwise nil\r\n result = Dir.foreach(current_dir) do |child|\r\n # exclude the ., .., svn, web-inf\r\n next if child == \".\" || child == \"..\" || child.include?(\"\\.svn\") || child.include?(\"WEB-INF\")\r\n # form the path\r\n @status_bar.set_status_text(child_path = current_dir + child)\r\n \r\n if FileTest.directory?(child_path) then\r\n dir_list.push(child_path)\r\n next\r\n end\r\n \r\n if FileTest.file?(child_path) && child_path.downcase.include?(interface.downcase) && child_path.include?(rs_or_rq) then\r\n break child_path\r\n else\r next\r\n end\r\n end\r\n # if find break the loop\r\n break result if result\r\n end\r\n end",
"def each_probe(match=nil, &block)\n if match\n parts = match.split(':', 4)\n begin\n each_probe_match(*parts, &block)\n rescue ArgumentError => e\n raise DTrace::Exception.new(\"each_probe: probe specification expected (e.g. 'provider:::')\")\n end\n else\n each_probe_all(&block)\n end\n end",
"def probe_api_path(uri, path)\n uri = URI.join(uri, path)\n request = RestClient::Resource.new(uri.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)\n begin\n request.get\n rescue RestClient::Exception => exception\n response = exception.response\n logger.error \"#{self.class.name}#probe_api_path: exception probing uri: '#{uri}'. Exception: #{$ERROR_INFO}\"\n return false if response.nil?\n if response.code == 401\n www_authenticate = response.headers[:www_authenticate]\n if www_authenticate =~ /^Basic realm=\"?(RESTAPI|ENGINE)\"?$/\n return true\n end\n end\n end\n false\n end",
"def resolve_alternates(load_path, logical_path)\n candidates, deps = super\n\n # bower.json can only be nested one level deep\n if !logical_path.index('/'.freeze)\n dirname = File.join(load_path, logical_path)\n\n if directory?(dirname)\n filenames = POSSIBLE_BOWER_JSONS.map { |basename| File.join(dirname, basename) }\n filename = filenames.detect { |fn| self.file?(fn) }\n\n if filename\n deps << build_file_digest_uri(filename)\n read_bower_main(dirname, filename) do |path|\n if file?(path)\n candidates << path\n end\n end\n end\n end\n end\n\n return candidates, deps\n end",
"def find_path_brute_force( board, start_point )\n options = get_options( start_point, board )\n\n # Bottom right corner\n if options.length == 0\n return { points: [start_point], best_value: get_value( start_point, board ) }\n end\n\n # If there's only one option, this works fine still.\n first_result = find_path_brute_force( board, options.first )\n second_result = find_path_brute_force( board, options.last )\n if first_result[:best_value] > second_result[:best_value]\n return {\n points: [start_point] + first_result[:points],\n best_value: first_result[:best_value] + get_value( start_point, board )\n }\n else\n return {\n points: [start_point] + second_result[:points],\n best_value: second_result[:best_value] + get_value( start_point, board )\n }\n end\nend",
"def best_candidate\n self.by_quality.first\n end",
"def prime_tests\n meth = %i[visit get].find { |m| respond_to?(m) } or return\n without_tracing do\n # Since the option causes a redirect, it's a little faster to avoid it\n # for subsequent executions.\n opt = self.tests_primed ? {} : { debug: true }\n send(meth, root_url(**opt))\n self.tests_primed = true\n end\n end",
"def first(*args)\n if args.any?\n if args.first.kind_of?(Integer) ||\n (loaded? && !args.first.kind_of?(Hash))\n to_a.first(*args)\n else\n apply_finder_options(args.first).first\n end\n else\n find_first\n end\nend",
"def find_endpoint http_method, path\n self.class.endpoints[http_method].each do |endpoint|\n return endpoint if endpoint.matches path\n end\n\n nil\n end",
"def find(path); end",
"def find(path); end",
"def _resolve path, options = {}\n candidates(path).detect do |path|\n downloadable? path, options\n end || resolve(File.dirname(path), options)\n end",
"def find_existing_path(typed_name)\n is_global = global?\n smart_paths.effective_paths(typed_name.type).each do |sp|\n next unless sp.valid_name?(typed_name)\n origin = sp.effective_path(typed_name, is_global ? 0 : 1)\n unless origin.nil?\n if sp.fuzzy_matching?\n # If there are multiple *specific* paths for the file, find\n # whichever ones exist. Otherwise, find all paths that *might* be\n # related to origin\n if origin.is_a?(Array)\n origins = origin.map { |ori| existing_path(ori) }.compact\n return [origins, sp] unless origins.empty?\n else\n origins = candidate_paths(origin)\n return [origins, sp] unless origins.empty?\n end\n else\n existing = existing_path(origin)\n return [origin, sp] unless existing.nil?\n end\n end\n end\n nil\n end",
"def hit(uris)\n uris.map do |u|\n response =\n if u.kind_of? String\n Net::HTTP.get(URI.parse(u))\n else\n url = URI.parse(u[0])\n Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }\n end\n\n assert response, \"Didn't get a response: #{u}\"\n response\n end\nend",
"def match(test_path)\n # shortcut return root recursive matching\n return Some(0) if path == '' && recursive\n\n split_test_path = test_path.split('/', -1)\n split_path = path.split('/', -1)\n\n # count the number of segments that match\n split_test_path\n .zip(split_path)\n .reduce(0) do |total, (t, p)|\n break total unless t == p\n\n total + 1\n end => count\n\n min_length = split_path.length\n\n # if we haven't matched at least as many path segments as is in this\n # mappings path, then fail\n return None() if count < min_length\n\n # if any more matches occurred\n # then success, and return the depth of match\n return Some(count) if recursive\n\n # only return success if all segments matched\n count == split_test_path.size ? Some(count) : None()\n end",
"def detect(dir = Dir.pwd)\n candidates = @registry.find_all do |pack|\n pack.applicable? dir\n end\n\n raise NotFound if candidates.empty?\n raise AmbiguousApp if candidates.length > 1\n\n candidates.first\n end",
"def find_partners_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PartnerApi.find_partners ...'\n end\n # resource path\n local_var_path = '/partners'\n\n # query parameters\n query_params = {}\n query_params[:'tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) if !opts[:'tags'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Partner>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PartnerApi#find_partners\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def execute_api_calls_and_evalute_responses\n apple_store_response.valid? ? evaluate_apple_lookup_api_call : apple_store_response.error\n end",
"def find(id)\n raise '@candidates must be an Array' if @candidates.nil?\n @candidates.detect {|candidate| candidate[:id] == id}\nend",
"def find_next\n status = `git status -s`.lines.reject(&:nil?).grep(/.. (PCL|tsion|steveklabnik)\\//)\n return nil if status.empty?\n\n first = status.map{|x| x.gsub(/^.. /, '') }.first.strip\n \n if File.directory?(first) \n return [first, [first]]\n else\n name = first.split('/')[-1].split('_', 2)[1]\n end\n\n pcl = find_file('PCL', name)\n tsion = find_file('tsion', name)\n steve = find_file('steveklabnik', name)\n\n [name, [pcl, tsion, steve]]\n end",
"def at_xpath(*paths)\n result = nil\n\n paths.each {|path|\n if result = xpath(path).first\n break\n end\n }\n\n result\n end",
"def find_path(start, chargers, builtin)\n chargers = chargers.dup\n current_jolt = start\n chargers << builtin\n chargers.sort.each do |charger|\n difference = charger - current_jolt\n return false if difference > 3\n\n current_jolt = charger\n end\n true\n end",
"def find_resources(&block)\n found = Varnisher::Urls.new\n\n self.class.resources.each do |resource|\n found += find_resource(resource, &block)\n end\n\n Varnisher.log.debug ''\n Varnisher.log.info \"#{found.length} total resources found.\\n\"\n\n found\n end",
"def try_route_with_individual_storage_checks(type, name)\n self.hosts.each do |host|\n logger.debug \"Trying host '#{host}' via Smoke for existence of #{type} '#{name}'...\"\n\n svc = smoke(host)\n exist =\n case type\n when :user\n svc.user_dir_exist?(name)\n when :gist\n svc.gist_dir_exist?(name)\n else false\n end\n\n if exist\n self.cache[name] = host\n logger.debug \"Found host '#{host}' for #{type} '#{name}' from Smoke.\"\n return host\n end\n end\n logger.warn \"No host found for #{type} '#{name}'.\"\n nil\n rescue Object => e\n logger.error \"No host found for #{type} '#{name}' because of '#{e.message}'.\"\n nil\n end",
"def check candidate_path\n # Convert dynamic segments into regexp captures\n matchable_path = candidate_path.gsub(/:\\w+/, '([^/]+)')\n\n # Don't match a partial segment. For example,\n # don't match /widget for /widgets.\n path.match(Regexp.new(\"^/?#{matchable_path}(?:/|$)\"))\n end",
"def find\n log_output(\"Starting #{provider} find\", :info)\n validate_provision_fields\n connection = connect\n \n name = get_field('name')\n # select those servers matching name. Fail if servers don't have a name\n servers = connection.servers.select do |s|\n if s.respond_to?(:name)\n s.name =~ /#{name}/\n else\n raise PluginError, \"Provider #{provider} does not support finding servers by name\"\n end\n end\n\n save_server_ids_in_context(servers, true)\n save_server_in_context(servers, true)\n populate_meta(servers, 'find', true)\n\n msg = servers.empty? ? \"#{provider} found no servers\" : \"#{provider} found #{servers.size} servers: \"\n msg += servers.map{|s| s.respond_to?(:name) ? s.name : s.identity}.join(\",\")\n Maestro.log.debug msg\n write_output(\"#{msg}\\n\")\n end",
"def find(path)\n @gemspecs.each do |spec|\n return spec if matching_file(spec, path)\n end\n nil\n end",
"def find_exact_cover\n exact_covers.first\n end",
"def find(id)\n # Your code Here\n @candidates.each do |element|\n \tif element[:id] == id\n \t\tpp element\n \tend\n end\n pp nil\n\nend",
"def find_paths(&block)\n follow,kill,find,continue = SearchParams.process(&block)\n\n paths,path = [],[]\n search = lambda do |node|\n if find[node]\n paths << path.dup\n next if not continue[node]\n end\n next if kill[node]\n [*follow[node]].each do |n|\n next if path.include? n\n path.push(n)\n search[n]\n path.pop\n end\n end\n\n [*follow[self]].each do |n| \n path.push(n)\n search[n] \n path.pop\n end\n\n paths\n end",
"def find(id)\n\nreturn candidates.detect{|candidate| candidate[:id]==id }\n\nend",
"def check\n\n # run a nuclei\n uri = _get_entity_name\n\n\n known_paths = <<-eos\n/api\n/api/v1\n/api/v1/namespaces\n/api/v1/nodes\n/api/v1/pods\n/apis\n/apis/admissionregistration.k8s.io/v1beta1\n/apis/apiextensions.k8s.io/v1beta1\n/apis/apiregistration.k8s.io/v1beta1\n/apis/apps/v1\n/apis/apps/v1beta1\n/apis/apps/v1beta2\n/apis/authentication.k8s.io/v1\n/apis/authentication.k8s.io/v1beta1\n/apis/authorization.k8s.io/v1\n/apis/authorization.k8s.io/v1beta1\n/apis/autoscaling/v1\n/apis/autoscaling/v2beta1\n/apis/batch/v1\n/apis/batch/v1beta1\n/apis/certificates.k8s.io/v1beta1\n/apis/events.k8s.io/v1beta1\n/apis/extensions/v1beta1\n/apis/extensions/v1beta1/podsecuritypolicies\n/apis/networking.k8s.io/v1\n/apis/policy/v1beta1\n/apis/rbac.authorization.k8s.io/v1\n/apis/rbac.authorization.k8s.io/v1beta1\n/apis/storage.k8s.io/v1\n/apis/storage.k8s.io/v1beta1\n/version\n/api/v1/namespaces/default/pods/\n/api/v1/namespaces/default/pods/test/status\n/api/v1/namespaces/default/secrets/\n/apis/extensions/v1beta1/namespaces/default/deployments\n/apis/extensions/v1beta1/namespaces/default/daemonsets\nca-key.pem\ntoken_auth.csv\nca.pem\nconfig.seen\ncloud-provider.yaml\napiserver.pem\n10-flannel.conf\nconfig.source\naudit.log\nconfig.hash\napiserver-key.pem\ncni-conf.json\nkube-proxy.log\napiserver-aggregator-ca.cert\napiserver-aggregator.cert\nserver.cert\nca.key\netcd-events.log\nkube-scheduler.log\nnode-role.kubernetes.io\nkube-apiserver.log\nbasic_auth.csv\ndns.alpha.kubernetes.io\napiserver-aggregator.key\netcd.log\nknown_tokens.csv\nkube-controller-manager.log\nca.crt\nserver.key\nrun.sh\netcd-apiserver-client.key\netcd-ca.crt\nadmission_controller_config.yaml\nserviceaccount.crt\napiserver-client.crt\nca-certificates.crt\napiserver.crt\nkube-addons.sh\ngce.conf\npv-recycler-template.yaml\netcd-apiserver-client.crt\nproxy_client.crt\napiserver.key\netcd-apiserver-server.crt\netcd-apiserver-ca.crt\netcd-apiserver-server.key\nserviceaccount.key\netcd-peer.key\naggr_ca.crt\nmigrate-if-needed.sh\napiserver-client.key\nproxy_client.key\netcd-peer.crt\nkube-addon-manager.log\nkube-apiserver-audit.log\nglbc.log\neos\n\n\n\n # default value for the check response\n out = false\n\n # first test that we can get something\n contents = http_get_body \"#{uri}\"\n _log_error \"failing, unable to get a response\" unless contents\n\n # get a missing page, and sha the dom\n benign_contents = http_get_body \"#{uri}/api/v1/namespaces/default/pods/#{rand(10000000000)}.aspx\"\n benign_content_sha = Digest::SHA1.hexdigest(html_dom_to_string(benign_contents))\n\n # check all paths for a non-error response\n known_paths.split(\"\\n\").each do |k8path|\n _log \"Getting: #{k8path}\"\n\n full_path = \"#{uri}#{k8path}\"\n\n # get the body and do the same thing as above\n contents = http_get_body full_path\n our_sha = Digest::SHA1.hexdigest(html_dom_to_string(contents))\n\n # now check them\n default_response = /default backend \\- 404/\n if our_sha != benign_content_sha && !contents =~ default_response\n heuristic_match = true\n _log \"Odd contents for #{full_path}!, flagging\"\n out = construct_positive_match(full_path, contents, benign_contents)\n else\n _log \"Got same content for missing page, probably okay\"\n end\n\n end\n\n out\n end",
"def youngest_person(people)\n # ??? <-- Only do this after writing the test and making sure it starts out failing!\nend",
"def find(id)\n found = nil\n found = @candidates.find { |candidate| candidate.fetch(:id) == id }\n # found = @candidates.select { |candidate| candidate.fetch(:id) == id }\n # found && found = found[0]\nend",
"def find(id)\n @candidates.each do |item|\n if item[:id]==id\n @result = item\n end\n end\n @result\nend",
"def find(id)\n @candidates.each do |person|\n if person[:id] === id\n return person\n end\n end\n return nil\nend",
"def find(path='/', &block)\n results = list(path, true)\n return (block_given?) ? results.select(&block) : results\n end"
] | [
"0.65709126",
"0.61971354",
"0.56022227",
"0.5500517",
"0.5206111",
"0.514551",
"0.5140843",
"0.50757813",
"0.5075698",
"0.50582874",
"0.504951",
"0.50423217",
"0.5020953",
"0.50137943",
"0.49814612",
"0.498063",
"0.49609333",
"0.4949002",
"0.49309647",
"0.49101096",
"0.4901755",
"0.48949403",
"0.48802453",
"0.48595357",
"0.48345155",
"0.48286295",
"0.4828106",
"0.48275754",
"0.48191163",
"0.4819083",
"0.4805166",
"0.478591",
"0.47845063",
"0.47768763",
"0.47501367",
"0.4734695",
"0.47195476",
"0.471459",
"0.47097173",
"0.4707311",
"0.47051826",
"0.47048956",
"0.46976057",
"0.46801522",
"0.46767685",
"0.46741387",
"0.46727598",
"0.46719778",
"0.46716285",
"0.46626407",
"0.46517283",
"0.4639215",
"0.46289238",
"0.46255377",
"0.4624975",
"0.4603503",
"0.45985618",
"0.4585831",
"0.4582368",
"0.45798877",
"0.45679694",
"0.45660308",
"0.45618773",
"0.4553486",
"0.45528418",
"0.45524052",
"0.45522612",
"0.45474005",
"0.45449427",
"0.45439997",
"0.45361087",
"0.4532066",
"0.45297268",
"0.45297268",
"0.45243615",
"0.45162377",
"0.4510654",
"0.45100334",
"0.45045307",
"0.45032874",
"0.4500302",
"0.44990024",
"0.44975182",
"0.44952956",
"0.44931737",
"0.44923607",
"0.44921994",
"0.44915318",
"0.44898662",
"0.44885966",
"0.4481414",
"0.448055",
"0.44797525",
"0.44773",
"0.447713",
"0.4470932",
"0.44695458",
"0.44606933",
"0.4460201",
"0.44493645"
] | 0.53918535 | 4 |
Returns the path of the API, probing it if needed. | def api_path
@api_path ||= find_api_path(base_uri)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n # if an api_version is specified and the path does not already contain\n # one, prepend it to the path\n api_version = raw_options[:api_version] || Blupee.config.api_version\n \"/#{api_version}/#{raw_path}\"\n end",
"def api_path(path)\n \"#{options[:base_path]}/#{path}\" || \"/#{path}\"\n end",
"def api_url(path)\n path\n end",
"def api_base_path\n \"/lol/platform/#{api_version}\"\n end",
"def api_path(path)\n \"/rest/v#{options[:api_version]}/#{path}\"\n end",
"def api_path(path)\n \"/services/data/v#{@options[:api_version]}/#{path}\"\n end",
"def find_api_path(uri)\n CANDIDATE_API_PATHS.detect { |path| probe_api_path(uri, path) } || CANDIDATE_API_PATHS.first\n end",
"def resource_api_path(path=nil)\n @resource_api_path = path if path\n @resource_api_path || \"1.0/#{self.path}\"\n end",
"def service_require\n ruby_file_path @api, service_name_full\n end",
"def config_path\n if result = chef_api_config_path\n Pathname(result).expand_path\n else\n Pathname(\"\")\n end\n end",
"def shellforce_api\n ShellForce.config.path + '/api'\nend",
"def api_path\n parent.api_path\n end",
"def build_path\n path = %w(api where)\n path.concat api_method\n path = path.join('/')\n @path = \"/#{path}.json\"\n end",
"def url(path)\n \"#{API}/#{path}\"\n end",
"def get_api_url_for(path)\n\t\treturn ('https://api.spotify.com' << path)\n\tend",
"def api_clients_path\n verify_path API_CLIENTS_PATH\n File.join @tar_contents_path, API_CLIENTS_PATH\n end",
"def api_path\n @api_path ||= \"/api/security/permissions/#{url_safe(name)}\"\n end",
"def api_url\n @api_url ||= URI.parse(::File.join(base_url, endpoint))\n end",
"def base_path\n \"/api/v1\"\n end",
"def base_path # rubocop:disable Rails/Delegate\n chip_api.base_path\n end",
"def api_path(*args)\n ver = api_version.presence\n arg = args.flatten.join('/').strip\n uri = URI.parse(arg)\n qry = uri.query.presence\n path = uri.path.presence\n host = uri.host.presence\n url =\n if host\n rel = (host == base_uri.host)\n scheme = uri.scheme.presence || (base_uri.scheme.presence if rel)\n port = uri.port.presence || (base_uri.port.presence if rel)\n scheme ||= 'https'\n port &&= nil if COMMON_PORTS.include?(port)\n [scheme, \"//#{host}\", port].compact.join(':')\n end\n base = base_uri.path.presence\n base = base&.split('/')&.compact_blank!&.presence\n path = path&.split('/')&.compact_blank!&.presence\n ver = nil if ver && (base&.include?(ver) || path&.include?(ver))\n base = base&.join('/')\n path = path&.join('/')\n path = \"#{base}/#{path}\" if base && path && !path.start_with?(base)\n [url, ver, *path].compact_blank!.join('/').tap do |result|\n result << \"?#{qry}\" if qry\n end\n end",
"def api_url\n return nil unless @auth\n\n if @auth.empty?\n warn \"There are no API configurations in #{@auth_file}\"\n return nil\n end\n\n if @auth.keys.size > 1\n warn \"There are #{@auth.keys.size} API configurations in #{@auth_file}\"\n return nil\n end\n\n @auth.keys.first\n end",
"def request_path(end_point)\n \"/api/v#{@api_version}/#{end_point}\"\n end",
"def api_url(path)\n return path if path.include?('//')\n \"#{api_root}/#{api_version}/#{tenancy_code}/#{path}\"\n end",
"def api_url(path_fragment)\n platform.api_url(path_fragment)\n end",
"def api_uri\n raise Exceptions::BadlyConfigured.new if @api_uri.empty? || @api_uri.nil? || @api_uri == '/'\n @api_uri\n end",
"def url_for(path, opts = {})\r\n api_host = opts[:api_host] || Moviepilot.config.api_host\r\n version = opts[:api_version] || Moviepilot.config.api_version\r\n [api_host, version, path].join('/')\r\n end",
"def path(version)\n path_lookup_util(version)\n end",
"def path(version)\n path_lookup_util(version)\n end",
"def parse_path_api path\n return path unless path =~ %r{(.*)#{self.class.api_doc_suffix}$}i\n [$1, true]\n end",
"def api_path(*args)\n \"/v#{api_version}/#{args.unshift(api_tier).compact.join('/')}\"\n end",
"def api(path)\n OodAppkit.files.api(path: path).to_s\n end",
"def chef_api_config_path\n ENV[\"CHEF_API_CONFIG\"] || if ENV.key?(\"HOME\")\n \"~/.chef-api\"\n else\n nil\n end\n end",
"def api_uri\n @api_uri ||= URI.parse(api_endpoint)\n end",
"def endpoint_url\n # @@api_base + @request.endpoint\n ApiBase + @endpoint\n end",
"def api_path\n if remote?\n \"drives/#{@remote_drive_id}/items/#{@remote_id}\"\n else\n \"drive/items/#{@id}\"\n end\n end",
"def api_host #:nodoc:\n API_URI\n end",
"def api_uri\n @api_uri ||= URI(api_url)\n end",
"def api_framework\n source_node[:apiFramework]\n end",
"def api_framework\n source_node[:apiFramework]\n end",
"def api_framework\n source_node[:apiFramework]\n end",
"def url\n api_url\n end",
"def path\n @backend.lib_dir + name_on_disk\n end",
"def api_url\n @@API_URL\n end",
"def documented_paths\n @documented_paths ||= begin\n @resources.inject([]) { |memo, r| memo += r[\"apis\"].map { |api| api[\"path\"] } }\n end\n end",
"def api_url(url = '')\n configuration.api_base + url\n end",
"def api_root\n root_url << '/api'\n end",
"def api_endpoint\n @api_endpoint ||= ENDPOINTS[:sandbox][:api]\n end",
"def request_uri(path)\n \"/#{API_VERSION}/#{path}\"\n end",
"def api_base_path\n 'https://messaging.bandwidth.com/api/v2'\n end",
"def path\n driver.getPath\n end",
"def api_prefix\n @api_url || DEFAULT_API_PREFIX\n end",
"def path\n @base\n end",
"def api_url\n @api_url || DEFAULT_API_URL\n end",
"def api_url\n \"#{protocol}://api:#{api_key}@#{host}/#{api_version}\"\n end",
"def base_href\n '/api/v1'\n end",
"def api_url\n @api_url || DEFAULT_API_URL\n end",
"def api_url\n if PagSeguro.developer?\n File.join PagSeguro.config[\"base\"], \"pagseguro_developer/confirm\"\n else\n API_URL\n end\n end",
"def api_url\n api_key? ? base_url.concat(api_query_parameter) : base_url\n end",
"def base\n\t\t\t\tif @api\n\t\t\t\t\treturn @api.base_url\n\t\t\t\telse\n\t\t\t\t\treturn 'http://masterserver.hon.s2games.com/'\n\t\t\t\tend\n\t\t\tend",
"def api_path\n @api_path ||= \"/api/security/groups/#{url_safe(name)}\"\n end",
"def local_path\n fetch_path(DevTools.gem_root)\n end",
"def url_api\n Guidebox\n end",
"def api_endpoint\n @api_endpoint ||= DEFAULT_API_ENDPOINT\n end",
"def make_url(apipath)\n @base_url + \"/api/open-v1.0/\" + apipath\n end",
"def api_base_url\n \"https://#{platform}.api.riotgames.com\"\n end",
"def path\n http_url RDoc::RDoc.current.generator.file_dir\n end",
"def api_uri\n options.endpoint\n end",
"def api_url\n raise NotImplementedError, \"#{self.class} must implement #api_url!\"\n end",
"def directory_uri\n template = Addressable::Template.new(\n \"https://{host}/discovery/v1/apis\"\n )\n return template.expand({\"host\" => self.host})\n end",
"def endpoint_for(path)\n File.join(MemoTomato::ROOT_URL, \"#{path}.json\")\n end",
"def request_uri(path)\n \"#{@api_url}#{path}\"\n end",
"def return_api_path(array)\n api_version = '1.0'\n return \"/#{api_version}/#{array.join('/')}\"\n end",
"def find_path\n\n end",
"def api_url(url)\n uri = URI(url.to_s)\n\n uri.scheme = server_uri.scheme if uri.scheme.nil?\n uri.host = server_uri.host if uri.host.nil?\n\n # prepend '/api/<version>/' to path if not provided\n unless uri.path =~ /^\\/api\\/\\d+\\//\n uri.path = File.join('/api', version.to_s, uri.path)\n end\n\n uri.to_s\n end",
"def api_base_url; @opts[:api_base_url]; end",
"def path\n http_url @store.rdoc.generator.class_dir\n end",
"def directory\n @endpoint ||= config.use_staging? ? ENDPOINT_STAGING : ENDPOINT\n end",
"def statsd_base_path\n \"rpc-client.#{service}.#{method_name}\".gsub('::', '.').downcase\n end",
"def path\n metadata.fetch(:path) do\n return if request_response_pairs.empty?\n request_response_pairs.first.first.path\n end\n end",
"def api\n self.well_info.api\n end",
"def path\n File.join Dubya.root_path, 'vendor/wiki'\n end",
"def api_path(path)\n \"/v3/company/#{options[:realm_id]}/#{path}\"\n end",
"def api_url\n @api_url ||=\"#{base_url}#{@options['api_url']}\"\n end",
"def coreApiEP\n\t\tCORE_API_URL_83\n\tend",
"def request_path current\n path = []\n\n while current do\n requirement = current.request.dependency.requirement\n path << \"#{current.spec.full_name} (#{requirement})\"\n\n current = current.parent\n end\n\n path = ['user request (gem command or Gemfile)'] if path.empty?\n\n path\n end",
"def framework_path\n File.join(config.build_products_dir, name)\n end",
"def api_location\n nil\n end",
"def api_url path, params = {}\n url = File.join File.join(api_base_url, api_base_path), path\n \"#{url}?#{api_query_string params}\"\n end",
"def path_for(app: app_name)\n \"#{base_path}/#{app}\"\n end",
"def path_for(app: app_name)\n \"#{base_path}/#{app}\"\n end",
"def get_root_json_filename\n File.expand_path(\"#{@api_directory}/root.json\")\n end",
"def get_api_url(endpoint)\n @api_base_url + endpoint\n end",
"def ext_url\n \"#{GOOGLEAPIS_URL}#{ext_path}\"\n end",
"def lookup_path_direct(namespace, path, type); end",
"def resource_path\n '.' + Dir[File.dirname(__FILE__)][/\\/resource\\/.*/]\n end",
"def search_external_path\n Options.external_dir\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end"
] | [
"0.7206963",
"0.7098479",
"0.7054683",
"0.69686484",
"0.6953233",
"0.6939049",
"0.68937266",
"0.6871654",
"0.66723686",
"0.66668826",
"0.6626966",
"0.6597206",
"0.6591955",
"0.64411867",
"0.6433396",
"0.64278024",
"0.64240927",
"0.6382282",
"0.6366482",
"0.63334465",
"0.63058126",
"0.62551284",
"0.62329066",
"0.623036",
"0.61873364",
"0.615081",
"0.6141104",
"0.6131615",
"0.6131615",
"0.6129782",
"0.6104619",
"0.6094652",
"0.60873646",
"0.6053775",
"0.60421485",
"0.6033231",
"0.6023925",
"0.6021023",
"0.6007562",
"0.6007562",
"0.6007562",
"0.5993444",
"0.598961",
"0.5985158",
"0.5984889",
"0.5963411",
"0.59613776",
"0.59477365",
"0.59405124",
"0.59323835",
"0.5913285",
"0.59015924",
"0.58927816",
"0.5884317",
"0.5883636",
"0.58825827",
"0.5872163",
"0.58704424",
"0.5847916",
"0.58195126",
"0.5816663",
"0.58084434",
"0.5795828",
"0.5795778",
"0.57772887",
"0.5775381",
"0.57715064",
"0.5767418",
"0.57672983",
"0.5765793",
"0.57607394",
"0.5757168",
"0.5746587",
"0.57109404",
"0.57047683",
"0.57006085",
"0.56733656",
"0.5662541",
"0.5658388",
"0.56537426",
"0.5645285",
"0.5626955",
"0.5626346",
"0.5621386",
"0.56135607",
"0.5611147",
"0.5604767",
"0.5599571",
"0.5595261",
"0.5578414",
"0.5578414",
"0.5570072",
"0.55696094",
"0.55674255",
"0.5565043",
"0.556496",
"0.55620766",
"0.5560571",
"0.5560571",
"0.5560571"
] | 0.7940841 | 0 |
Parse domain out of the username string | def parse_domain_name
if @options[:domain].blank? && !@options[:username].blank?
if @options[:username].include?('\\')
@options[:domain], @options[:username] = username.split('\\')
elsif @options[:username].include?('/')
@options[:domain], @options[:username] = username.split('/')
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username_domain(username = nil)\n username ||= options[:username] if options\n return unless username\n username.to_s.split('@').last\n end",
"def parse_user_domain(hostname)\n return hostname.split('.').first if Rails.configuration.url_host.empty?\n Rails.configuration.url_host.split(',').each do |url_host|\n return hostname.chomp(url_host).chomp('.') if hostname.include?(url_host)\n end\n ''\n end",
"def domain_username_split(user)\n return user if(user.nil? || user.empty?)\n if !user[/\\//] # Only /, not \\!\n return [nil,user]\n else\n return user.split(\"/\",2)\n end\n end",
"def domain_name(str)\n str = str.split('//')\n str = str[str.size - 1].split('.')\n str.delete('www')\n str[0]\nend",
"def domain_name(url)\n #url.gsub(/http:|https:|www.|\\/\\/|.com.*/,'')\n url.gsub(/http:|https:|www.|\\/\\//,'').split('.').first\nend",
"def parse_domain_name\n mdata = /ip domain-name ([\\w.]+)/.match(config)\n { domain_name: mdata.nil? ? '' : mdata[1] }\n end",
"def parse_username_from_url\n URI.parse(url_from_attributes).path.split(\"/\")[1]\n rescue URI::BadURIError, URI::InvalidURIError\n nil\n end",
"def get_domain url\n uri = URI.parse url\n host = uri.host.downcase\n host.start_with?('www.') ? host[4..-1] : host\n end",
"def domain_name(url)\n url.gsub(\"www.\",\"\").split(\"//\")[1].split(\"/\")[0].split('.')[0]\nend",
"def get_url_domain\n uri = URI.parse(url)\n host = uri.host.downcase\n host.start_with?('www.') ? host[4..-1] : host\n end",
"def get_domain_name_from_email_address(email)\nemail.scan(/@(\\w+)/)[0].pop\nend",
"def domain\n @domain ||= begin\n return nil if @text.empty?\n\n uri = Addressable::URI.parse(@text)\n\n if uri.host # valid https?://* URI\n uri.host\n elsif email?\n @text.match(/@([\\w\\.\\-]+)\\Z/i)[1]\n else # url sans http://\n begin\n uri = Addressable::URI.parse(\"http://#{@text}\")\n # properly parse http://foo edge cases\n # see https://github.com/sporkmonger/addressable/issues/145\n uri.host if uri.host =~ /\\./\n rescue Addressable::URI::InvalidURIError\n nil\n end\n end\n end\n end",
"def domain\n @domain ||= begin\n return nil if @text.empty?\n\n uri = Addressable::URI.parse(@text)\n\n if uri.host # valid https?://* URI\n uri.host\n elsif email?\n @text.match(/@([\\w\\.\\-]+)\\Z/i)[1]\n else # url sans http://\n begin\n uri = Addressable::URI.parse(\"http://#{@text}\")\n # properly parse http://foo edge cases\n # see https://github.com/sporkmonger/addressable/issues/145\n uri.host if uri.host =~ /\\./\n rescue Addressable::URI::InvalidURIError\n nil\n end\n end\n end\n end",
"def get_domain_name_from_email_address(email)\n med = email[/[@].*[.]/]\n domain = med[1..-2]\nend",
"def domain_name(url)\n url.match(/(http[s]?:\\/\\/[\\\\w]{3}?\\.?)(\\w+-?\\w+)/)[-1]\nend",
"def get_domain(url)\n url_partitioned_at_double_hash = url.partition(\"//\")\n domain_partitioned_at_hash = url_partitioned_at_double_hash[2].partition(\"/\")\n domain_partitioned_at_hash[0]\nend",
"def domain_name(url)\n if url.match(/^www/)\n p url.split(\".\")[1]\n elsif url.match(/^http/)\n x = url.split(\"/\")[2]\n if x.match(/^www/)\n p x.split(\".\")[1]\n else\n p x.split(\".\")[0]\n end\n else\n p url.split(\".\")[0]\n end\nend",
"def user_domain\n @user_domain ||= if (parts = new_resource.user.match(/(?<domain>.*)\\\\(?<account>.*)/))\n parts[:domain]\n end\n end",
"def domain_name(url)\n url.gsub(/http(s)?:\\/\\/(www.)?/, '').match(/[^.]+/)[0]\nend",
"def domain\n email.split(\"@\")[1]\n end",
"def normalize(domain)\n # strip off the protocol (\\w{1,20}://), the URI (/), parameters (?), port number (:), and username (.*@)\n # then split into parts via the .\n parts = domain.gsub(%r{^\\w{1,20}://}, '').gsub(%r{[/?:].*}, '').gsub(/.*?@/, '').split('.')\n # grab the last two parts of the domain\n dom = parts[-2, 2].join '.'\n # if the dom is in the two_level_tld list, then use three parts\n dom = parts[-3, 3].join '.' if @two_level_tld.index dom\n dom = parts[-4, 4].join '.' if @three_level_tld.index dom\n dom\n end",
"def normalized_domain\n if @text.empty?\n nil\n elsif parsed_domain\n parsed_domain.host\n end\n end",
"def split_email_domain\n return self.email.split('@')[1]\n end",
"def domain_parts\n PublicSuffix.parse domain\n rescue PublicSuffix::DomainInvalid\n nil\n end",
"def domain_parts\n PublicSuffix.parse domain\n rescue PublicSuffix::DomainInvalid\n nil\n end",
"def get_domain_name_from_email_address(email)\n index_no = email.index('@') + 1\n email[index_no...email.length - 4]\nend",
"def domain_name(url)\n url.match(%r{(http(s)?://)?(www.)?([a-zA-Z0-9-]*)}).to_a.last\nend",
"def initialize( username, domain = nil )\n if (domain)\n @username = username\n @domain = domain\n else\n (@username, @domain) = username.split('@')\n end\n replace( \"#{@username}\\@#{@domain}\".downcase )\n end",
"def domain_name(url)\n regex = /(?:(http|https):\\/\\/)?(?:www\\.)?(?<domain_name>.*?)\\./\n return url.match(regex)[:domain_name]\n \n # original solution:\n # regex = /(?:(?:(?:http:\\/\\/)?(?:www\\.)?)|(?:(?:https:\\/\\/)?(?:www\\.)?))([\\w-]+)\\./\n # matches = regex.match(url)\n # return matches.to_a.last\nend",
"def domain url\n domain = URI.parse(url.sub(%r{[?#].*$}, '').gsub(/\\s/, '+')).domain rescue nil\n domain || url.scan(%r{https?://([^/]+)}).first\n end",
"def domain_name(url)\n return nil unless url\n if m=url.match(/([^.\\/ ]+)\\.(com|net|info|org|name|biz|gov|\\w\\w)(\\.\\w+)?(\\/.*)*(\\?.*)*$/)\n \"#{m[1]}.#{m[2]}\"\n else\n url\n end\n end",
"def cleanse_domain(domain)\n domain.downcase!\n domain = domain.sub(/^https?\\:\\/\\//, '').sub(/^www./,'')\n domain = domain.split(\"/\").first\n domain = domain.split(\"@\").last\n\n domain = PublicSuffix.parse(domain)\n domain = \"#{domain.sld}.#{domain.tld}\"\n domain\n end",
"def domain_info\n @domain = normalized_email.split('@').last\n domain\n end",
"def domain\n Domain.new((address.split('@')[1] || '').strip)\n end",
"def domain(dom)\n domain = URI.extract(dom)\n raise ArgumentError, 'The domain must be a URL.' if domain.blank?\n @domain = URI.parse(domain[0]).normalize.to_s\n end",
"def parse_session_domain\n \".#{$1}\" if /([^\\.]+\\.[^\\.]+)$/.match(request.forwarded_hosts.first)\n end",
"def extract_host(u)\n URI.split(u).compact[1]\n end",
"def get_domain_name_from_email_address(email)\n\temail = '[email protected]'\n\tn = email.gsub(/.+@([^.]+).+/, '\\1')\nend",
"def extract_host(u)\n URI.split(u).compact[1]\n end",
"def clean_username(username)\n\n my_username = username\n #remove all non- alphanumeric character (expect dashes '-')\n my_username = my_username.gsub(/[^0-9a-z -]/i, '')\n\n #remplace dashes() for empty space because if the user add dash mean that it want separate the username\n my_username = my_username.gsub(/[-]/i, ' ')\n\n #remplace the empty space for one dash by word\n my_username.downcase!\n my_username.strip!\n username_split = my_username.split(' ').join('-')\n\n end",
"def sf_domain(uri)\n uri = uri.to_s.split('/')\n uri.empty? ? '' : uri[2]\n end",
"def parse_domain_attr(name)\n unless name.is_a?(String)\n fail 'domain attribute name must be a string'\n end\n\n *first, last = name.split('.')\n [first.join('.'), last]\n end",
"def domain_of(email)\n\t\tdomain = email.match /[^@]+\\z/\n\t\tdomain[0] if domain\n\tend",
"def subdomain\n host.split(\".\").first\n end",
"def domain\n @domain ||= PublicSuffix.parse(@fqdn).domain\n end",
"def normalize_domain(domain)\n return domain.downcase.gsub(/\\.$/,'')\n end",
"def domain\n return @domain if defined? @domain\n\n @domain = begin\n PublicSuffix.parse(normalized_domain, default_rule: nil)\n rescue PublicSuffix::DomainInvalid, PublicSuffix::DomainNotAllowed\n nil\n end\n end",
"def domain\n unless @domain\n if defined? ActiveSupport::CoreExtensions::String::Inflections\n @domain = name.tableize\n else\n @domain = name.downcase\n end\n end\n @domain\n end",
"def domain(tld_length = 1)\n host.split(\":\").first.split(\".\").last(1 + tld_length).join(\".\")\n end",
"def smtp_domain\n @smtp_username.split('@').last\n end",
"def parse_dn\n raise InvalidURIError, 'bad LDAP URL' unless @path\n @dn = @path[1..-1]\n end",
"def extract_domain_name(payload)\n\t\tif(payload) then\n\t\t domain_name = \"\"\n while(true)\n \t\n \t len = payload[0].unpack('H*')[0].to_i\n \t # to understand below you might need to read up on dns packets. they take the form of [length][string][length][string][...]0\n \t if len != 0 then \n \n domain_name += payload[1, len] + \".\" #grab the first chunk from the begining, until the length specified by the packet\n payload = payload[len + 1..-1]\n else\n domain_name = domain_name[0, domain_name.length - 1] # -1 to truncate the 0 at the end of the payload\n \t\n \n return domain_name\n \t\n end # if len != 0 then\n end\n end\n\tend",
"def get_domain_name_from_email_address(email)\nend",
"def parse_site_user_id_from_url url\n url.scan(/cc\\/blog\\/([^\\/]+)/)[0][0].downcase rescue nil\n end",
"def dn_to_domain(dn)\n if dn.include? \"DC=\"\n return dn.gsub(',','').split('DC=')[1..-1].join('.')\n else\n return dn\n end\n end",
"def extract_subdomain(host, tld_length); end",
"def get_domain_name(host)\n domain = nil\n search = nil\n resolv_conf = if host['platform'].include?('windows')\n if host.is_cygwin?\n host.exec(Command.new(\"cat /cygdrive/c/Windows/System32/drivers/etc/hosts\")).stdout\n else\n host.exec(Command.new('type C:\\Windows\\System32\\drivers\\etc\\hosts')).stdout\n end\n else\n host.exec(Command.new(\"cat /etc/resolv.conf\")).stdout\n end\n resolv_conf.each_line do |line|\n if (match = /^\\s*domain\\s+(\\S+)/.match(line))\n domain = match[1]\n elsif (match = /^\\s*search\\s+(\\S+)/.match(line))\n search = match[1]\n end\n end\n return_value ||= domain\n return_value ||= search\n\n return unless return_value\n\n return_value.gsub(/\\.$/, '')\n end",
"def get_domain(payload)\n domain_name = \"\"\n while(true)\n # Get length fields\n len = payload[0].unpack('H*')[0].to_i\n \n if len != 0 then\n domain_name += payload[1, len] + \".\"\n payload = payload[len + 1..-1]\n else\n domain_name = domain_name[0, domain_name.length - 1]\n return domain_name\n end # if len != 0 then\n end # while(true)\n end",
"def email_domain\n if !self[:email].blank?\n split_host = URI.parse(\"#{self[:email]}\").path.split('@')\n \"#{split_host.last}\" if 2 == split_host.size\n else\n self.organization.site_domain if self.organization\n end\n rescue URI::InvalidURIError\n nil\n end",
"def domain\n URI(base_url).host.downcase\n end",
"def host_from_uri(domain)\n Addressable::URI.parse(domain).host || Addressable::URI.parse(\"http://#{domain}\").host\n end",
"def parse_prefix(prefix)\n nick_and_user, host = String(prefix).split \"@\", 2\n\n if host.nil?\n if nick_and_user.include? \".\"\n servername = nick_and_user\n else\n nickname = nick_and_user\n end\n else\n nickname, user = nick_and_user.split \"!\", 2\n end\n\n [nickname, user, host || servername]\n end",
"def build_domain \n unless self.domain\n self.domain = URI.parse(self.url).host \n self.save\n end\n end",
"def normalise_nick(nick)\n return /^[@+]?(.*)$/.match(nick)[1]\n end",
"def base_hostname\n @username.match(/.com/) ? @username : \"#{@username}.tumblr.com\"\n end",
"def domain\n URI.parse(@config.split('<')[0].split('->')[0])\n end",
"def guess_company_domain\n if self.company_domain.blank?\n string = self.company_name.to_s.downcase.gsub(' ', '') + \".fr\"\n self.company_domain = string\n end\n end",
"def get_account_subdomain(request_host, app_host)\n if request_host =~ /(.*?)\\.?#{app_host}$/ && !($1.empty? || $1 == 'www')\n $1\n elsif APP_CONFIG[:restricted_names].include?(request_host.split('.').last)\n request_host\n else\n nil\n end\n end",
"def splitter(data)\n data.split(%r{(?:@)[^\\s]+|(?:http)s?:\\/[^\\s]+|\\W}).reject(&:empty?)\n end",
"def get_address_domain(address)\n\t\tmatch = @domain_regex.match(address)\n\t\tif !match.nil?\n\t\t\treturn match[1]\n\t\telse\n\t\t\treturn \"UNKNOWN DOMAIN\"\n\t\tend\n\tend",
"def return_email_domain \n return \"@\" + self.email.split('@')[1]\n end",
"def username\n email.match(/[^@]+/).to_s\n end",
"def name_of_user(username)\n username.split('.').map(&:capitalize)\n end",
"def first_domain_part\n return nil if request.env['HTTP_HOST'].blank?\n @first_domain_part ||= request.env['HTTP_HOST'].split(\".\").first\n end",
"def format_username\n \t_email_base = self.email[/[^@]+/]\n \tself.username ||= _email_base.camelize.underscore.gsub(/\\./,\"_\") unless _email_base.nil?\n\n end",
"def subdomains(tld_length = 1) \n parts = host.split('.')\n parts[0..-(tld_length+2)]\n end",
"def preprocess_username\n @username = @options[:ldap][:username_prefix] + @username if @options[:ldap][:username_prefix]\n end",
"def parse_url_host\n url = self.url.gsub(/^https?\\:\\/\\//, '')\n url = url.gsub(/www\\./, '') unless (url.match(/www\\./).blank? && url.gsub(/www\\./, '').match(/[A-Za-z]/))\n self.url = \"https://\" + url\n end",
"def domain(tld_length = 1)\n host.split('.').last(1 + tld_length).join('.')\n end",
"def social_media_name(url)\n if url.include?(\"www\")\n url_name = url.gsub(\"https://www.\",\"\")\n url_name = url_name.split(\".com\").unshift\n url_name[0]\n elsif url.include?(\"https\")\n url_name = url.gsub(\"https://\",\"\")\n url_name = url_name.split(\".com\").unshift\n url_name[0]\n else\n url_name = url.gsub(\"http://\",\"\")\n url_name = url_name.split(\".com\").unshift\n url_name[0]\n end\nend",
"def normalize(address)\n return nil unless address.count(\"@\") == 1\n\n name, domain = address.downcase.split(\"@\")\n\n domain = CANONICAL_DOMAINS.fetch(domain, domain)\n name = name.delete(\".\") if domain.in?(IGNORE_DOTS)\n name = name.gsub(/\\+.*\\z/, \"\") if domain.in?(IGNORE_PLUS_ADDRESSING)\n name = name.gsub(/-.*\\z/, \"\") if domain.in?(IGNORE_MINUS_ADDRESSING)\n\n \"#{name}@#{domain}\"\n end",
"def find_for_domain(string)\n token = string\n defs = _definitions(TYPE_TLD)\n\n while token != \"\"\n if (found = defs[token])\n return factory(:tld, *found)\n else\n index = token.index(\".\")\n break if index.nil?\n\n token = token[(index + 1)..-1]\n end\n end\n\n nil\n end",
"def normalized_host\n # Remove trailing '.' characters\n host.sub(/\\.*$/, '').downcase if host\n end",
"def getDomainName(payload)\n domainName = \"\"\n while(true)\n len = payload[0].to_i\n if (len != 0)\n domainName += payload[1,len] + \".\"\n payload = payload[len+1..-1]\n else\n return domainName = domainName[0,domainName.length-1]\n end\n end\nend",
"def normalize(domain)\n domain = domain.chomp(DOT).unicode_normalize(:nfc) unless domain.ascii_only?\n Punycode.encode_hostname(domain).downcase\n end",
"def sanitize_url(url)\n # URL matches 'www'\n if url =~ /w{3}/\n sterilize url.split(/\\./)[1]\n # URL does not match 'www'\n else\n first_parts = url.split(/\\./)[0..1]\n scheme_eliminated = first_parts.map {|part| part.gsub(/[a-zA-Z]+\\W+/, '')}.join(' ')\n sterilize(scheme_eliminated) \n end\n end",
"def strip_domain(jid)\n domain = jid.domain.split('.').drop(1).join('.')\n JID.new(domain)\n end",
"def nickname(url)\n return nil unless url\n if m=url.match(/([^.\\/ ]+)\\.(com|net|info|org|name|biz|gov|\\w\\w)(\\.\\w+)?(\\/.*)*(\\?.*)*$/)\n m[1]\n else\n url\n end\n end",
"def get_image_url(str, domain)\n ary = str.split('/')\n if ary[0] == ''\n domain + str\n else\n str\n end\n end",
"def extract_user_id(username)\n username[2..-2]\n end",
"def parse_url(input)\n hosts = \"github\\.com|bitbucket\\.org|gitlab\\.com\"\n\n # HTTPS/HTTP link pointing to recognised hosts\n if input =~ /^(?:https?:\\/\\/)?(?:[^.@]+@)?(?:www\\.)?(#{hosts})\\/([^\\/]+)\\/([^\\/]+)/i\n { host: $1.downcase(), user: $2, repo: $3.sub(/\\.git$/, \"\") }\n # SSH\n elsif input =~ /^git@(#{hosts}):([^\\/]+)\\/([^\\/]+)\\.git$/i\n { host: $1.downcase(), user: $2, repo: $3 }\n # provider:user/repo\n elsif input =~ /^(github|bitbucket|gitlab):\\/?([^\\/]+)\\/([^\\/]+)\\/?$/i\n { host: $1.downcase(), user: $2, repo: $3 }\n # user/repo - Common GitHub shorthand\n elsif input =~ /^\\/?([^\\/]+)\\/([^\\/]+)\\/?$/\n { host: \"github.com\", user: $1, repo: $2 }\n else\n raise \"Unsupported URL: #{input}\"\n end\nend",
"def getDomain(payload)\n\tdomainName = \"\"\n\t\n\twhile true\n\n\t\t# Get length of domain name section\n\t\tlength = payload[0].unpack('c*')[0]\n\t\t#length = payload[0].to_i\n\n\t\tif(length != 0)\n\n\t\t\t# Add domain section to overall domain name string\n\t\t\tdomainName += payload[1, length] + \".\"\n\t\t\tpayload = payload[length + 1..-1]\n\t\telse\n\t\t\t# Return overall domain name string\n\t\t\treturn domainName = domainName[0, domainName.length - 1]\n\t\tend\n\tend\n\tputs \"Domain Info: \" + domainName\nend",
"def domain\n @uri[:domain]\n end",
"def get_host_from_url(url)\n return url[0...url.index(\"/\")]\nend",
"def slug\n @input = self.username.gsub(/\\s|\\W/,'-').downcase\n end",
"def parse_url(text)\n text.downcase\n end",
"def dn_for username\n \"uid=#{username},#{@dn_suffix}\"\n end",
"def to_domain\n domain = @uri.domain\n domain ? Wgit::Url.new(domain) : nil\n end",
"def to_domain\n domain = @uri.domain\n domain ? Wgit::Url.new(domain) : nil\n end",
"def get_host_name(url)\n\tmatch = %r|(https?://)?(?<host>[^/]+)(/.*$)?|.match(url)\n\tmatch['host']\nend"
] | [
"0.79118145",
"0.78218126",
"0.7167245",
"0.7149523",
"0.714551",
"0.713789",
"0.7134789",
"0.7083486",
"0.7073546",
"0.6886631",
"0.6885214",
"0.6874291",
"0.6874291",
"0.68356234",
"0.6816738",
"0.6813902",
"0.6751128",
"0.673275",
"0.67262846",
"0.67204493",
"0.6656043",
"0.6652542",
"0.6652492",
"0.6620043",
"0.6620043",
"0.66078764",
"0.6573",
"0.6562271",
"0.6535608",
"0.650862",
"0.64911324",
"0.64732337",
"0.6436634",
"0.6351844",
"0.63334554",
"0.633135",
"0.63045526",
"0.6295862",
"0.6282088",
"0.62744105",
"0.62549865",
"0.6212391",
"0.61994267",
"0.6183127",
"0.6155675",
"0.6140241",
"0.61353534",
"0.61166763",
"0.60860103",
"0.60674644",
"0.60593134",
"0.6054861",
"0.6052832",
"0.603484",
"0.6030035",
"0.5984736",
"0.5977946",
"0.5955438",
"0.5947339",
"0.5933033",
"0.59215295",
"0.59159195",
"0.5905967",
"0.5904363",
"0.58432764",
"0.583758",
"0.58144194",
"0.5805823",
"0.57912314",
"0.57911086",
"0.5788067",
"0.5760544",
"0.5755543",
"0.5750804",
"0.57384646",
"0.57357794",
"0.5732019",
"0.57188255",
"0.57012194",
"0.56804734",
"0.5679355",
"0.5673983",
"0.5664284",
"0.5653259",
"0.564559",
"0.5635451",
"0.5616638",
"0.561395",
"0.5574247",
"0.5571753",
"0.5566411",
"0.55638975",
"0.554934",
"0.5539019",
"0.55342215",
"0.5526511",
"0.5523782",
"0.5522013",
"0.5522013",
"0.55013734"
] | 0.8521616 | 0 |
Returns a file object containing the trusted CA certificates. The file will be created if it doesn't exist, and it shouldn't be removed or modified by the caller. | def ca_file
return unless @ca_certs
@ca_file ||= Tempfile.new('ca_file').tap do |tempfile|
tempfile.write(@ca_certs)
tempfile.close
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trusted_certs_content\n content = \"\"\n if chef_config[:trusted_certs_dir]\n Dir.glob(File.join(ChefConfig::PathHelper.escape_glob_dir(chef_config[:trusted_certs_dir]), \"*.{crt,pem}\")).each do |cert|\n content << \"cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'\\n\" +\n IO.read(File.expand_path(cert)) + \"\\nEOP\\n\"\n end\n end\n content\n end",
"def trusted_certs\n @trusted_certs ||= trusted_certs_content\n end",
"def certs\n unless @@certs\n pattern = /-{5}BEGIN CERTIFICATE-{5}\\n.*?-{5}END CERTIFICATE-{5}\\n/m\n dir = File.join(VINES_ROOT, 'conf', 'certs')\n certs = Dir[File.join(dir, '*.crt')].map {|f| File.read(f) }\n certs = certs.map {|c| c.scan(pattern) }.flatten\n certs.map! {|c| OpenSSL::X509::Certificate.new(c) }\n @@certs = certs.reject {|c| c.not_after < Time.now }\n end\n @@certs\n end",
"def ca_cert()\n\t\tENV['CA_FILE'] || \"TestCA.crt\" # The CA cert File\n end",
"def ca_file\n ENV['SSL_CERT_FILE']\n end",
"def cert_file_path\n File.expand_path(File.join(control.newrelic_root, 'cert', 'cacert.pem'))\n end",
"def cert_file\n write_file(\"request-#{domain}.crt\", cert.to_pem)\n end",
"def ca_cert_location\n @ca_cert_location ||= begin\n if cf?\n File.join(tmp_dir, 'ca.crt')\n else\n nil\n end\n end\n end",
"def make_ssl_cert_file(cert_file)\n\n uri = URI(@cert_source_uri)\n\n Net::HTTP.start(uri.host) { |http|\n resp = http.get(uri.path)\n open(cert_file, \"w\") { |file|\n file.write(resp.body)\n }\n }\n end",
"def ca_cert\n @ca_cert ||= OpenSSL::X509::Certificate.new File.read(ca_cert_file)\n end",
"def ca_cert_location\n @ca_cert_location ||= begin\n if ca_cert_string\n File.join(tmp_dir, 'ca.crt')\n else\n nil\n end\n end\n end",
"def make_certs_world_readable\n FileUtils.chmod(0644, [root_filename, cert_filename].compact)\n end",
"def load_trust_ca\n load_cacerts(@cert_store)\n change_notify\n end",
"def add_trust_ca(trust_ca_file_or_hashed_dir)\n unless File.exist?(trust_ca_file_or_hashed_dir)\n trust_ca_file_or_hashed_dir = File.join(File.dirname(__FILE__), trust_ca_file_or_hashed_dir)\n end\n @cacerts_loaded = true # avoid lazy override\n add_trust_ca_to_store(@cert_store, trust_ca_file_or_hashed_dir)\n change_notify\n end",
"def distrust_certs()\n process_certs(\"Explicitly distrusting certs\", CertTools.distrusted_certs_dir)\n end",
"def get_cert_path\n if !has_cert?\n return nil\n end\n\n return @cert_file_path\n end",
"def get_cert\n cert_str = \"\"\n \n File.open(@cert_file_path, \"r\") do |f|\n cert_str = f.read\n end\n\n return cert_str\n end",
"def get_trusted_keys\n return [] unless File.file?(@trust_path)\n\n # no signature verification\n File.open(@trust_path, 'r').readlines.map(&:chomp).uniq.sort\nend",
"def ssl_ca_certificate_file\n super\n end",
"def ca_file\n @ca_file ||= ENV.fetch(\"CODECLIMATE_CA_FILE\", File.expand_path(\"../../../../config/cacert.pem\", __FILE__))\n end",
"def ca_store\n @ca_store ||= begin\n store = OpenSSL::X509::Store.new\n store.add_file(ca_bundle_path)\n store\n end\n end",
"def ca_file; end",
"def ca_file; end",
"def certificate_path\n\t\t\tFile.join(@root, \"#{@hostname}.crt\")\n\t\tend",
"def cert_file_path\n if path_override = NewRelic::Agent.config[:ca_bundle_path]\n NewRelic::Agent.logger.warn(\"Couldn't find CA bundle from configured ca_bundle_path: #{path_override}\") unless File.exist?(path_override)\n path_override\n end\n end",
"def ca_file\n @agent.ca_file\n end",
"def certs_dir\n File.normalize_path(File.join(root_path, '..', 'certs'))\n end",
"def certs_dir\n Pathname.new File.expand_path('../../tmp/certs', __FILE__)\nend",
"def certificate_file\n super\n end",
"def load_test_certs\n this_dir = File.expand_path(File.dirname(__FILE__))\n data_dir = File.join(File.dirname(this_dir), 'spec/testdata')\n files = ['ca.pem', 'server1.key', 'server1.pem']\n files.map { |f| File.open(File.join(data_dir, f)).read }\nend",
"def certificate_get\n return @cert unless @cert.nil?\n cert_path = File.join(resource[:cert_dir], resource[:cert_name])\n @cert = if Pathname.new(cert_path).exist?\n file = File.read(cert_path)\n OpenSSL::X509::Certificate.new(file)\n else\n false\n end\n end",
"def load_test_certs\n this_dir = File.expand_path(File.dirname(__FILE__))\n data_dir = File.join(File.dirname(File.dirname(this_dir)), 'spec/testdata')\n files = ['ca.pem', 'server1.key', 'server1.pem']\n files.map { |f| File.open(File.join(data_dir, f)).read }\nend",
"def test_SSL_CERT_FILE\n if ENV['SSL_CERT_FILE']\n # Connect per system CA list (overwritten per SSL_CERT_FILE)\n sclient = connect_ssl_client(\"localhost\", 23456)\n res = read_and_close_ssl(sclient, \"hello client->server\")\n assert_equal \"hello server->client\", res\n else\n server = TCPServer.new \"localhost\", 23456\n server_th = Thread.new do\n sserver = run_ssl_server(server, pki)\n read_and_close_ssl(sserver, \"hello server->client\")\n end\n\n Tempfile.open([\"cert\", \".pem\"]) do |fd|\n fd.write pki.ca_cert.to_pem\n fd.close\n ENV['SSL_CERT_FILE'] = fd.path\n cmd = [\"ruby\", __FILE__, \"-n\", __method__.to_s]\n res = IO.popen(cmd, &:read)\n assert_equal 0, $?.exitstatus, \"res #{cmd.join(\" \")} failed: #{res}\"\n ENV.delete('SSL_CERT_FILE')\n end\n\n assert_equal \"hello client->server\", server_th.value\n end\n end",
"def cert\n @cert ||= (OpenSSL::X509::Certificate.new File.read(cert_file) if cert_file)\n end",
"def load_test_certs\r\n this_dir = File.expand_path(File.dirname(__FILE__))\r\n data_dir = File.join(File.dirname(File.dirname(this_dir)), 'spec/testdata')\r\n files = ['ca.pem', 'server1.key', 'server1.pem']\r\n files.map { |f| File.open(File.join(data_dir, f)).read }\r\nend",
"def check(desc, ca_path, cert_path)\n store = OpenSSL::X509::Store.new\n store.add_file(ca_path)\n\n client_cert = OpenSSL::X509::Certificate.new(File.read(cert_path))\n\n result = store.verify(client_cert)\n\n puts \"#{desc}: #{result}\"\nend",
"def test_ssl_certs_dir\n certfile = \"#{RbConfig::TOPDIR}/#{\"bin/etc/\" if RUBY_VERSION >= \"3.2\"}ssl/certs/#{pki.ca_cert.subject.hash.to_s(16)}.0\"\n File.write(certfile, pki.ca_cert.to_pem)\n\n server = TCPServer.new \"localhost\", 0\n server_th = Thread.new do\n run_ssl_server(server, pki)\n end\n\n # Connect per system CA list (with addition of our certificate)\n sclient = connect_ssl_client(\"localhost\", server.local_address.ip_port)\n assert_ssl_connection_is_usable(server_th.value, sclient)\n\n File.unlink(certfile)\n end",
"def certificate\n return @cert unless @cert.nil?\n\n # Verify that the given directory exists\n unless File.directory?(resource[:cert_dir])\n raise ArgumentError, \"Directory not found for: #{resource[:cert_dir]}\"\n end\n\n cert_path = File.join(resource[:cert_dir], resource[:cert_name])\n @cert = if Pathname.new(cert_path).exist?\n file = File.read(cert_path)\n OpenSSL::X509::Certificate.new(file)\n else\n false\n end\n end",
"def certificates\n currently_owned(Transaction::IS_CERTIFICATE)\n end",
"def certificate_store # :nodoc:\n @certificate_store ||=\n begin\n # use local certificate\n certificate = OpenSSL::X509::Certificate.new @ca.ca_cert.to_pem\n\n store = OpenSSL::X509::Store.new\n store.add_cert certificate\n store\n end\n end",
"def certificates_block_untrusted_tls_certificates\n return @certificates_block_untrusted_tls_certificates\n end",
"def ca_cert_file=(value)\n raise TypeError, 'ca_cert_file must be a String or respond_to #to_s' unless value.is_a?(String) || value.respond_to?(:to_s)\n \n @ca_cert_file = value.to_s\n end",
"def load\n (Dir.entries(@path) - %w(. .. ca.crt)).each do |entry|\n certificate_path = File.join(@path, entry)\n self << CertificateDepot::Certificate.from_file(certificate_path)\n end\n end",
"def with_certs_dir\n with_repository do |repository|\n certs_dir = \"#{repository}/certificates\"\n FileUtils.mkdir_p certs_dir\n File.write(\"#{certs_dir}/test_cert.crt\", 'Hello')\n yield certs_dir\n end\n end",
"def generate_signed_cert\n unless @generated_signed_cert\n domains = %w(example.org www.example.org)\n\n key = OpenSSL::PKey::RSA.new(LetsCert::TEST::KEY_LENGTH)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = 2\n cert.issuer = OpenSSL::X509::Name.parse \"/DC=letscert/CN=CA\"\n cert.public_key = key.public_key\n cert.not_before = Time.now\n # 20 days validity\n cert.not_after = cert.not_before + 20 * 24 * 60 * 60\n ef = OpenSSL::X509::ExtensionFactory.new\n ef.subject_certificate = cert\n domains.each do |domain|\n cert.add_extension(ef.create_extension('subjectAltName',\n \"DNS:#{domain}\",\n false))\n end\n cert.sign(ca_root_key, OpenSSL::Digest::SHA256.new)\n\n @generated_signed_cert = [cert, domains]\n end\n\n @generated_signed_cert\n end",
"def check_cert\n\t\t\t\tpath = File.join('/tmp','gistto.crt')\n\t\t\t\tunless File.exists? path\n\t\t\t\t\tFileUtils.cp File.join(File.expand_path('../../../extras', __FILE__),'gistto.crt'), '/tmp'\n\t\t\t\t\tabort \"Cert File can't be copied to temp dir\" unless File.exists? path\n\t\t\t\tend\n\t\t\t\tpath\n\t\t\tend",
"def load_cacerts(cert_store)\n file = File.join(File.dirname(__FILE__), 'cacert.pem')\n add_trust_ca_to_store(cert_store, file)\n end",
"def to_x509()\n @cert\n end",
"def certs\n request :get, '/certs'\n end",
"def set_cert_file(http)\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n\n cert_file = File.join(@app_path, \"cacert.pem\")\n\n #If cert file is not found, create one.\n if not File.exist?(cert_file)\n make_ssl_cert_file(cert_file)\n end\n http.ca_file = cert_file\n http\n end",
"def ca_file\n super\n end",
"def ca_file\n super\n end",
"def load_ca_file connection\n connection.ca_file = File.dirname(__FILE__) + '/ThawtePremiumServerCA.crt'\n end",
"def ca_cert\n \n end",
"def cert_path; end",
"def cert_path; end",
"def sync\n @certificates.each do |certificate|\n certificate_path = File.join(@path, \"#{certificate.serial_number}.crt\")\n unless File.exist?(certificate_path)\n certificate.write_to(certificate_path)\n end\n end\n end",
"def ssl_certs\n requires :identity\n\n service.ssl_certs.all(identity)\n end",
"def set_ssl_ca_certificate_file(opts)\n opts = check_params(opts,[:ca_cert_files])\n super(opts)\n end",
"def ssl_cert\n OpenSSL::X509::Certificate.new(File.read(self.class.ssl_cert_path))\n rescue => e\n # :nocov:\n unless allow_missing_certs?\n Rails.logger.warn \"Could not load #{service_name} SSL cert: #{e.message}\"\n raise e if Rails.env.production?\n end\n nil\n # :nocov:\n end",
"def ca_file=(ca_file); end",
"def ca_file=(ca_file); end",
"def get_cert_details()\n $log.debug(\"Returning certificate details\")\n self.use_ssl = true\n disable_validations\n begin\n self.start do |x|\n return ResultContainer.new(true, x.peer_cert)\n end\n rescue => ex\n return ResultContainer.new(false, ex)\n end\n end",
"def ssl_certificate\n @ssl_certificate ||= OpenSSL::X509::Certificate.new <<-CERT\n-----BEGIN CERTIFICATE-----\nMIIBQjCB7aADAgECAgEAMA0GCSqGSIb3DQEBBQUAMCoxDzANBgNVBAMMBm5vYm9k\neTEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUwIBcNMTExMTAzMjEwODU5WhgPOTk5\nOTEyMzExMjU5NTlaMCoxDzANBgNVBAMMBm5vYm9keTEXMBUGCgmSJomT8ixkARkW\nB2V4YW1wbGUwWjANBgkqhkiG9w0BAQEFAANJADBGAkEA8pmEfmP0Ibir91x6pbts\n4JmmsVZd3xvD5p347EFvBCbhBW1nv1GsbCBEFlSiT1q2qvxGb5IlbrfdhdgyqdTX\nUQIBATANBgkqhkiG9w0BAQUFAANBAAAB////////////////////////////////\n//8AMCEwCQYFKw4DAhoFAAQUePiv+QrJxyjtEJNnH5pB9OTWIqA=\n-----END CERTIFICATE-----\n CERT\n end",
"def verify(name)\n unless cert = Puppet::SSL::Certificate.find(name)\n raise ArgumentError, \"Could not find a certificate for %s\" % name\n end\n store = OpenSSL::X509::Store.new\n store.add_file Puppet[:cacert]\n store.add_crl crl.content if self.crl\n store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT\n store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL|OpenSSL::X509::V_FLAG_CRL_CHECK if Puppet.settings[:certificate_revocation]\n\n unless store.verify(cert.content)\n raise CertificateVerificationError.new(store.error), store.error_string\n end\n end",
"def keycert_files; end",
"def load_x509_cert(cert_file, key_store)\n input_stream = java.io.BufferedInputStream.new(java.io.FileInputStream.new(cert_file))\n\n cert_factory = java.security.cert.CertificateFactory.get_instance('X.509')\n cert_count = 0 #The file might contain multiple certs\n\n while input_stream.available > 0\n begin\n cert = cert_factory.generate_certificate(input_stream)\n cert_count = cert_count + 1\n # load_x509_cert(cert, 'neo4j.javadriver.trustedcert.', cert_count, key_store)\n rescue java.security.cert.CertificateException => e\n\n # This happens if there is whitespace at the end of the certificate - we load one cert, and then try and load a\n # second cert, at which point we fail\n return if !e.get_cause.nil? && e.get_cause.get_message == 'Empty input'\n raise java.io.IOException.new(\"Failed to load certificate from `#{cert_file.get_absolute_path}`: #{cert_count} : #{e.get_message}\", e)\n end\n end\n end",
"def make_certs(config, verbose=false)\n FileUtils.mkdir_p config['certmaker']['outdir'], :verbose => verbose\n\n certs = CertificateSuiteGenerator.new(config['certs'], config['hostname'], config['certmaker']).certificates\n\n certs.each do |calias, ck|\n File.open(File.join(config['certmaker']['outdir'],calias+\"cert.pem\"),\"wb\") { |f| f.write ck[:cert] }\n File.open(File.join(config['certmaker']['outdir'],calias+\"key.pem\"),\"wb\") { |f| f.write ck[:key] }\n end\n\n end",
"def cert_store; end",
"def cert_store; end",
"def default_ca_file; end",
"def truststore\n RubyAem::Resources::Truststore.new(@client)\n end",
"def set_ca_certs (ca_file)\n return fail_response(13001, \"NaServer::set_ca_certs: missing CA certificate file\") unless ca_file\n @ca_file = ca_file\n end",
"def certificates_block_untrusted_tls_certificates=(value)\n @certificates_block_untrusted_tls_certificates = value\n end",
"def certificate_chain\n data.certificate_chain\n end",
"def certificate_is_trusted?\n root_certificate =\n case @bank\n when :nordea\n NORDEA_ROOT_CERTIFICATE\n when :danske\n DANSKE_ROOT_CERTIFICATE\n end\n\n verify_certificate_against_root_certificate(certificate, root_certificate)\n end",
"def ca_file_location\n ::Ohai::Config[:ca_file]\n end",
"def ca_file_location\n ::Ohai::Config[:ca_file]\n end",
"def set_certificate_file(opts)\n opts = check_params(opts,[:certs])\n super(opts)\n end",
"def compile\n puts '-----> Creating TrustStore with container certificates'\n\n resolved_certificates = certificates\n with_timing(caption(resolved_certificates)) do\n unless use_jvm_trust_store?\n FileUtils.mkdir_p File.join(@app_dir, NEW_TRUST_STORE_DIRECTORY)\n end\n resolved_certificates.each_with_index { |certificate, index| add_certificate certificate, index }\n end\n end",
"def add_roots()\n puts \"Adding root certs to #{@root_cert_file_name}\" if @verbose\n num_root_certs = 0\n Dir.foreach(CertTools.root_certs_dir) do |f|\n next if f[0].chr == \".\"\n #puts \"Processing root #{f}\" if @verbose\n full_root_path = File.join(CertTools.root_certs_dir, f)\n if f == \"AppleDEVID.cer\" \n puts \" sipping intermediate #{f} for trust\" if @verbose\n cmd_str = CertTools.security_tool_path + \" -q add-certificates -k \" + Utilities.quote_str(@root_cert_kc_path) + \" \" + \n Utilities.quote_str(full_root_path)\n\n `#{cmd_str}`\n Utilities.bail(\"Security tool add-certificates returned an error for #{full_root_path}\") if $? != 0\n else\n cmd_str = CertTools.security_tool_path\n cmd_str += \" -q add-trusted-cert -i \"\n cmd_str += Utilities.quote_str(@setting_file_path)\n cmd_str += \" -o \"\n cmd_str += Utilities.quote_str(@setting_file_path)\n cmd_str += \" -k \"\n cmd_str += Utilities.quote_str(@root_cert_kc_path)\n cmd_str += \" \"\n cmd_str += Utilities.quote_str(full_root_path)\n cmd_result = `#{cmd_str}`\n Utilities.bail(\"Security tool add-trusted-cer returned an error for #{full_root_path}\") if $? != 0\n new_num_certs = get_num_root_certs\n if new_num_certs <= num_root_certs then\n puts \"Root #{f} was not added! result = #{cmd_result.to_s}\"\n puts cmd_str\n end\n num_root_certs = new_num_certs\n end\n end\n true\n end",
"def ensure_ca_certificates\n final_state = run_machine(NeedCACerts.new, NeedKey)\n final_state.ssl_context\n end",
"def certificate_list\n return @certificate_list\n end",
"def revoked_certs()\n process_certs(\"Explicitly distrusting certs\", CertTools.revoked_certs_dir)\n end",
"def create_setting_file()\n puts \"Creating empty Setting file at #{@setting_file_path}\" if @verbose\n FileUtils.rm_rf(@setting_file_path) if FileTest.exists? @setting_file_path\n cmd_str = CertTools.security_tool_path + \" add-trusted-cert -o \" + Utilities.quote_str(@setting_file_path)\n `#{cmd_str}`\n $?\n end",
"def list\n cert_list(certstore_handler)\n end",
"def certificate_list\n certificates = self.certs #[0].certificate.name\n list = certificates.collect! {|x| x.certificate.name + \"; \" }\n list.join()\n end",
"def verify_cert(ca_root_bundle = CA_ROOT_BUNDLE)\n $log.debug(\"Verifying certificate\")\n ca_root_bundle = CA_ROOT_BUNDLE unless(ca_root_bundle)\n unless (File.exist?(ca_root_bundle) && File.file?(ca_root_bundle))\n return ResultContainer.new(false, \"Invalid certificate file #{ca_root_bundle}\")\n end\n\n self.use_ssl = true\n enable_validations\n self.ca_file = ca_root_bundle\n begin\n self.start do |x|\n x.peer_cert\n return ResultContainer.new(true, x.peer_cert)\n end\n rescue => ex\n return ResultContainer.new(false, ex)\n end\n end",
"def validate\n now = Time.now\n\n # Check start time and end time of certificates\n @cert_chain.each do |cert|\n if cert.not_before > now || cert.not_after < now\n raise \"Certificate not valid. Current time is #{now.localtime}\"\n end\n end\n\n begin\n # Validate the proxy certifcates\n signee = @cert_chain[0]\n\n check_crl(signee)\n\n @cert_chain[1..-1].each do |cert|\n if !((signee.issuer.to_s == cert.subject.to_s) &&\n (signee.verify(cert.public_key)))\n raise \"#{signee.subject} with issuer #{signee.issuer} \" \\\n \"was not verified by #{cert.subject}\"\n end\n\n signee = cert\n end\n\n # Validate the End Entity certificate\n if !@options[:ca_dir]\n raise \"No certifcate authority directory was specified.\"\n end\n\n begin\n ca_hash = signee.issuer.hash.to_s(16)\n ca_path = @options[:ca_dir] + '/' + ca_hash + '.0'\n\n ca_cert = OpenSSL::X509::Certificate.new(File.read(ca_path))\n\n if !((signee.issuer.to_s == ca_cert.subject.to_s) &&\n (signee.verify(ca_cert.public_key)))\n raise \"#{signee.subject} with issuer #{signee.issuer} \" \\\n \"was not verified by #{ca_cert.subject}\"\n end\n\n signee = ca_cert\n end while ca_cert.subject.to_s != ca_cert.issuer.to_s\n rescue\n raise\n end\n end",
"def convert_certs_list_to_X509(certs_list)\n x509_certs_list = []\n certs_list.each do |cert|\n x509_certs_list.push OpenSSL::X509::Certificate.new(cert)\n end\n x509_certs_list\n end",
"def cert_chain(raw)\n rawchain = split_chain(raw)\n rawchain.map { |rawcert| OpenSSL::X509::Certificate.new(rawcert) }\n end",
"def read(file_path, password)\n truststore_raw = File.read file_path\n OpenSSL::PKCS12.new(truststore_raw, password)\n end",
"def install_ssl_ca(logger, options)\n ca_file = options[:puppetdb_ssl_ca]\n raise Errno::ENOENT, 'SSL CA file does not exist' unless File.file?(ca_file)\n ca_content = File.read(ca_file)\n ca_outfile = File.join(@tempdir, 'var', 'ssl', 'certs', 'ca.pem')\n File.open(ca_outfile, 'w') { |f| f.write(ca_content) }\n logger.debug \"Installed CA certificate in #{ca_outfile}\"\n end",
"def ca_cert_string\n @ca_cert_string ||= begin\n vcap_services[vcap_services.keys.first].first['credentials']['cacrt']\n end\n end",
"def process_certs(message, dir)\n puts message if @verbose\n Dir.foreach(dir) do |f|\n next if f[0].chr == \".\"\n full_path = File.join(dir, f)\n #puts \"Processing #{f}\" if @verbose\n cmd_str = CertTools.security_tool_path\n #cmd_str += \" -q add-trusted-cert -i \"\n cmd_str += \" add-trusted-cert -i \"\n cmd_str += Utilities.quote_str(@setting_file_path)\n cmd_str += \" -o \"\n cmd_str += Utilities.quote_str(@setting_file_path)\n cmd_str += \" -k \"\n cmd_str += Utilities.quote_str(@temp_kc_path)\n cmd_str += \" -r deny \"\n cmd_str += Utilities.quote_str(full_path)\n `#{cmd_str}`\n Utilities.bail(\"Security add-trusted-cert returned an error for #{full_path}\") if $? != 0\n end\n end",
"def test_storeAndSign\n ca = nil\n caserv = nil\n\n # make our CA server\n assert_nothing_raised {\n caserv = Puppet::Network::Handler.ca.new(:autosign => false)\n }\n\n # retrieve the actual ca object\n assert_nothing_raised {\n ca = caserv.ca\n }\n\n # make our test cert again\n key = nil\n csr = nil\n cert = nil\n hostname = \"test.domain.com\"\n assert_nothing_raised {\n cert = Puppet::SSLCertificates::Certificate.new(\n :name => \"anothertest.domain.com\"\n )\n }\n # and the CSR\n assert_nothing_raised {\n cert.mkcsr\n }\n\n # retrieve them\n certtext = nil\n assert_nothing_raised {\n certtext, cacerttext = caserv.getcert(\n cert.csr.to_s, \"test.reductivelabs.com\", \"127.0.0.1\"\n )\n }\n\n # verify we got nothing back, since autosign is off\n assert_equal(\"\", certtext)\n\n # now sign it manually, with the CA object\n x509 = nil\n assert_nothing_raised {\n x509, cacert = ca.sign(cert.csr)\n }\n\n # and write it out\n cert.cert = x509\n assert_nothing_raised {\n cert.write\n }\n\n assert(File.exists?(cert.certfile))\n\n # now get them again, and verify that we actually get them\n newtext = nil\n assert_nothing_raised {\n newtext, cacerttext = caserv.getcert(cert.csr.to_s)\n }\n\n assert(newtext)\n assert_nothing_raised {\n OpenSSL::X509::Certificate.new(newtext)\n }\n\n # Now verify that we can clean a given host's certs\n assert_nothing_raised {\n ca.clean(\"anothertest.domain.com\")\n }\n\n assert(!File.exists?(cert.certfile), \"Cert still exists after clean\")\n end",
"def collect_cert_info\n # Redirect keytool check error to /dev/null\n os_has_keytool = system('keytool 2>/dev/null')\n raise 'keytool dependency not satisfied. Make sure that JAVA keytool utility is installed' unless os_has_keytool\n cert_info = {}\n certificate_raw = `keytool -printcert -rfc -jarfile #{@apk_path.shellescape}`\n certificate_content_regexp = /(-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----)/m\n matched_data = certificate_content_regexp.match(certificate_raw)\n if matched_data\n certificate_content = matched_data.captures[0]\n cert_info = {\n issuer_raw: nil,\n cn: nil,\n ou: nil,\n o: nil,\n st: nil,\n l: nil,\n c: nil,\n creation_date: nil,\n expiration_date: nil\n }\n cert_extract_dates(certificate_content, cert_info)\n cert_extract_issuer(certificate_content, cert_info)\n else\n puts 'Failed to find CERT.RSA file in APK'\n end\n cert_info\n end",
"def x509_get_crl_path(caname)\n item = x509_get_crl(caname)\n return ::File.join(node['x509']['tls_root'], 'certs', \"#{item['hash']}.r0\")\nend",
"def store\n\t\t\t@store ||= OpenSSL::X509::Store.new.tap do |store|\n\t\t\t\tstore.add_cert(self.certificate)\n\t\t\tend\n\t\tend",
"def cli_cert()\n\t\tENV['CLI_FILE'] || \"client.crt\" # The client cert File\n end"
] | [
"0.6740507",
"0.6589355",
"0.6229071",
"0.61627907",
"0.615404",
"0.6089785",
"0.59886664",
"0.597287",
"0.5970318",
"0.59263206",
"0.5847469",
"0.57526463",
"0.5692456",
"0.56913406",
"0.56660044",
"0.5619496",
"0.5584074",
"0.55695546",
"0.55649084",
"0.5553198",
"0.55473244",
"0.55367297",
"0.55367297",
"0.5466284",
"0.54236764",
"0.54144686",
"0.54133755",
"0.5386145",
"0.53717136",
"0.53630567",
"0.5356625",
"0.53545356",
"0.53429264",
"0.532708",
"0.53263605",
"0.5314674",
"0.5293431",
"0.528996",
"0.52590686",
"0.52552813",
"0.52543706",
"0.5245325",
"0.523163",
"0.5225242",
"0.5224425",
"0.5153369",
"0.5114045",
"0.509694",
"0.5072856",
"0.5066661",
"0.50442237",
"0.50442237",
"0.50396585",
"0.50198644",
"0.50020295",
"0.50020295",
"0.5001414",
"0.49964622",
"0.49957874",
"0.49844146",
"0.49620306",
"0.49620306",
"0.49422777",
"0.49269676",
"0.49233386",
"0.49173874",
"0.4916861",
"0.49148378",
"0.4881116",
"0.4881116",
"0.48545167",
"0.4853299",
"0.4853067",
"0.48488006",
"0.48429513",
"0.48398226",
"0.48351136",
"0.48351136",
"0.483399",
"0.4832288",
"0.48269027",
"0.48245892",
"0.48192838",
"0.48001307",
"0.47892877",
"0.47731265",
"0.47522947",
"0.47450525",
"0.4734789",
"0.4734508",
"0.47240645",
"0.47130904",
"0.4711509",
"0.47114307",
"0.4709264",
"0.47071305",
"0.4703123",
"0.46810028",
"0.46619675",
"0.46532747"
] | 0.7190446 | 0 |
Returns true if unit is available, otherwise false. The unit is available if it is not occupied by a tenant. | def available?
return @tenant == nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available?\n if tenant == false && @units != @number\n return true\n else \n return false\n end\n end",
"def occupied?\n not @unit.nil?\n end",
"def unit?\n [email protected]?\n end",
"def units?\n return units.any?\n end",
"def available?\n status == :available\n end",
"def available?\n true\n end",
"def available?\n if @available_rooms.length > 0\n return true\n end\n end",
"def is_available?\n return @status == :AVAILABLE\n end",
"def available?\n self.active == true and self.quantity_available > 0\n end",
"def unit?\n role?('unit')\n end",
"def is_available?\n return self.available_inventory > 0\n end",
"def unit?(unit)\n @units.include?(unit)\n end",
"def is_available?\n count_available > 0\n end",
"def available?\n Holdings::Status::Available.new(@item).available?\n end",
"def available?\n true\n end",
"def available?\n false\n end",
"def is_available\n return @is_available\n end",
"def currently_available?\n #Time.zone.now < available_until\n true\n end",
"def available?\n @dao.active?\n end",
"def available?\n Holdings::Status::Available.new(@callnumber).available?\n end",
"def has_vacancy?\n @rooms.values.any? { |room| room.available_space() > 0 }\n end",
"def available?\n return false\n end",
"def available?\n AvailableResponse.new(request(:get, '/information')).success?\n end",
"def next_unit?\n [email protected]?\n end",
"def available?\n @subnet.state == 'available'\n end",
"def is_units?(); @type == GRT_UNITS; end",
"def available?\n self.available_count > 0\n end",
"def available?()\n #This is a stub, used for indexing\n end",
"def full?\n\t\t\t\t@available <= 0\n\t\t\tend",
"def installed?\n source_api.number_of_units.positive? && positive_availability?\n end",
"def unit?\n !data[\"street_address\"].nil?\n end",
"def available?\n return false if deleted?\n return false if karma < app_settings(:post_karma_barrier)\n true\n end",
"def tenanted?\n @roomer_scope == :tenanted\n end",
"def in_unit?(unit)\n unit = Unit.find(unit) if unit.is_a?(Numeric)\n units.include?(unit)\n end",
"def available?\n @available_at <= Time.now && !rented?\n end",
"def unit_validity(desired_unit)\n return Unitwise.valid?(desired_unit)\nend",
"def available?\n @available && connected?\n end",
"def available?\n session_bus = DBus::SessionBus.instance\n session_bus.service('org.a11y.Bus').exists?\n end",
"def available?\n @dbi.db_instance_status == 'available'\n end",
"def available?\n @dbi.db_instance_status == 'available'\n end",
"def available?\n idle.any?\n end",
"def rooms_available?\n return @available_rooms.length > 0\n end",
"def agent_available?\n @free_agents.count > 0\n end",
"def is_derived_unit?\n !is_base_unit?\n end",
"def available?\n vehicle.nil?\n end",
"def is_available?\n stock > 0\n end",
"def constructs_units?\n each_constructable_item do |item, base, name|\n return true if base == \"unit\"\n end\n\n false\n end",
"def usable?\n false\n end",
"def destroyable?\n return false unless units.any?\n end",
"def has_free_trial?\n return (trial and trial.free?)\n end",
"def data_available?\n true\n end",
"def available?\n self.in_stock? || self.backorderable?\n end",
"def available?\n self.available_product_supplies.length > 0 and not self.delete?\n end",
"def machine_avail?\n\t\tmachine = self.machines.find(:first, :conditions =>\n\t\t\t[\"installed = ? and cid = ?\", false, 'none'])\n\t\tif machine\n\t\t\treturn machine\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def locally_available?(request)\n UmlautBorrowDirect.locally_available? request\n end",
"def already_used?\n p \"Checking already used\"\n vehicle.present? and state == 1\n end",
"def available?\n @vpc.state == 'available'\n end",
"def destroyable?\n return false unless units.any?\n end",
"def available_in?(region)\n available_regions.include?(region)\n end",
"def full?\n slots_available.zero?\n end",
"def valid?\n return false if @unit_id.nil?\n return false if @archived.nil?\n return false if @type.nil?\n true\n end",
"def completeable?\n if self.measurements.empty?\n !self.treatment_plan.first_session?(self) and !self.treatment_plan.last_session?(self)\n else\n # standard validation has already made sure the measurement set has the required measurement\n true \n end\n end",
"def ready?\n return false unless @status =~ /down/i\n volumes.each do |volume|\n return false if volume.status =~ /locked/i\n end\n true\n end",
"def grain? = unit == 'grain'",
"def ready_to_bill?\n status == READY\n end",
"def isReady?\n self.plan_parts.each do |part|\n if !part.isReady?\n return false\n end\n end\n return true\n end",
"def complete?\n complete = true\n\n devices.each do |device|\n if !device.complete?\n complete = false\n break\n end\n end\n\n return complete\n end",
"def ready?\n q = get_connection(\"neutron\")\n \n network = q.networks.select {|n| n.name == self.network}\n if network.empty?\n return false, \"Network #{self.network} does not exist on the tenant.\"\n end\n\n types = Array.new\n self.instances.each do |inst|\n types << inst.types\n end\n types.flatten!\n duplicates = types.select{|t| types.count(t) > 1}\n if duplicates.include?(\"named\")\n return false, \"Named is a component on multiple instances\" # If named is included more than once\n end\n if duplicates.include?(\"datastore\") && duplicates.count(\"datastore\") < 3\n return false, \"There are 2 mongodb hosts, there must be either one or more than two.\"\n end\n if self.valid_gear_sizes == []\n return false, \"No gear sizes are defined\"\n end\n limits = self.limits\n if limits[:max_instances] < self.instances.count\n return false, \"There are more #{self.instances.count - limits[:max_instances]} more instances than the project limit of \\\"#{limits[:max_instances]}\\\" allows.\"\n end\n types.uniq!\n types.compact!\n if types.sort == [\"named\", \"broker\", \"datastore\", \"activemq\", \"node\"].sort\n true\n else\n return false, \"All necessary components are not included: \" + types.join(\",\")\n end\n end",
"def available?\n in_stock? || backorderable?\n end",
"def provisional?\n registered? && @provisional\n end",
"def room_available\n !self.rooms.where(available: true).blank?\n end",
"def is_usable\n return @is_usable\n end",
"def available?\n check_elements_for_compliance { |e| !e.available? }\n end",
"def ready?\n q = get_connection(\"network\")\n \n network = q.networks.select {|n| n.name == self.network}\n if network.empty?\n return false, \"Network #{self.network} does not exist on the tenant.\"\n end\n\n types = Array.new\n self.instances.each do |inst|\n types << inst.types\n end\n types.flatten!\n duplicates = types.select{|t| types.count(t) > 1}\n if duplicates.include?(\"named\")\n return false, \"Named is a component on multiple instances\" # If named is included more than once\n end\n if duplicates.include?(\"datastore\") && duplicates.count(\"datastore\") < 3\n return false, \"There are 2 mongodb hosts, there must be either one or more than two.\"\n end\n if self.valid_gear_sizes == []\n return false, \"No gear sizes are defined\"\n end\n limits = self.limits\n if limits[:max_instances] < self.instances.count\n return false, \"There are more #{self.instances.count - limits[:max_instances]} more instances than the project limit of \\\"#{limits[:max_instances]}\\\" allows.\"\n end\n types.uniq!\n types.compact!\n if types.sort == [\"named\", \"broker\", \"datastore\", \"activemq\", \"node\"].sort\n true\n else\n return false, \"All necessary components are not included: \" + types.join(\",\")\n end\n end",
"def available\r\n @available\r\n end",
"def available?(division)\n get_state(division).eql? 'closed'\n end",
"def healthy?\n %w(run sleep).include?(@transmitter.status)\n end",
"def tranch_available?\n current_tranch_open? and previous_tranch_all_sold_out_or_operated?\n end",
"def available?\n self.state.eql? \"closed\"\n end",
"def alive?\n\t\t\[email protected]? || @battery > 0\n\t\tend",
"def unavailable?\n self.type == :unavailable\n end",
"def positive_availability?\n target_api.availability.positive?\n end",
"def destroyable?\n if self.units.size > 0\n return false\n end\n return true\n end",
"def is_available=(value)\n @is_available = value\n end",
"def active_subscription?\n managers.map(&:subscribed?).include?(true) || managers.map(&:active_trial?).include?(true) ? true : false\n end",
"def free_agent?\n type == \"free_agent\"\n end",
"def available?\n return true unless coliding_locks.any?\n end",
"def use?\n inclusively { enabled? && needed? }\n end",
"def is_available\n\t\tself.stock_qty > 0\n\tend",
"def returnable?\n AVAILABLE == status\n end",
"def unit_movable?\n return false if @tb_unit.nil?\n @tb_unit.can_move?\n end",
"def server_available?\n !in_latency_window.empty?\n end",
"def ready_to_approve?\n status = self.units.map(&:unit_status) & ['condition', 'copyright', 'unapproved']\n return status.empty?\n end",
"def loaded?\n Unit.units.has_key? @label\n end",
"def all_members_available?\n @rs.members.each do |member|\n machine = @machine.env.machine(member[:host], @machine.provider_name)\n return false if !member_available?(machine)\n end\n true\n end",
"def available_space?(location)\n\n\tend",
"def tba?\n (!self.available_on.nil? && self.available_on > self.class.upcoming_on)\n end",
"def can_afford?(name)\n Era::TBUnit.makable?(name)\n end",
"def ready?\n status == \"RUNNING\"\n end",
"def full?\n @tenants.length == @num_beds\n end"
] | [
"0.8500873",
"0.72543454",
"0.7066293",
"0.68368345",
"0.68214405",
"0.67758125",
"0.66916597",
"0.6688044",
"0.66567636",
"0.66516143",
"0.66198903",
"0.6594279",
"0.656273",
"0.65550965",
"0.65503156",
"0.64900506",
"0.64318836",
"0.64191425",
"0.6355586",
"0.63407695",
"0.6338376",
"0.63192517",
"0.6279442",
"0.62534475",
"0.62426805",
"0.6242018",
"0.62297994",
"0.6229522",
"0.6211045",
"0.6198113",
"0.6195778",
"0.6194357",
"0.61719555",
"0.6158876",
"0.6147485",
"0.61427754",
"0.612114",
"0.611648",
"0.61126906",
"0.61126906",
"0.61082846",
"0.6104544",
"0.6096867",
"0.6086049",
"0.6069664",
"0.6058674",
"0.6056963",
"0.60527796",
"0.60279274",
"0.6027015",
"0.6017058",
"0.6001142",
"0.59922165",
"0.5991577",
"0.5975067",
"0.5962813",
"0.5954536",
"0.595152",
"0.5944718",
"0.5941093",
"0.59337544",
"0.59284884",
"0.59210944",
"0.5901758",
"0.58959615",
"0.58909917",
"0.5875333",
"0.58626616",
"0.5856232",
"0.5850455",
"0.5835778",
"0.58280474",
"0.58257866",
"0.5821396",
"0.58151674",
"0.5792853",
"0.5791939",
"0.57879984",
"0.5787327",
"0.57872164",
"0.57865524",
"0.5773583",
"0.57598865",
"0.5746899",
"0.5743724",
"0.5743283",
"0.57376873",
"0.5735045",
"0.5713875",
"0.57065684",
"0.57058525",
"0.5686179",
"0.56838435",
"0.5676376",
"0.566923",
"0.56657696",
"0.56647617",
"0.56620264",
"0.5643622",
"0.56404227"
] | 0.73926 | 1 |
Creates a new parser for N3 (or Turtle). | def initialize(n3_str, uri=nil)
@uri = Addressable::URI.parse(uri) unless uri.nil?
parser = N3GrammerParser.new
document = parser.parse(n3_str)
if document
@graph = Graph.new
process_directives(document)
process_statements(document)
else
parser.terminal_failures.each do |tf|
puts "Expected #{tf.expected_string.inspect} (#{tf.index})- '#{n3_str[tf.index,10].inspect}'"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_parser(grammar_paths)\n @search_parser ||= grammar_paths.inject(nil) do |parser,lucene_grammar|\n begin\n break parser unless parser.nil?\n # don't instantiate custom nodes\n Treetop.load_from_string(\n IO.read(lucene_grammar).gsub(/<[^>]+>/, ''))\n LuceneParser.new\n rescue\n # silently swallow and try the next grammar\n end\n end\n end",
"def create_parser(grammar_paths)\n @search_parser ||=\n grammar_paths.inject(nil) do |parser, lucene_grammar|\n begin\n break parser unless parser.nil?\n # Don't instantiate custom nodes\n Treetop.load_from_string(\n IO.read(lucene_grammar).gsub(/<[^>]+>/, ''))\n LuceneParser.new\n rescue\n # Silently swallow and try the next grammar\n end\n end\n end",
"def initialize parser\n @parser = parser\n end",
"def parser\n Parser.new(self, :mode=>mode)\n end",
"def parser; end",
"def parser; end",
"def parser; end",
"def parser; end",
"def initialize\n @parser = Grammar::RootParser.new\n end",
"def initialize\n @parser = Grammar::RootParser.new\n end",
"def parser\n @parser ||= Parser.new(self)\n end",
"def parser\n @parser ||= Parser.new(self)\n end",
"def parse(body)\n new Nokogiri body\n end",
"def n(type, children = [])\n Parser::AST::Node.new(type, children)\n end",
"def n(type, children = [])\n Parser::AST::Node.new(type, children)\n end",
"def initialize(opts={})\n if opts[:parser]\n @parser = opts[:parser]\n elsif opts[:grammar_file] and opts[:grammar_class]\n if @@parsers[opts[:grammar_class]]\n # already compiled the grammar, just use it\n @parser = @@parsers[opts[:grammar_class]]\n else\n # load the grammar\n Treetop.load(opts[:grammar_file])\n cls = eval(opts[:grammar_class])\n @parser = cls.new\n end\n else\n raise ArgumentError.new(\"Specify either :parser or :grammar_file and :grammar_class\")\n end\n end",
"def parser\n @parser ||= Sawtooth::Parser.new(:rules => self.rules)\n end",
"def pluggable_parser; end",
"def parser(name = T.unsafe(nil)); end",
"def new!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 31 )\n\n type = NEW\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 334:7: 'new'\n match( \"new\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 31 )\n\n end",
"def parser (tokens)\n\n\t# create the new, concrete syntax tree\n\t# making it global to reduce headaches (hopefully XD )\n\t$cst = ConcreteSyntaxTree.new\n\t\n\t# define some other useful, global vars\n\t$tokens = tokens\n\t$index = 0\n\t\n\t# have to ask alan about this\n\tif $tokens.length <= 1\n\t\tputs \"Insufficient code present! There is only #{$tokens.length} token here!\"\n\t\texit\n\tend\t\n\t\n\t\n\t# Engine to full burn!!!\n\t#parse(\"Program\", program)\n\tprogram\n\t\n\t\n\tbegin\n\t\tif $tokens.length != $index\n\t\t\traise EOFDetectionError.new(\"early\", $tokens[$index - 1].lineno, $tokens[$index - 1].pos)\n\t\tend\n\trescue EOFDetectionError\n\tend\n\t\t\n\t\n\t\n\treturn $cst\nend",
"def parser\n @parser ||= Parser.new(self)\n end",
"def new!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 62 )\n\n type = NEW\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 183:7: 'new'\n match( \"new\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 62 )\n\n end",
"def initialize\n compiler = Treetop::Compiler::GrammarCompiler.new\n @where = File.expand_path(File.dirname(__FILE__))\n grammar = File.join(@where, 'seqpar.treetop')\n output = File.join(@where, 'seqpar.rb')\n compiler.compile(grammar, output)\n load output\n File.delete(output)\n @parser = SeqParParser.new\n end",
"def build_parser( descriptor, file = nil )\n return RCC::Scanner::Interpreter::Parser.new( @parser_plan, open_source(descriptor, file) )\n end",
"def build_parser( descriptor, file = nil )\n return RCC::Scanner::Interpreter::Parser.new( @parser_plan, open_source(descriptor, file) )\n end",
"def build_parser\n code = ''\n\n %w[opal/ruby/nodes opal/ruby/parser opal/ruby/ruby_parser].each do |src|\n full = File.join OPAL_PATH, 'opal_lib', src + '.rb'\n compiled = compile_source full\n code += \"opal.register('#{src}.rb', #{compiled});\"\n end\n\n code += build_stdlib 'racc/parser.rb', 'strscan.rb', 'dev.rb'\n code += \"opal.require('dev');\"\n\n code\n end",
"def to_parser\n parser = Racc::GrammarFileParser.new\n result = parser.parse to_yacc\n nfa = Racc::States.new(result.grammar).nfa\n parsegen = Racc::ParserFileGenerator.new nfa.dfa, result.params\n parser_src = parsegen.generate_parser\n\n if $DEBUG\n puts \"############# PARSED GRAMMAR\"\n puts parser_src\n puts \"############# END PARSED GRAMMAR\"\n end\n\n Module.new { class_eval parser_src }.const_get('GeneratedGrammar')\n end",
"def parse_new_node(node, options = {})\n content = \"\"\n parser = nil\n\n case node.type\n # Any function call\n when :send\n parser = CallParser.new(node, options)\n\n # Function args\n when :args\n parser = ArgsParser.new(node)\n\n # Class declaration\n when :class\n parser = ClassParser.new(node)\n\n # Assign var\n when :lvasgn, :ivasgn, :cvasgn\n parser = VarParser.new(node, options)\n\n when :lvar, :ivar\n return unless node.children.length > 0\n return node.children[0].to_s\n\n # Function declaration\n when :def, :defs\n parser = FunctionParser.new(node, options)\n\n # Basic types\n when :str, :int, :float, :true, :false, :nil\n parser = BaseTypeParser.new(node, node.type)\n\n # Blocks\n when :begin\n node.children.each do |child|\n parser = MasterParser.new\n content << parser.parse_new_node(child, options).to_s << \"\\n\"\n end\n\n return content\n\n # Else, error\n else\n raise \"Unsupported type \" + node.type.to_s\n end\n\n parser.parse\n parser\n end",
"def parser( &block )\n nested_class( 'Parser', Yacl::Define::Cli::Parser, &block )\n end",
"def initialize(grammar)\n tokens = grammar.split(/[ \\t]+/)\n has_comments = tokens.index('#')\n if has_comments\n # remove all elements after comments position\n tokens = tokens.each_with_index.each_with_object([]) do |(value, index), result|\n result << value if index < has_comments\n result\n end\n end\n # we should have a well formed grammar\n self.tree = GrammarTree.new(tokens)\n end",
"def parse(text, options = T.unsafe(nil)); end",
"def initialize(paren_start, element = nil, paren_end = nil)\n @options = @@parse_options\n @paren_type = paren_start[0]\n @offset = paren_start[1]\n if paren_end\n @length = (paren_end[1] - paren_start[1]) + paren_end[2]\n else\n @length = paren_start[2]\n end\n \n # delete head '(', '?', and tail \")\"\n @prefix = @paren_type.sub(/^\\(\\??/, \"\")\n if @prefix.index(\"(\") != 0\n @prefix.sub!(/\\)$/, \"\")\n end\n \n @name = get_name(@prefix)\n @condition = nil # set at generating json\n @refer_name = nil\n if element\n TstLog(\"Parenthesis: name:#{@name}, offset:#{@offset}, element:#{element}\")\n @element = element\n @type_name = \"LEX_PAREN\"\n else\n TstLog(\"Parenthesis: name:#{@name}, offset:#{@offset}, element: \\\"\\\"\")\n @element = TEmpty.new\n @type_name = \"LEX_OPTION_PAREN\" # (?x-i) etc.\n end\n @generated_string = []\n @nest = 0\n end",
"def ruby_bnf_grammar_parser\r\n parser = nil\r\n time_and_puts(\"Generating parser for Ruby BNF grammar\") do\r\n begin\r\n parser = Parse.generate_parser <<-'EOG'\r\nGrammar BnfGrammars\r\n Tokens\r\n Blank = /\\s+/ [:Skip]\r\n EpsilonComment = /\\/\\* none \\*\\//\r\n Nonterm = /[a-z][a-z_\\d]*/ \r\n Keyword = /k\\w+/\r\n Token = /t[A-Z_\\d]+/\r\n String = /'[^']*'/\r\n Productions\r\n BnfGrammar -> Prod+ [: productions]\r\n Prod -> Nonterm ':' list(Alt, '|') [: nonterm,_,alts]\r\n Alt -> Element* [: elements]\r\n Element -> (Nonterm | Keyword | Token | \r\n String | EpsilonComment) [^]\r\nEOG\r\n rescue Exception => e\r\n puts e.inspect\r\n exit -1\r\n end\r\n end\r\n parser\r\nend",
"def initialize(parse_tree)\n @parse_tree = parse_tree\n end",
"def create_parser(options)\n parser = OptionParser.new\n\n parser.on \"-o DIR\", \"--output-dir DIR\", \"Specify custom output directory\" do |value|\n options.custom_output_dir_set = true\n options.custom_output_dir_value = value\n end\n parser.on \"-s FILENAME\", \"--single-file FILENAME\", \"Output all quotes in a single file\" do |name|\n options.single_file = true\n options.single_file_name = name\n end\n parser.on \"-l\", \"--list-categories\", \"List all available categories\" do\n options.list_only = true\n end\n\n parser.on \"-h\", \"--help\", \"Print this help text\" do\n puts parser\n exit\n end\n\n parser.on \"-v\", \"--version\", \"Print program version\" do\n puts \"gnomikologikon-fortune #{Gnomika::Ruby::VERSION}\"\n exit\n end\n end",
"def initialize(node = Array.new, children = Array.new)\n @children = children\n @terminal = false # ( not node.nil? ) and children.empty?\n @node = (node.kind_of? String) ? node.tr_tokenize : node\n return self\n end",
"def parse(params) new(params).parse end",
"def parse text\n raise \"No parser defined for #{self.class}\"\n end",
"def parse\n #return a cached version if it exists\n return @nexml if @nexml\n\n #start at the root element\n skip_leader\n\n #start with a new Nexml object\n version = attribute( 'version' )\n generator = attribute( 'generator' )\n @nexml = NeXML::Nexml.new( version, generator )\n\n #perhaps a namespace api as well\n \n #start parsing other elements\n while next_node\n case local_name\n when \"otus\"\n @nexml.add_otus( parse_otus )\n when \"trees\"\n @nexml.add_trees( parse_trees )\n when \"characters\"\n @nexml.add_characters( parse_characters )\n end\n end\n\n #close the libxml parser object\n #close\n\n #return the Nexml object\n @nexml\n end",
"def compile_parser(base, grammar_or_parser, opts={})\r\n compile(Class.new(base), grammar_or_parser, opts)\r\n end",
"def parse(ntxtObj)\n\n # If ntxtObj isn't an Ntxt, create it as one.\n ( ntxtObj = Ntxt.new(ntxtObj) ) unless ntxtObj.is_a?( Ntxt )\n\n rootBlock = Block.new(ntxtObj)\n\n @lines = ntxtObj.text.split(\"\\n\")\n @currentLine = 0\n @currentOffset = 0\n @currentBlock = rootBlock\n\n parseLines()\n\n rootBlock\n end",
"def new_parser_with_data\n\tdoc = load_sample_xml\n\tparser = GreenButton::Parser.new(doc)\nend",
"def initialize\n utility_parsers\n operator_parsers\n integer_parsers\n term_and_expr_parsers\n end",
"def parse\n @stack.push @current_level\n program_node = program Sets::EMPTY_SET \n \n SyntaxTree.new program_node\n end",
"def parser=(_arg0); end",
"def parse(x)\n grammar = interpreter.parser.grammar\n parse_with(grammar, x)\n end",
"def to_PLParser(startSym)\n\n thePLP = TextRect.new\n\n @ntIndex.each do |nt, s|\n\n theNT = TextRect.new(\"#{nt.name} ::= \")\n before = ' '\n\n s[:rules].each do |i|\n rhs = @ruleTable[i][:rule].rhs\n rhs.each { |sym| before << sym.name << ' ' }\n theNT.below!(before)\n before = ' | '\n end\n\n theNT.below!(' ;')\n thePLP.below!(theNT)\n\n end\n\n thePLP.below!('&G')\n\n end",
"def parse; end",
"def parse; end",
"def parse; end",
"def parse_from_text(text)\n parser = TextParser.new\n parser.parse_text(text, self)\n return self\n end",
"def initialize(text=nil)\n @text = text\n @type=nil\n @copy=nil\n @target=nil\n parse unless @text.nil?\n end",
"def to_grammar\n raise NotImplementedError\n end",
"def grammar_def\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 1)\n return_value = GrammarDefReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n g = nil\n __DOC_COMMENT1__ = nil\n string_literal2 = nil\n string_literal3 = nil\n string_literal4 = nil\n char_literal6 = nil\n __EOF12__ = nil\n id5 = nil\n options_spec7 = nil\n tokens_spec8 = nil\n attr_scope9 = nil\n action10 = nil\n rule11 = nil\n\n tree_for_g = nil\n tree_for_DOC_COMMENT1 = nil\n tree_for_string_literal2 = nil\n tree_for_string_literal3 = nil\n tree_for_string_literal4 = nil\n tree_for_char_literal6 = nil\n tree_for_EOF12 = nil\n stream_T__68 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__68\")\n stream_DOC_COMMENT = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token DOC_COMMENT\")\n stream_T__69 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__69\")\n stream_T__67 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__67\")\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__71\")\n stream_T__70 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__70\")\n stream_EOF = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token EOF\")\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule id\")\n stream_tokens_spec = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule tokens_spec\")\n stream_rule = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule rule\")\n stream_options_spec = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule options_spec\")\n stream_action = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule action\")\n stream_attr_scope = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule attr_scope\")\n begin\n # at line 95:9: ( DOC_COMMENT )? ( 'lexer' | 'parser' | 'tree' | ) g= 'grammar' id ';' ( options_spec )? ( tokens_spec )? ( attr_scope )* ( action )* ( rule )+ EOF\n # at line 95:9: ( DOC_COMMENT )?\n alt_1 = 2\n look_1_0 = @input.peek(1)\n\n if (look_1_0 == DOC_COMMENT) \n alt_1 = 1\n end\n case alt_1\n when 1\n # at line 95:9: DOC_COMMENT\n __DOC_COMMENT1__ = match(DOC_COMMENT, TOKENS_FOLLOWING_DOC_COMMENT_IN_grammar_def_295) \n if @state.backtracking == 0\n stream_DOC_COMMENT.add(__DOC_COMMENT1__)\n end\n\n end\n # at line 96:6: ( 'lexer' | 'parser' | 'tree' | )\n alt_2 = 4\n case look_2 = @input.peek(1)\n when T__67 then alt_2 = 1\n when T__68 then alt_2 = 2\n when T__69 then alt_2 = 3\n when T__70 then alt_2 = 4\n else\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n\n nvae = NoViableAlternative(\"\", 2, 0)\n raise nvae\n end\n case alt_2\n when 1\n # at line 96:8: 'lexer'\n string_literal2 = match(T__67, TOKENS_FOLLOWING_T__67_IN_grammar_def_305) \n if @state.backtracking == 0\n stream_T__67.add(string_literal2)\n end\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n @grammar_type = LEXER_GRAMMAR \n # <-- action\n end\n\n when 2\n # at line 97:8: 'parser'\n string_literal3 = match(T__68, TOKENS_FOLLOWING_T__68_IN_grammar_def_321) \n if @state.backtracking == 0\n stream_T__68.add(string_literal3)\n end\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n @grammar_type = PARSER_GRAMMAR \n # <-- action\n end\n\n when 3\n # at line 98:8: 'tree'\n string_literal4 = match(T__69, TOKENS_FOLLOWING_T__69_IN_grammar_def_333) \n if @state.backtracking == 0\n stream_T__69.add(string_literal4)\n end\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n @grammar_type = TREE_GRAMMAR \n # <-- action\n end\n\n when 4\n # at line 99:16: \n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n @grammar_type = COMBINED_GRAMMAR \n # <-- action\n end\n\n end\n g = match(T__70, TOKENS_FOLLOWING_T__70_IN_grammar_def_375) \n if @state.backtracking == 0\n stream_T__70.add(g)\n end\n @state.following.push(TOKENS_FOLLOWING_id_IN_grammar_def_377)\n id5 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id5.tree)\n end\n char_literal6 = match(T__71, TOKENS_FOLLOWING_T__71_IN_grammar_def_379) \n if @state.backtracking == 0\n stream_T__71.add(char_literal6)\n end\n # at line 101:25: ( options_spec )?\n alt_3 = 2\n look_3_0 = @input.peek(1)\n\n if (look_3_0 == OPTIONS) \n alt_3 = 1\n end\n case alt_3\n when 1\n # at line 101:25: options_spec\n @state.following.push(TOKENS_FOLLOWING_options_spec_IN_grammar_def_381)\n options_spec7 = options_spec\n @state.following.pop\n if @state.backtracking == 0\n stream_options_spec.add(options_spec7.tree)\n end\n\n end\n # at line 101:39: ( tokens_spec )?\n alt_4 = 2\n look_4_0 = @input.peek(1)\n\n if (look_4_0 == TOKENS) \n alt_4 = 1\n end\n case alt_4\n when 1\n # at line 101:39: tokens_spec\n @state.following.push(TOKENS_FOLLOWING_tokens_spec_IN_grammar_def_384)\n tokens_spec8 = tokens_spec\n @state.following.pop\n if @state.backtracking == 0\n stream_tokens_spec.add(tokens_spec8.tree)\n end\n\n end\n # at line 101:52: ( attr_scope )*\n loop do #loop 5\n alt_5 = 2\n look_5_0 = @input.peek(1)\n\n if (look_5_0 == SCOPE) \n alt_5 = 1\n\n end\n case alt_5\n when 1\n # at line 101:52: attr_scope\n @state.following.push(TOKENS_FOLLOWING_attr_scope_IN_grammar_def_387)\n attr_scope9 = attr_scope\n @state.following.pop\n if @state.backtracking == 0\n stream_attr_scope.add(attr_scope9.tree)\n end\n\n else\n break #loop 5\n end\n end\n # at line 101:64: ( action )*\n loop do #loop 6\n alt_6 = 2\n look_6_0 = @input.peek(1)\n\n if (look_6_0 == AT) \n alt_6 = 1\n\n end\n case alt_6\n when 1\n # at line 101:64: action\n @state.following.push(TOKENS_FOLLOWING_action_IN_grammar_def_390)\n action10 = action\n @state.following.pop\n if @state.backtracking == 0\n stream_action.add(action10.tree)\n end\n\n else\n break #loop 6\n end\n end\n # at file 102:6: ( rule )+\n match_count_7 = 0\n loop do\n alt_7 = 2\n look_7_0 = @input.peek(1)\n\n if (look_7_0 == DOC_COMMENT || look_7_0 == FRAGMENT || look_7_0 == TOKEN_REF || look_7_0 == RULE_REF || look_7_0.between?(T__75, T__77)) \n alt_7 = 1\n\n end\n case alt_7\n when 1\n # at line 102:6: rule\n @state.following.push(TOKENS_FOLLOWING_rule_IN_grammar_def_398)\n rule11 = rule\n @state.following.pop\n if @state.backtracking == 0\n stream_rule.add(rule11.tree)\n end\n\n else\n match_count_7 > 0 and break\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n\n eee = EarlyExit(7)\n\n\n raise eee\n end\n match_count_7 += 1\n end\n\n __EOF12__ = match(EOF, TOKENS_FOLLOWING_EOF_IN_grammar_def_406) \n if @state.backtracking == 0\n stream_EOF.add(__EOF12__)\n end\n # AST Rewrite\n # elements: attr_scope, id, tokens_spec, action, options_spec, rule, DOC_COMMENT\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 104:6: -> ^( id ( DOC_COMMENT )? ( options_spec )? ( tokens_spec )? ( attr_scope )* ( action )* ( rule )+ )\n # at line 104:9: ^( id ( DOC_COMMENT )? ( options_spec )? ( tokens_spec )? ( attr_scope )* ( action )* ( rule )+ )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(@adaptor.create!(@grammar_type, g) , root_1)\n\n @adaptor.add_child(root_1, stream_id.next_tree)\n # at line 105:12: ( DOC_COMMENT )?\n if stream_DOC_COMMENT.has_next?\n @adaptor.add_child(root_1, stream_DOC_COMMENT.next_node)\n\n end\n\n stream_DOC_COMMENT.reset();\n # at line 105:25: ( options_spec )?\n if stream_options_spec.has_next?\n @adaptor.add_child(root_1, stream_options_spec.next_tree)\n\n end\n\n stream_options_spec.reset();\n # at line 105:39: ( tokens_spec )?\n if stream_tokens_spec.has_next?\n @adaptor.add_child(root_1, stream_tokens_spec.next_tree)\n\n end\n\n stream_tokens_spec.reset();\n # at line 105:52: ( attr_scope )*\n while stream_attr_scope.has_next?\n @adaptor.add_child(root_1, stream_attr_scope.next_tree)\n\n end\n\n stream_attr_scope.reset();\n # at line 105:64: ( action )*\n while stream_action.has_next?\n @adaptor.add_child(root_1, stream_action.next_tree)\n\n end\n\n stream_action.reset();\n # at line 105:72: ( rule )+\n unless stream_rule.has_next?\n raise ANTLR3::RewriteEarlyExit\n end\n\n while stream_rule.has_next?\n @adaptor.add_child(root_1, stream_rule.next_tree)\n\n end\n\n stream_rule.reset\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 1)\n\n end\n \n return return_value\n end",
"def test\n sentence = \"(S (NP (NNP John)) (VP (V runs)))\"\n test = Tree.new(sentence)\n end",
"def parse(text); end",
"def initialize(str, debug=false)\n setup_parser(str, debug)\n @g = KPeg::Grammar.new\n end",
"def configure_parser; end",
"def k_new!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 42 )\n\n\n\n type = K_NEW\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 421:4: 'new'\n match( \"new\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 42 )\n\n\n end",
"def node(type, *args)\n AST.new(type, args)\n end",
"def parser_for_version(version)\n require \"parser/#{version}\"\n Parser.const_get version.capitalize\n end",
"def parse\n end",
"def grammar_def\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 1 )\n return_value = GrammarDefReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n g = nil\n __DOC_COMMENT1__ = nil\n string_literal2 = nil\n string_literal3 = nil\n string_literal4 = nil\n char_literal6 = nil\n __EOF12__ = nil\n id5 = nil\n options_spec7 = nil\n tokens_spec8 = nil\n attr_scope9 = nil\n action10 = nil\n rule11 = nil\n\n tree_for_g = nil\n tree_for_DOC_COMMENT1 = nil\n tree_for_string_literal2 = nil\n tree_for_string_literal3 = nil\n tree_for_string_literal4 = nil\n tree_for_char_literal6 = nil\n tree_for_EOF12 = nil\n stream_T__68 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__68\" )\n stream_DOC_COMMENT = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token DOC_COMMENT\" )\n stream_T__69 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__69\" )\n stream_T__67 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__67\" )\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__71\" )\n stream_T__70 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__70\" )\n stream_EOF = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token EOF\" )\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule id\" )\n stream_tokens_spec = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule tokens_spec\" )\n stream_rule = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule rule\" )\n stream_options_spec = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule options_spec\" )\n stream_action = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule action\" )\n stream_attr_scope = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule attr_scope\" )\n begin\n # at line 86:9: ( DOC_COMMENT )? ( 'lexer' | 'parser' | 'tree' | ) g= 'grammar' id ';' ( options_spec )? ( tokens_spec )? ( attr_scope )* ( action )* ( rule )+ EOF\n # at line 86:9: ( DOC_COMMENT )?\n alt_1 = 2\n look_1_0 = @input.peek( 1 )\n\n if ( look_1_0 == DOC_COMMENT )\n alt_1 = 1\n end\n case alt_1\n when 1\n # at line 86:9: DOC_COMMENT\n __DOC_COMMENT1__ = match( DOC_COMMENT, TOKENS_FOLLOWING_DOC_COMMENT_IN_grammar_def_290 )\n if @state.backtracking == 0\n stream_DOC_COMMENT.add( __DOC_COMMENT1__ )\n end\n\n end\n # at line 87:6: ( 'lexer' | 'parser' | 'tree' | )\n alt_2 = 4\n case look_2 = @input.peek( 1 )\n when T__67 then alt_2 = 1\n when T__68 then alt_2 = 2\n when T__69 then alt_2 = 3\n when T__70 then alt_2 = 4\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 2, 0 )\n end\n case alt_2\n when 1\n # at line 87:8: 'lexer'\n string_literal2 = match( T__67, TOKENS_FOLLOWING_T__67_IN_grammar_def_300 )\n if @state.backtracking == 0\n stream_T__67.add( string_literal2 )\n end\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n @grammar_type = LEXER_GRAMMAR \n # <-- action\n end\n\n when 2\n # at line 88:8: 'parser'\n string_literal3 = match( T__68, TOKENS_FOLLOWING_T__68_IN_grammar_def_316 )\n if @state.backtracking == 0\n stream_T__68.add( string_literal3 )\n end\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n @grammar_type = PARSER_GRAMMAR \n # <-- action\n end\n\n when 3\n # at line 89:8: 'tree'\n string_literal4 = match( T__69, TOKENS_FOLLOWING_T__69_IN_grammar_def_328 )\n if @state.backtracking == 0\n stream_T__69.add( string_literal4 )\n end\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n @grammar_type = TREE_GRAMMAR \n # <-- action\n end\n\n when 4\n # at line 90:16: \n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n @grammar_type = COMBINED_GRAMMAR \n # <-- action\n end\n\n end\n g = match( T__70, TOKENS_FOLLOWING_T__70_IN_grammar_def_370 )\n if @state.backtracking == 0\n stream_T__70.add( g )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_grammar_def_372 )\n id5 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id5.tree )\n end\n char_literal6 = match( T__71, TOKENS_FOLLOWING_T__71_IN_grammar_def_374 )\n if @state.backtracking == 0\n stream_T__71.add( char_literal6 )\n end\n # at line 92:25: ( options_spec )?\n alt_3 = 2\n look_3_0 = @input.peek( 1 )\n\n if ( look_3_0 == OPTIONS )\n alt_3 = 1\n end\n case alt_3\n when 1\n # at line 92:25: options_spec\n @state.following.push( TOKENS_FOLLOWING_options_spec_IN_grammar_def_376 )\n options_spec7 = options_spec\n @state.following.pop\n if @state.backtracking == 0\n stream_options_spec.add( options_spec7.tree )\n end\n\n end\n # at line 92:39: ( tokens_spec )?\n alt_4 = 2\n look_4_0 = @input.peek( 1 )\n\n if ( look_4_0 == TOKENS )\n alt_4 = 1\n end\n case alt_4\n when 1\n # at line 92:39: tokens_spec\n @state.following.push( TOKENS_FOLLOWING_tokens_spec_IN_grammar_def_379 )\n tokens_spec8 = tokens_spec\n @state.following.pop\n if @state.backtracking == 0\n stream_tokens_spec.add( tokens_spec8.tree )\n end\n\n end\n # at line 92:52: ( attr_scope )*\n while true # decision 5\n alt_5 = 2\n look_5_0 = @input.peek( 1 )\n\n if ( look_5_0 == SCOPE )\n alt_5 = 1\n\n end\n case alt_5\n when 1\n # at line 92:52: attr_scope\n @state.following.push( TOKENS_FOLLOWING_attr_scope_IN_grammar_def_382 )\n attr_scope9 = attr_scope\n @state.following.pop\n if @state.backtracking == 0\n stream_attr_scope.add( attr_scope9.tree )\n end\n\n else\n break # out of loop for decision 5\n end\n end # loop for decision 5\n # at line 92:64: ( action )*\n while true # decision 6\n alt_6 = 2\n look_6_0 = @input.peek( 1 )\n\n if ( look_6_0 == AT )\n alt_6 = 1\n\n end\n case alt_6\n when 1\n # at line 92:64: action\n @state.following.push( TOKENS_FOLLOWING_action_IN_grammar_def_385 )\n action10 = action\n @state.following.pop\n if @state.backtracking == 0\n stream_action.add( action10.tree )\n end\n\n else\n break # out of loop for decision 6\n end\n end # loop for decision 6\n # at file 93:6: ( rule )+\n match_count_7 = 0\n while true\n alt_7 = 2\n look_7_0 = @input.peek( 1 )\n\n if ( look_7_0 == DOC_COMMENT || look_7_0 == FRAGMENT || look_7_0 == TOKEN_REF || look_7_0 == RULE_REF || look_7_0.between?( T__75, T__77 ) )\n alt_7 = 1\n\n end\n case alt_7\n when 1\n # at line 93:6: rule\n @state.following.push( TOKENS_FOLLOWING_rule_IN_grammar_def_393 )\n rule11 = rule\n @state.following.pop\n if @state.backtracking == 0\n stream_rule.add( rule11.tree )\n end\n\n else\n match_count_7 > 0 and break\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n eee = EarlyExit(7)\n\n\n raise eee\n end\n match_count_7 += 1\n end\n\n __EOF12__ = match( EOF, TOKENS_FOLLOWING_EOF_IN_grammar_def_401 )\n if @state.backtracking == 0\n stream_EOF.add( __EOF12__ )\n end\n # AST Rewrite\n # elements: id, rule, options_spec, DOC_COMMENT, action, attr_scope, tokens_spec\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 95:6: -> ^( id ( DOC_COMMENT )? ( options_spec )? ( tokens_spec )? ( attr_scope )* ( action )* ( rule )+ )\n # at line 95:9: ^( id ( DOC_COMMENT )? ( options_spec )? ( tokens_spec )? ( attr_scope )* ( action )* ( rule )+ )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( ( @adaptor.create(@grammar_type, g) ), root_1 )\n\n @adaptor.add_child( root_1, stream_id.next_tree )\n # at line 96:12: ( DOC_COMMENT )?\n if stream_DOC_COMMENT.has_next?\n @adaptor.add_child( root_1, stream_DOC_COMMENT.next_node )\n\n end\n\n stream_DOC_COMMENT.reset();\n # at line 96:25: ( options_spec )?\n if stream_options_spec.has_next?\n @adaptor.add_child( root_1, stream_options_spec.next_tree )\n\n end\n\n stream_options_spec.reset();\n # at line 96:39: ( tokens_spec )?\n if stream_tokens_spec.has_next?\n @adaptor.add_child( root_1, stream_tokens_spec.next_tree )\n\n end\n\n stream_tokens_spec.reset();\n # at line 96:52: ( attr_scope )*\n while stream_attr_scope.has_next?\n @adaptor.add_child( root_1, stream_attr_scope.next_tree )\n\n end\n\n stream_attr_scope.reset();\n # at line 96:64: ( action )*\n while stream_action.has_next?\n @adaptor.add_child( root_1, stream_action.next_tree )\n\n end\n\n stream_action.reset();\n # at line 96:72: ( rule )+\n stream_rule.has_next? or raise ANTLR3::RewriteEarlyExit\n\n while stream_rule.has_next?\n @adaptor.add_child( root_1, stream_rule.next_tree )\n\n end\n stream_rule.reset\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 1 )\n\n end\n \n return return_value\n end",
"def parse()\n\n\n begin\n @ruleStack.push('parse')\n # dice.g:42:8: ( expr )\n # dice.g:42:8: expr\n\n #@following.push(FOLLOW_expr_in_parse50)\n expr()\n #@following.pop\n\n\n\n\n rescue ANTLR::RecognitionException => e\n report_error(e)\n #raise e\n ensure\n @ruleStack.pop\n end\n\n end",
"def build_parse ctxt, parent, opts={}, &block\n nonterminal_common_build_parse(UnionParse, ctxt, parent, opts, &block)\n end",
"def parser\n @parser ||= parser_klass.new(job_folder)\n end",
"def create\n if text.match(/\\_QUOTE/)\n require 'organismo/element/quote'\n Organismo::Element::Quote.new(text, location)\n elsif text.match(/\\_SRC/)\n require 'organismo/element/code'\n Organismo::Element::Code.new(text, location)\n elsif text.match(/\\_EXAMPLE/)\n require 'organismo/element/example'\n Organismo::Element::Example.new(text, location)\n elsif text.match(/\\*/)\n require 'organismo/element/header'\n Organismo::Element::Header.new(text, location)\n elsif text.match(/\\[\\[\\S*(\\.png)|(\\jpg)|(\\.jpeg)\\]\\]/)\n require 'organismo/element/image'\n Organismo::Element::Image.new(text, location)\n elsif text.match(/\\[\\[\\S*\\]\\]/)\n require 'organismo/element/link'\n Organismo::Element::Link.new(text, location) \n elsif text.match(/\\-/)\n require 'organismo/element/plain_list'\n Organismo::Element::PlainList.new(text, location)\n else\n require 'organismo/element/text'\n Organismo::Element::Text.new(text, location)\n end\n end",
"def parse(source); end",
"def new(options=nil)\n Tidyobj.new(options)\n end",
"def parse\n parse_eols\n rules = []\n while rule = parse_rule\n rules << rule\n end\n if [email protected]?\n raise \"expected eos : #{@s.inspect}\"\n end\n Peg.new @ctx, rules\n end",
"def tree(capa = 1)\n R3::Tree.new(capa)\nend",
"def parse!\n raise NotImplementedError, \"this class is intended to be a top class, not a useful parser\"\n end",
"def parse(source, options = T.unsafe(nil)); end",
"def parse(source, options = T.unsafe(nil)); end",
"def initialize(program)\n syntactic_parser = Parser::SyntacticParser.new(program)\n @ast = syntactic_parser.ast\n @context = Context.new\n end",
"def parse(input = nil, options = 0)\n end",
"def parse(io, options = T.unsafe(nil)); end",
"def parser=(p)\n @@parser = choose_parser(p)\n end",
"def constructor\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 54 )\n\n\n return_value = ConstructorReturnValue.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_DEF288__ = nil\n __K_INITIALIZE289__ = nil\n __LPAR290__ = nil\n __RPAR292__ = nil\n __LLAIZQ293__ = nil\n __LLADER295__ = nil\n parametros_tipos291 = nil\n bodyexp294 = nil\n\n\n tree_for_K_DEF288 = nil\n tree_for_K_INITIALIZE289 = nil\n tree_for_LPAR290 = nil\n tree_for_RPAR292 = nil\n tree_for_LLAIZQ293 = nil\n tree_for_LLADER295 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 247:4: K_DEF K_INITIALIZE LPAR ( parametros_tipos )? RPAR LLAIZQ bodyexp LLADER\n __K_DEF288__ = match( K_DEF, TOKENS_FOLLOWING_K_DEF_IN_constructor_1218 )\n if @state.backtracking == 0\n tree_for_K_DEF288 = @adaptor.create_with_payload( __K_DEF288__ )\n @adaptor.add_child( root_0, tree_for_K_DEF288 )\n\n end\n\n __K_INITIALIZE289__ = match( K_INITIALIZE, TOKENS_FOLLOWING_K_INITIALIZE_IN_constructor_1220 )\n if @state.backtracking == 0\n tree_for_K_INITIALIZE289 = @adaptor.create_with_payload( __K_INITIALIZE289__ )\n @adaptor.add_child( root_0, tree_for_K_INITIALIZE289 )\n\n end\n\n __LPAR290__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_constructor_1222 )\n if @state.backtracking == 0\n tree_for_LPAR290 = @adaptor.create_with_payload( __LPAR290__ )\n @adaptor.add_child( root_0, tree_for_LPAR290 )\n\n end\n\n # at line 247:28: ( parametros_tipos )?\n alt_39 = 2\n look_39_0 = @input.peek( 1 )\n\n if ( look_39_0 == TIPO )\n alt_39 = 1\n end\n case alt_39\n when 1\n # at line 247:28: parametros_tipos\n @state.following.push( TOKENS_FOLLOWING_parametros_tipos_IN_constructor_1224 )\n parametros_tipos291 = parametros_tipos\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, parametros_tipos291.tree )\n end\n\n\n end\n __RPAR292__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_constructor_1227 )\n if @state.backtracking == 0\n tree_for_RPAR292 = @adaptor.create_with_payload( __RPAR292__ )\n @adaptor.add_child( root_0, tree_for_RPAR292 )\n\n end\n\n __LLAIZQ293__ = match( LLAIZQ, TOKENS_FOLLOWING_LLAIZQ_IN_constructor_1229 )\n if @state.backtracking == 0\n tree_for_LLAIZQ293 = @adaptor.create_with_payload( __LLAIZQ293__ )\n @adaptor.add_child( root_0, tree_for_LLAIZQ293 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_bodyexp_IN_constructor_1231 )\n bodyexp294 = bodyexp\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, bodyexp294.tree )\n end\n\n __LLADER295__ = match( LLADER, TOKENS_FOLLOWING_LLADER_IN_constructor_1233 )\n if @state.backtracking == 0\n tree_for_LLADER295 = @adaptor.create_with_payload( __LLADER295__ )\n @adaptor.add_child( root_0, tree_for_LLADER295 )\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__, 54 )\n\n\n end\n\n return return_value\n end",
"def parse\n raise NotImplementedError\n end",
"def newmetaparam(name, options = {}, &block)\n # TODO: raise exception or support?\n nil\n end",
"def rewind\n create_parser\n end",
"def test_jore_parsing\n assert_equal(\"73N\", @parser.parse_jore(\"1073N 1\"))\n assert_equal(\"519\", @parser.parse_jore(\"1519 1\"))\n end",
"def create_option_parser\n OptionParser.new do |parser|\n parser.banner = \"Toy Robot Simulation\\nUsage: toy_robot_simulator [options]\"\n parser.version = VERSION\n\n parser.on_tail('-v', '--version', 'Display the version') do\n puts parser.version\n exit\n end\n\n parser.on_tail('-h', '--help', 'You are looking at it') do\n puts parser.help\n exit\n end\n end\n end",
"def parser(filename = EXAMPLE_CONTINUOUS)\n filepath = File.join(File.dirname(__FILE__), \"..\", \"data\", filename)\n @parser = ImzML::Parser.new(filepath)\n end",
"def directive_create(tag_name, tag_buf, parser); end",
"def parse(input)\n # Save for error msgs\n @input = input.clone\n @tokens = lex(input)\n @rpn = parse_expr\n\n assert_eos\n\n self\n end",
"def parse(source, options = {})\n new.parse(source, options)\n end",
"def initialize(rules = {}, node_type = Array, &default_action)\n raise ArgumentError.new(\"cannot form parser from a #{rules.class}\") unless rules.kind_of? Hash\n raise ArgumentError.new(\"syntax tree type must respond to <<\") unless node_type.method_defined?(:\"<<\")\n @default_action = (default_action.nil? ? lambda{|node, name| node} : default_action)\n @node_type = node_type\n @rules = rules.map do |k, v|\n Rule.new(k, v, @default_action)\n end\n end",
"def initialize(io)\n @rparent={:subs => [], :indent => -1,:text => [],:attrs => {},:comments => []}\n \n #todo guess at contents xml or nom\n parse_nom(io)\n end",
"def parse\n raise NotImplementedError.new\n end",
"def create\n @parser = Parser.new(parser_params)\n\n respond_to do |format|\n if @parser.save\n format.html { redirect_to @parser, notice: 'Parser was successfully created.' }\n format.json { render :show, status: :created, location: @parser }\n else\n format.html { render :new }\n format.json { render json: @parser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @parser = Parser.new(parser_params)\n\n respond_to do |format|\n if @parser.save\n format.html { redirect_to @parser, notice: 'Parser was successfully created.' }\n format.json { render :show, status: :created, location: @parser }\n else\n format.html { render :new }\n format.json { render json: @parser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @parser = Parser.new(parser_params)\n\n respond_to do |format|\n if @parser.save\n format.html { redirect_to @parser, notice: 'Parser was successfully created.' }\n format.json { render action: 'show', status: :created, location: @parser }\n else\n format.html { render action: 'new' }\n format.json { render json: @parser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def text_to_syntax_tree(text, parse_options={})\n logger.info(\"Parsing...\")\n tree = @parser.parse(text, parse_options)\n logger.info(\"Parsed!\")\n\n if tree.nil?\n raise Slaw::Parse::ParseError.new(parser.failure_reason || \"Couldn't match to grammar\",\n line: parser.failure_line || 0,\n column: parser.failure_column || 0)\n end\n\n tree\n end",
"def create\n @parser = StatementParsers::ParserBase.new(statement_params)\n respond_to do |format|\n if @parser.save\n format.html { redirect_to statement_parsers_url, notice: \"Parser #{@parser.name} was successfully created.\" }\n format.json { render :show, status: :created, location: @parser }\n else\n format.html { render :new, :flash => {:error => @parser.errors.full_messages} }\n format.json { render json: @parser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def instantiate_node(node_type,*args)\n if node_type.respond_to? :new \n node_type.new(*args)\n else\n SyntaxNode.new(*args).extend(node_type)\n end\n end",
"def parse(source)\n @root = Document.new(tokenize(source))\n self\n end",
"def parse(s)\n case s['type']\n when '2p-set'\n TwoPhaseSet.new s\n when 'lww-set'\n LWWSet.new s\n when 'or-set'\n ORSet.new s\n when 'g-counter'\n GCounter.new s\n else\n raise ArgumentError, \"unknown type #{s['type']}\"\n end\n end"
] | [
"0.61424464",
"0.6130579",
"0.60563785",
"0.59542274",
"0.59065545",
"0.59065545",
"0.59065545",
"0.59065545",
"0.57602584",
"0.57138985",
"0.5700162",
"0.5700162",
"0.568779",
"0.5652527",
"0.5652527",
"0.56236935",
"0.56192493",
"0.5601566",
"0.5584199",
"0.5578563",
"0.5573611",
"0.5566148",
"0.5553082",
"0.5540695",
"0.5501001",
"0.5501001",
"0.5458648",
"0.5431576",
"0.53607595",
"0.5352805",
"0.5339817",
"0.52976483",
"0.52961963",
"0.52847844",
"0.5253928",
"0.5253656",
"0.5247523",
"0.5245305",
"0.52411413",
"0.5218138",
"0.5211451",
"0.5182513",
"0.5167816",
"0.516079",
"0.5152405",
"0.5152222",
"0.5126355",
"0.5117037",
"0.5114106",
"0.5114106",
"0.5114106",
"0.5094304",
"0.50924546",
"0.5078468",
"0.507739",
"0.50707465",
"0.5070698",
"0.5063453",
"0.504608",
"0.5044323",
"0.5042489",
"0.50387937",
"0.50198615",
"0.5018404",
"0.50145066",
"0.50075483",
"0.5005136",
"0.50014925",
"0.4999383",
"0.49785373",
"0.49727046",
"0.49720314",
"0.49696386",
"0.49577767",
"0.49577767",
"0.49532732",
"0.49530753",
"0.49503967",
"0.4941692",
"0.49386114",
"0.49379826",
"0.49188092",
"0.49149364",
"0.48995498",
"0.48951358",
"0.48933032",
"0.48914105",
"0.48869857",
"0.48855504",
"0.48731717",
"0.48708513",
"0.48648486",
"0.48626",
"0.48626",
"0.48571953",
"0.48547885",
"0.4851397",
"0.4847558",
"0.48409104",
"0.4833818"
] | 0.6471546 | 0 |
GET /ticketrezs GET /ticketrezs.xml | def index
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @ticketrezs }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tickets }\n end\n end",
"def index\n @tickets = @project.tickets.desc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tickets }\n end\n end",
"def index\n @tickets = OTRS::Ticket.where(params[:q])\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => @tickets }\n wants.json { render :json => @tickets }\n end\n end",
"def index\n @ticket_times = TicketTime.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ticket_times }\n end\n end",
"def index\n @ticket_actions = TicketAction.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ticket_actions }\n end\n end",
"def GetTickets params = {}\n\n params = params.merge(path: 'tickets.json')\n APICall(params)\n\n end",
"def getXMLTicket(path)\n resp2 = @@conn.get do |req|\n req.url path\n req.headers['Authorization'] = 'Basic aHIuc2VsbGVydEBnbWFpbC5jb206c2VzMTEy' #@TODO make this a param\n req.headers['Content-Type'] = 'application/xml'\n end\n # puts \"Responce : \" + resp2['body'].inspect\n # puts \"Responce2 : \" + resp2.body.to_s()\n \n return resp2.body.to_s()\n end",
"def index\n @ticketalerts = Ticketalert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ticketalerts }\n end\n end",
"def index\n @tickets = current_user.tickets.page(params[:page]||1)\n respond_to do |format|\n format.html\n format.xml { render :xml => @tickets }\n format.json { render :json => @tickets }\n end\n end",
"def index\n if params[:event_id]\n @tickets = Ticket.find_all_by_event_id(params[:event_id])\n else\n @tickets = Ticket.find(:all)\n end\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tickets }\n end\n end",
"def find_tickets(res)\n if res.key?(\"tickets\")\n tickets_info = res[\"tickets\"]\n @tickets = []\n tickets_info.each do |ticket_info|\n ticket = Ticket.new(ticket_info) \n @tickets << ticket\n end\n @tickets\n elsif res.key?(\"error\")\n raise res[\"error\"]\n else\n raise \"unknown error from API\"\n end\n end",
"def index\n\t @tickets = Ticket.order('created_at DESC').page(params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def index\n @sprint = params[:sprint].presence || Sprint.current!\n @tickets = Ticket.for_sprint(@sprint).by_created_at_desc\n @tickets = @tickets.for_project(params[:project]) if params[:project].present?\n @tickets = @tickets.for_user(params[:user]) if params[:user].present?\n @tickets = @tickets.search_name(params[:description]) if params[:description].present?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def test_articlerss\n get :articlerss, :id => 1 \n assert_response :success\n assert_nothing_raised do\n assert REXML::Document.new(@response.body)\n end\n end",
"def index\n @title = \"Tickets\"\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def index\n respond_with(@tickets)\n end",
"def show\n authorize! :read, Rezlineitem\n @rezlineitems = @ticketrez.rezlineitems\n @show = @ticketrez.show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticketrez }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def index\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ticket }\n end\n end",
"def index\n @kontakties = Kontakty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @kontakties }\n end\n end",
"def index\n \t@clickers = Clicker.all\t\t\t\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clickers }\n end\n end",
"def index\n @receipts = Receipt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receipts }\n end\n end",
"def expired\n @classifieds = Cyberstock.expired.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end",
"def index\n @entries = @resource_finder.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def my_tickets\n user = current_user.id if !current_user.nil?\n # OCO\n init_oco if !session[:organization]\n\n @search = Ticket.search do\n fulltext params[:search]\n if session[:organization] != '0'\n with :organization_id, session[:organization]\n end\n if !user.blank?\n with :created_by, user\n end\n with(:ticket_status_id).less_than(4)\n order_by :id, :desc\n paginate :page => params[:page] || 1, :per_page => per_page\n end\n\n @tickets = @search.results\n\n respond_to do |format|\n format.html # my_tickets.html.erb\n format.json { render json: @tickets }\n end\n end",
"def show\n @custom_ticket = CustomTicket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @custom_ticket }\n end\n end",
"def index\n @borrower_residences = BorrowerResidence.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @borrower_residences.to_xml }\n end\n end",
"def index\n @components_rear_tires = Components::RearTire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_rear_tires }\n end\n end",
"def get_trucker_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_trucker(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def index\n @lookup_scantasks = LookupScantask.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_scantasks }\n end\n end",
"def get_events_for_ticket( session_key, ticket_id)\n response_xml = self.call( :get_events_for_ticket, message: {\n arg0: session_key,\n arg1: ticket_id\n })\n response = IssueCentre::Response.parse( response_xml)\n end",
"def index\n tickets = Ticket.all_relevant_tickets\n @pagy, @tickets = pagy(tickets)\n ticket_records_with_associations =\n TicketSerializer.new(@tickets, { params: { :ticketlist => true } }).hash_for_collection[:data].map { | ticket |\n ticket[:attributes]\n }\n # When we need pagination lets use the below\n #render json: { data: ticket_records_with_associations,\n # pagy: pagy_metadata(@pagy) }\n paginate json: ticket_records_with_associations\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def get_substrates()\n\tputs \"Getting list of substrates.\"\n\tresponse = request_get('/api/partner/substrate')\n\tputs response.body\nend",
"def index\n @support_tickets = SupportTicket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @support_tickets }\n end\n end",
"def all_ticket_entries\n @ac = ApplicationController.new\n @tickets = Ticket.find(:all, :order => \"created_at\")[0..5000].reverse!\n @species = Specie.all\n @woodtypes = WoodType.all\n end",
"def index\n @employees = $Vendor.employees.scopied.order(\"created_at desc\").page(params[:page]).per(25)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @employees }\n end\n end",
"def index\n @votes = @retort.votes.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end",
"def test_solveticket\n\n # create ticket\n @zendeskclient.createticket(\"test ticket\", \"4\", 'Captain Cool', \"[email protected]\")\n assert_equal(201, @zendeskclient.responsecode)\n assert(@zendeskclient.response.to_s.match('http://rateitindia.zendesk.com'))\n tktcreationresponse = @zendeskclient.response\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # a new ticket; assert on the status of the ticket\n assert_equal(\"0\", doc.root.elements[\"status-id\"].text)\n\n\n ticketid = ZenDeskAPI.extractid(tktcreationresponse)\n\n\n # solve the ticket and test for the http error code\n @zendeskclient.solveticket(\"31198262\", ticketid)\n assert_equal(200, @zendeskclient.responsecode)\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # after solving the ticket; assert on the status of the ticket\n assert_equal(\"3\", doc.root.elements[\"status-id\"].text)\n\n end",
"def index_all\n @tickets = Ticket.all_tickets\n render json: @tickets, status: 200\n end",
"def print_my_recent_bookmarks(username, password)\n # Make the HTTPS request.\n response = open('https://api.del.icio.us/v1/posts/recent',\n :http_basic_authentication => [username, password])\n\n # Read the response entity-body as an XML document.\n xml = response.read\n\n # Turn the document into a data structure.\n document = REXML::Document.new(xml)\n\n # For each bookmark...\n REXML::XPath.each(document, \"/posts/post\") do |e|\n # Print the bookmark's description and URI\n puts \"#{e.attributes['description']}: #{e.attributes['href']}\"\n end\nend",
"def index\n @fixed_deposits = FixedDeposit.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fixed_deposits }\n end\n end",
"def index\n @sprints = Sprint.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sprints.to_xml }\n end\n end",
"def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n\t\tresponse = Net::HTTP.get_response(uri)\n\t\tcontent = response.body\n\n\t\txml = REXML::Document.new(content)\n\n\t\treturn xml\n\tend",
"def cyberstock\n @classifieds = Cyberstock.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end",
"def index\n @frequencia_setores = Frequencia::Setor.order('updated_at ASC').paginate :page => params[:page], :per_page => 10\n @total = Frequencia::Setor.all.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @frequencia_setores }\n end\n end",
"def index\n @received_issues = ReceivedIssue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @received_issues }\n end\n end",
"def rest_get(uri)\n \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 return doc\n \n end\n \nend",
"def index\n @uitgelichts = Uitgelicht.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uitgelichts }\n end\n end",
"def index\n @ticket_detalles = TicketDetalle.all\n end",
"def index\n @lookup_sets = LookupSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_sets }\n end\n end",
"def index\n @reviewers = Reviewer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reviewers }\n end\n end",
"def index\n @help = \"Recurring Transaction List\"\n @recurrings = @account.recurrings\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @recurrings }\n end\n end",
"def show\n authorize! :read, Show, Ticketrez, Ticketsection\n @ticketrezs = @show.ticketrezs\n @ticketsections = @show.ticketsections\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @show }\n end\n end",
"def index\n @homework_return_requests = HomeworkReturnRequest.order('created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @homework_return_requests }\n end\n end",
"def index\n debugger\n @receitas = Receita.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receitas }\n end\n end",
"def index\n @retiradas = Retirada.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @retiradas }\n end\n end",
"def index\n @realtors = Realtor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @realtors }\n end\n end",
"def index\n @requests = Request.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requests }\n end\n end",
"def index\n @feria2009calificaciones = Feria2009calificacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feria2009calificaciones }\n end\n end",
"def index\n @support_tickets = SupportTicket.all\n end",
"def list\r\n # the base uri for api requests\r\n _query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n _query_builder << '/tickets'\r\n\r\n # validate and preprocess url\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n _headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'X-API-TOKEN' => Configuration.x_api_token,\r\n 'X-API-EMAIL' => Configuration.x_api_email\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params _headers\r\n\r\n # invoke the API call request to fetch the response\r\n _response = Unirest.get _query_url, headers: _headers\r\n\r\n # Error handling using HTTP status codes\r\n if _response.code == 401\r\n raise APIException.new 'Your API key is incorrect', 401, _response.body\r\n elsif _response.code == 400\r\n raise APIException.new 'There is an error in the parameters you send', 400, _response.body\r\n elsif _response.code == 404\r\n raise APIException.new 'Cannot find the resource specified', 404, _response.body\r\n elsif !_response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', _response.code, _response.body\r\n end\r\n \r\n # Try to cast response to list of desired type\r\n if _response.body.instance_of? Array\r\n value = Array.new\r\n _response.body.each do |item|\r\n begin\r\n value << (Ticket.from_hash(item))\r\n rescue Exception\r\n raise APIException.new \"Invalid JSON returned.\", _response.code, _response.body\r\n end\r\n end\r\n value\r\n end\r\n end",
"def index\r\n @purchase_requisition_categories = PurchaseRequisitionCategory.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @purchase_requisition_categories }\r\n end\r\n end",
"def get_ticket\n ticket_details = self.class.get(\"/rest/api/2/issue/\", :verify => false)\n File.open(\"custom.txt\", 'w') {|f| f.write(ticket_details) }\n end",
"def GetTicket id\n\n APICall(path: \"tickets/#{id}.json\")\n\n end",
"def show\n @ticket_type = TicketType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket_type }\n end\n end",
"def index\n if params[:tickets] == 'closed'\n @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).closed.page(params[:page])\n else\n @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.page(params[:page])\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def list\n\t\t@hras = Hra.paginate :page => params[:page], :per_page => 10\t#Pagination\n \trespond_to do |format|\t\t\n \t\t format.html \n \t\t\tformat.xml { render :xml => @hras }\t\t#Render to XML File\n \tend\n\tend",
"def index\n\n if request.format == Mime::XML\n limit=params[:limit].nil? ? 1000: params[:limit]\n else\n limit=params[:limit].nil? ? 50 : params[:limit]\n end\n\n @reservations = Reservation.paginate :page => params[:page] || 1, :per_page => limit, :conditions => [\"user_id = ? AND historical = ?\", session[:user_id], 0], :order => \"id\"\n\n respond_to do |format|\n format.xml { render :xml => @reservations }\n format.any { render :json => @reservations }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id].to_i) rescue nil\n respond_to do |format|\n unless @ticket.blank?\n format.xml { render :xml => ticket_presenter }\n format.json { render :json => ticket_presenter }\n else\n format.xml { head :not_found }\n format.json { head :not_found }\n end\n end\n end",
"def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n end",
"def show\n @ticket_seller = TicketSeller.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket_seller }\n end\n end",
"def get_logger_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_logger(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def index\n @ticket_events = TicketEvent.all\n end",
"def index\n @usrs = Usr.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usrs }\n end\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def sru_response\n # Create bib record.\n title_str = OLE_QA::Framework::String_Factory.alphanumeric(12)\n author_str = OLE_QA::Framework::String_Factory.alphanumeric(14)\n today = Time.now.strftime('%Y%m%d-%H%M')\n bib_ary = [{\n :tag => '245',\n :ind_1 => '',\n :ind_2 => '',\n :value => '|a' + title_str\n },\n {\n :tag => '100',\n :ind_1 => '',\n :ind_2 => '',\n :value => '|a' + author_str\n }]\n bib_editor = OLE_QA::Framework::OLELS::Bib_Editor.new(@ole)\n bib_editor.open\n create_bib(bib_editor,bib_ary)\n query = \"title any #{title_str}\"\n filename = \"sru_perf-#{today}.xml\"\n get_sru_file(query,filename,@ole)\n records = get_marc_xml(filename)\n verify(5) {File.zero?(\"data/downloads/#{filename}\") == false}\n verify(5) {records.count == 1}\n end",
"def index\n @tickets = current_user.tickets.last(15).reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def index\n @cuitcheques = Cuitcheque.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cuitcheques }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @chronopay_links }\n end\n end",
"def retired_index\n @rigs = Rig.inactive\n @main_header = \"Retired Rigs\"\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rigs }\n end\n end",
"def index\n @committeemembers = Committeemember.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @committeemembers }\n end\n end",
"def all_book_tickers\n request :public, :get, :bookTicker\n end"
] | [
"0.6684903",
"0.6608066",
"0.6503497",
"0.6477688",
"0.6398327",
"0.6339453",
"0.6324002",
"0.61693484",
"0.5934766",
"0.59085095",
"0.58974314",
"0.5861965",
"0.5857106",
"0.57998556",
"0.5797091",
"0.5787374",
"0.5780197",
"0.57764983",
"0.57764983",
"0.57764983",
"0.57764983",
"0.57764983",
"0.57764983",
"0.5776282",
"0.57708865",
"0.5758441",
"0.5748483",
"0.5735724",
"0.5734859",
"0.5731666",
"0.5720115",
"0.5708875",
"0.57047355",
"0.56981033",
"0.5693866",
"0.5693048",
"0.56866926",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5680064",
"0.5679236",
"0.56549245",
"0.56526834",
"0.5640534",
"0.5639355",
"0.56383616",
"0.5637256",
"0.56371844",
"0.56367284",
"0.5636669",
"0.5613874",
"0.56096715",
"0.5605938",
"0.5603371",
"0.5600537",
"0.5599646",
"0.55947256",
"0.5593677",
"0.5584573",
"0.5583641",
"0.55771154",
"0.5572457",
"0.55711615",
"0.55597466",
"0.5559157",
"0.5537061",
"0.5535397",
"0.5524037",
"0.5523991",
"0.55230856",
"0.5522313",
"0.5504844",
"0.5502709",
"0.5495289",
"0.5486279",
"0.54807866",
"0.5480522",
"0.54772323",
"0.5472739",
"0.5472246",
"0.547201",
"0.547036",
"0.54670715",
"0.5462864",
"0.5461457",
"0.54554766",
"0.5455197",
"0.54462886",
"0.54447496",
"0.5443715",
"0.54418606"
] | 0.71887994 | 0 |
GET /ticketrezs/1 GET /ticketrezs/1.xml | def show
authorize! :read, Rezlineitem
@rezlineitems = @ticketrez.rezlineitems
@show = @ticketrez.show
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @ticketrez }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ticketrezs }\n end\n end",
"def getXMLTicket(path)\n resp2 = @@conn.get do |req|\n req.url path\n req.headers['Authorization'] = 'Basic aHIuc2VsbGVydEBnbWFpbC5jb206c2VzMTEy' #@TODO make this a param\n req.headers['Content-Type'] = 'application/xml'\n end\n # puts \"Responce : \" + resp2['body'].inspect\n # puts \"Responce2 : \" + resp2.body.to_s()\n \n return resp2.body.to_s()\n end",
"def index\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tickets }\n end\n end",
"def index\n @tickets = @project.tickets.desc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tickets }\n end\n end",
"def index\n @ticket_times = TicketTime.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ticket_times }\n end\n end",
"def index\n @tickets = OTRS::Ticket.where(params[:q])\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => @tickets }\n wants.json { render :json => @tickets }\n end\n end",
"def index\n @ticket_actions = TicketAction.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ticket_actions }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def show\n @custom_ticket = CustomTicket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @custom_ticket }\n end\n end",
"def index\n @ticketalerts = Ticketalert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ticketalerts }\n end\n end",
"def GetTickets params = {}\n\n params = params.merge(path: 'tickets.json')\n APICall(params)\n\n end",
"def show\n @ticket_type = TicketType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket_type }\n end\n end",
"def show\n @ticket = Ticket.find(params[:id].to_i) rescue nil\n respond_to do |format|\n unless @ticket.blank?\n format.xml { render :xml => ticket_presenter }\n format.json { render :json => ticket_presenter }\n else\n format.xml { head :not_found }\n format.json { head :not_found }\n end\n end\n end",
"def show\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to edit_ticket_url(@ticket) }\n format.xml { render :xml => @ticket.to_xml }\n end\n end",
"def show\n @ticket_time = TicketTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket_time }\n end\n end",
"def test_articlerss\n get :articlerss, :id => 1 \n assert_response :success\n assert_nothing_raised do\n assert REXML::Document.new(@response.body)\n end\n end",
"def index\n @tickets = current_user.tickets.page(params[:page]||1)\n respond_to do |format|\n format.html\n format.xml { render :xml => @tickets }\n format.json { render :json => @tickets }\n end\n end",
"def show\n @scaleticket = Scaleticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scaleticket }\n end\n end",
"def index\n @receipts = Receipt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receipts }\n end\n end",
"def index\n if params[:event_id]\n @tickets = Ticket.find_all_by_event_id(params[:event_id])\n else\n @tickets = Ticket.find(:all)\n end\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tickets }\n end\n end",
"def show\n @ticket_seller = TicketSeller.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket_seller }\n end\n end",
"def rest_get(uri)\n \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 return doc\n \n end\n \nend",
"def GetTicket id\n\n APICall(path: \"tickets/#{id}.json\")\n\n end",
"def index\n \t@clickers = Clicker.all\t\t\t\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clickers }\n end\n end",
"def get_ticket\n ticket_details = self.class.get(\"/rest/api/2/issue/\", :verify => false)\n File.open(\"custom.txt\", 'w') {|f| f.write(ticket_details) }\n end",
"def disp_xml_rq\n body= File.open(\"public/OTA/OTA_HotelAvailRQ100.xml\").read\n render :xml => body\n end",
"def index\n @borrower_residences = BorrowerResidence.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @borrower_residences.to_xml }\n end\n end",
"def show\n @respuestum = Respuestum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @respuestum }\n end\n end",
"def show\n @ticker = Ticker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticker }\n end\n end",
"def test_solveticket\n\n # create ticket\n @zendeskclient.createticket(\"test ticket\", \"4\", 'Captain Cool', \"[email protected]\")\n assert_equal(201, @zendeskclient.responsecode)\n assert(@zendeskclient.response.to_s.match('http://rateitindia.zendesk.com'))\n tktcreationresponse = @zendeskclient.response\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # a new ticket; assert on the status of the ticket\n assert_equal(\"0\", doc.root.elements[\"status-id\"].text)\n\n\n ticketid = ZenDeskAPI.extractid(tktcreationresponse)\n\n\n # solve the ticket and test for the http error code\n @zendeskclient.solveticket(\"31198262\", ticketid)\n assert_equal(200, @zendeskclient.responsecode)\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # after solving the ticket; assert on the status of the ticket\n assert_equal(\"3\", doc.root.elements[\"status-id\"].text)\n\n end",
"def download_xml\n\t\turi = URI.parse(\"http://www.esmadrid.com/opendata/tiendas_v1_es.xml\")\n\t\tresponse = Net::HTTP.get_response(uri)\n\t\tcontent = response.body\n\n\t\txml = REXML::Document.new(content)\n\n\t\treturn xml\n\tend",
"def show\n respond_to do |wants|\n wants.html # show.html.erb\n wants.xml { render :xml => @ticket }\n wants.json { render :json => @ticket }\n end\n end",
"def index\n @received_issues = ReceivedIssue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @received_issues }\n end\n end",
"def index\n\t @tickets = Ticket.order('created_at DESC').page(params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def find_tickets(res)\n if res.key?(\"tickets\")\n tickets_info = res[\"tickets\"]\n @tickets = []\n tickets_info.each do |ticket_info|\n ticket = Ticket.new(ticket_info) \n @tickets << ticket\n end\n @tickets\n elsif res.key?(\"error\")\n raise res[\"error\"]\n else\n raise \"unknown error from API\"\n end\n end",
"def index\n @kontakties = Kontakty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @kontakties }\n end\n end",
"def show\n authorize! :read, Show, Ticketrez, Ticketsection\n @ticketrezs = @show.ticketrezs\n @ticketsections = @show.ticketsections\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @show }\n end\n end",
"def index\n @lookup_scantasks = LookupScantask.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_scantasks }\n end\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def show\n \n@clicker = Clicker.find(params[:id])\n\n \nrespond_to do |format|\n \nformat.html # show.html.erb\n \nformat.xml { render :xml => @clicker+\"yyyyy\" }\n \n end\n \nend",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def index\n @sprint = params[:sprint].presence || Sprint.current!\n @tickets = Ticket.for_sprint(@sprint).by_created_at_desc\n @tickets = @tickets.for_project(params[:project]) if params[:project].present?\n @tickets = @tickets.for_user(params[:user]) if params[:user].present?\n @tickets = @tickets.search_name(params[:description]) if params[:description].present?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def cyberstock\n @classifieds = Cyberstock.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end",
"def index\n @components_rear_tires = Components::RearTire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @components_rear_tires }\n end\n end",
"def index\n @votes = @retort.votes.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @votes }\n end\n end",
"def index\n @fixed_deposits = FixedDeposit.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fixed_deposits }\n end\n end",
"def index\n respond_with(@tickets)\n end",
"def index\n @title = \"Tickets\"\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @requisition }\n end\n end",
"def show\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tso.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end",
"def index\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ticket }\n end\n end",
"def show\n @retailorder = Retailorder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @retailorder }\n end\n end",
"def index\n @uitgelichts = Uitgelicht.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uitgelichts }\n end\n end",
"def index\n @sprints = Sprint.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sprints.to_xml }\n end\n end",
"def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end",
"def index\n @requests = Request.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requests }\n end\n end",
"def index\n @entries = @resource_finder.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def show\n @breadcrumb = 'read'\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ticket }\n end\n end",
"def expired\n @classifieds = Cyberstock.expired.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end",
"def get_events_for_ticket( session_key, ticket_id)\n response_xml = self.call( :get_events_for_ticket, message: {\n arg0: session_key,\n arg1: ticket_id\n })\n response = IssueCentre::Response.parse( response_xml)\n end",
"def get_trucker_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_trucker(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def index\n @homework_return_requests = HomeworkReturnRequest.order('created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @homework_return_requests }\n end\n end",
"def get(options = {})\n @response_xml = options[:cache_file] ? File.read(options[:cache_file]) : http_get(options)\n response = Response.parse(response_xml, options) do | inner_response, elements |\n parse_reports(inner_response, elements)\n end\n response.response_items.first # there is is only one\n end",
"def sru_response\n # Create bib record.\n title_str = OLE_QA::Framework::String_Factory.alphanumeric(12)\n author_str = OLE_QA::Framework::String_Factory.alphanumeric(14)\n today = Time.now.strftime('%Y%m%d-%H%M')\n bib_ary = [{\n :tag => '245',\n :ind_1 => '',\n :ind_2 => '',\n :value => '|a' + title_str\n },\n {\n :tag => '100',\n :ind_1 => '',\n :ind_2 => '',\n :value => '|a' + author_str\n }]\n bib_editor = OLE_QA::Framework::OLELS::Bib_Editor.new(@ole)\n bib_editor.open\n create_bib(bib_editor,bib_ary)\n query = \"title any #{title_str}\"\n filename = \"sru_perf-#{today}.xml\"\n get_sru_file(query,filename,@ole)\n records = get_marc_xml(filename)\n verify(5) {File.zero?(\"data/downloads/#{filename}\") == false}\n verify(5) {records.count == 1}\n end",
"def index\n @reviewers = Reviewer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reviewers }\n end\n end",
"def index\n @frequencia_setores = Frequencia::Setor.order('updated_at ASC').paginate :page => params[:page], :per_page => 10\n @total = Frequencia::Setor.all.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @frequencia_setores }\n end\n end",
"def show\n @ticketorder = Ticketorder.find(params[:id])\n @seller = Seller.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticketorder }\n end\n end",
"def my_tickets\n user = current_user.id if !current_user.nil?\n # OCO\n init_oco if !session[:organization]\n\n @search = Ticket.search do\n fulltext params[:search]\n if session[:organization] != '0'\n with :organization_id, session[:organization]\n end\n if !user.blank?\n with :created_by, user\n end\n with(:ticket_status_id).less_than(4)\n order_by :id, :desc\n paginate :page => params[:page] || 1, :per_page => per_page\n end\n\n @tickets = @search.results\n\n respond_to do |format|\n format.html # my_tickets.html.erb\n format.json { render json: @tickets }\n end\n end",
"def show\n @user_testcase_xref = UserTestcaseXref.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_testcase_xref }\n end\n end",
"def index\n @lookup_sets = LookupSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_sets }\n end\n end",
"def print_my_recent_bookmarks(username, password)\n # Make the HTTPS request.\n response = open('https://api.del.icio.us/v1/posts/recent',\n :http_basic_authentication => [username, password])\n\n # Read the response entity-body as an XML document.\n xml = response.read\n\n # Turn the document into a data structure.\n document = REXML::Document.new(xml)\n\n # For each bookmark...\n REXML::XPath.each(document, \"/posts/post\") do |e|\n # Print the bookmark's description and URI\n puts \"#{e.attributes['description']}: #{e.attributes['href']}\"\n end\nend",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @download_registrations }\n end\n end",
"def index\n @qxes = Qx.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @qxes }\n end\n end",
"def show\n @retailorderdetail = Retailorderdetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @retailorderdetail }\n end\n end",
"def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def show\n @frequencia_setor = Frequencia::Setor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb.erb\n format.xml { render :xml => @frequencia_setor }\n end\n end",
"def index\n @help = \"Recurring Transaction List\"\n @recurrings = @account.recurrings\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @recurrings }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @chronopay_links }\n end\n end",
"def index\r\n @purchase_requisition_categories = PurchaseRequisitionCategory.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @purchase_requisition_categories }\r\n end\r\n end",
"def index\n @employees = $Vendor.employees.scopied.order(\"created_at desc\").page(params[:page]).per(25)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @employees }\n end\n end",
"def index\n\n if request.format == Mime::XML\n limit=params[:limit].nil? ? 1000: params[:limit]\n else\n limit=params[:limit].nil? ? 50 : params[:limit]\n end\n\n @reservations = Reservation.paginate :page => params[:page] || 1, :per_page => limit, :conditions => [\"user_id = ? AND historical = ?\", session[:user_id], 0], :order => \"id\"\n\n respond_to do |format|\n format.xml { render :xml => @reservations }\n format.any { render :json => @reservations }\n end\n end",
"def index\n @transaction_details = TransactionDetail.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @transaction_details.to_xml }\n end\n end",
"def create\n respond_to do |format|\n if @ticketrez.save\n flash[:notice] = 'Ticketrez was successfully created.'\n format.html { redirect_to(@ticketrez) }\n format.xml { render :xml => @ticketrez, :status => :created, :location => @ticketrez }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticketrez.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def get_substrates()\n\tputs \"Getting list of substrates.\"\n\tresponse = request_get('/api/partner/substrate')\n\tputs response.body\nend",
"def index\n @sprints = @product.sprints\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sprints }\n end\n end",
"def retired_index\n @rigs = Rig.inactive\n @main_header = \"Retired Rigs\"\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rigs }\n end\n end",
"def index\n @transport_lines = TransportLine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transport_lines }\n end\n end",
"def index\n debugger\n @receitas = Receita.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receitas }\n end\n end",
"def index\n @estatus = Estatu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estatus }\n end\n end",
"def new\n @ticket = Ticket.new\n @page_title = \"New Ticket\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket }\n end\n\n end",
"def index\n @truck = Truck.find(params[:truck_id])\n @service_logs = ServiceLog.find_all_by_truck_id(params[:truck_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @service_logs }\n end\n end",
"def index\n @revenus = @foyer.revenus\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @revenus }\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 index\n \n @inquiries = Inquiry.all(:order => 'id desc').paginate(:page => params[:page], :per_page=>15)\n\n respond_to do |format|\n format.html { render 'index' }\n format.xml { render :xml => @inquiries }\n end\n end",
"def index\n @certs = Cert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @certs }\n end\n end"
] | [
"0.7217497",
"0.6822987",
"0.6659201",
"0.6529385",
"0.6438048",
"0.6419128",
"0.6352116",
"0.6258671",
"0.6258671",
"0.6258671",
"0.6258671",
"0.6258671",
"0.6258671",
"0.6219957",
"0.6171344",
"0.6058073",
"0.6005899",
"0.59724534",
"0.59609616",
"0.5912952",
"0.5873086",
"0.585856",
"0.58485234",
"0.5848386",
"0.5847438",
"0.5801957",
"0.58011276",
"0.5787355",
"0.5759229",
"0.5750709",
"0.57385236",
"0.5728194",
"0.5721559",
"0.57092726",
"0.57008404",
"0.56905735",
"0.5681616",
"0.56508523",
"0.5647325",
"0.5645098",
"0.563988",
"0.56394064",
"0.56345063",
"0.56309384",
"0.56268954",
"0.56229734",
"0.56214535",
"0.56081396",
"0.56071633",
"0.56054413",
"0.5603698",
"0.5598889",
"0.558646",
"0.55845034",
"0.55829775",
"0.5579746",
"0.55752003",
"0.5571653",
"0.5570362",
"0.5570236",
"0.5569614",
"0.5566716",
"0.5562047",
"0.5561246",
"0.5556973",
"0.5551341",
"0.554913",
"0.55470484",
"0.5546161",
"0.5539938",
"0.5527736",
"0.55231464",
"0.5514908",
"0.5511228",
"0.5508643",
"0.5499632",
"0.5491706",
"0.5491095",
"0.54899156",
"0.5489059",
"0.54887843",
"0.5487956",
"0.54855907",
"0.54825187",
"0.54784435",
"0.54765123",
"0.54762346",
"0.54745036",
"0.5474498",
"0.54733866",
"0.5471207",
"0.54643697",
"0.5458229",
"0.5456948",
"0.54554075",
"0.54467547",
"0.544065",
"0.5437971",
"0.54317254",
"0.54314965"
] | 0.600243 | 17 |
GET /ticketrezs/new GET /ticketrezs/new.xml | def new
@show = Show.find_by_abbrev(params[:abbrev])
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @ticketrez }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def new\n @ticket = Ticket.new\n @page_title = \"New Ticket\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket }\n end\n\n end",
"def new\n @ticket = OTRS::Ticket.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @ticket }\n wants.json { render :json => @ticket }\n end\n end",
"def new\n @ticket_type = TicketType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket_type }\n end\n end",
"def create\n respond_to do |format|\n if @ticketrez.save\n flash[:notice] = 'Ticketrez was successfully created.'\n format.html { redirect_to(@ticketrez) }\n format.xml { render :xml => @ticketrez, :status => :created, :location => @ticketrez }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticketrez.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n #@matches = Match.all\n @title = \"New Ticket\"\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def new\n @ticket = Ticket.new(sprint: Sprint.current!)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def create\n @ticket = OTRS::Ticket.new(params[:ticket])\n\n respond_to do |wants|\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n wants.html { redirect_to(@ticket) }\n wants.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n wants.json { render :json => @ticket, :status => :created, :location => @ticket }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n wants.json { render :json => @ticket.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @ticket_seller = TicketSeller.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket_seller }\n end\n end",
"def new\n @travel_fix = TravelFix.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel_fix }\n end\n end",
"def getNew\n\t\[email protected] ['id', 'pid', 'title', 'tracker', 'created'], ['status', 'new']\n\tend",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def new\n @ticket = Ticket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n\n respond_to do |format|\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n format.html { redirect_to(@ticket) }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end",
"def new\n @ticket = Ticket.new\n @seances = Seance.find(:all)\n @cinemas = Cinema.find(:all)\n @cinema_films = CinemaFilm.find(:all)\n @films = Film.find(:all)\n @seats = Seat.find(:all)\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def new\n @new_employee_request = NewEmployeeRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @new_employee_request }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @tpago = Tpago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tpago }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lease }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def new\n @events = Event.find(:all, :conditions => [\"user_id = ?\", self.current_user.id])\n @ticket = Ticket.new\n @ticket.event_id = params[:ticket][:event_id]\n\n respond_to do |format|\n if @events.length >= 1\n format.html # new.html.erb\n format.xml { render :xml => @ticket }\n else\n format.html { redirect_to new_event_path()}\n end\n end \n end",
"def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end",
"def new\n @t1 = T1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @t1 }\n end\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to(@ticket, :notice => 'Bilet został pomyślnie utworzony.') }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @occurence = Occurence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occurence }\n end\n end",
"def new\n @press = Press.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @press }\n end\n end",
"def new\n @sprint = Sprint.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @tracker = Tracker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tracker }\n end\n end",
"def new\n @reqinfo = Reqinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reqinfo }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fund_request }\n end\n end",
"def new\n @journal = Journal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journal }\n end\n end",
"def new\n @tx = Tx.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tx }\n end\n end",
"def new\n @renewal = Renewal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @renewal }\n end\n end",
"def new\n @requisition = Requisition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisition }\n end\n end",
"def new\n @show = @ticketalert.show\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ticketalert }\n end\n end",
"def new\n @temp = Temp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @temp }\n end\n end",
"def new\n @travel = Travel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel }\n end\n end",
"def new\n @travel = Travel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @notifier }\n end\n end",
"def new_rest\n @entry_answer = EntryAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_answer }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\n end\n end",
"def new\n @newz = Newz.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newz }\n end\n end",
"def new\n topic = Topic.find params[:topic_id]\n @ticket = Ticket.where(:topic_id => topic.id, :user_id => current_user.id).first\n return render :text => '你已投过票' if @ticket\n @ticket = Ticket.new :topic_id => topic.id\n @ticket_types = TicketType.where('weight < 0')\n\n respond_to do |format|\n format.html { render :layout => false}\n format.xml { render :xml => @ticket }\n end\n end",
"def new\n @click_to_talk = ClickToTalk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @click_to_talk }\n end\n end",
"def new\n @testcase = Testcase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @testcase }\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def new\n @breadcrumb = 'create'\n @ticket_priority = TicketPriority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket_priority }\n end\n end",
"def new\n @pr = Pr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pr }\n end\n end",
"def new\n @receipt = Receipt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receipt }\n end\n end",
"def new\n @ref = Ref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ref }\n end\n end",
"def new\n @lookup_truthtable = LookupTruthtable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_truthtable }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software }\n end\n end",
"def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end",
"def new\n @lookup_pettracer = LookupPettracer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end",
"def new\n @lookup_pettracer = LookupPettracer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end",
"def new\n @journalentry = Journalentry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journalentry }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n @tps_report = TpsReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tps_report }\n end\n end",
"def new\n @mailfetch = Mailfetch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mailfetch }\n end\n end",
"def new\n @sticker = Sticker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sticker }\n end\n end",
"def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @borrow }\n end\n end",
"def new\n @tipp = Tipp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipp }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @patron = Patron.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patron }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @ticket = Ticket.new\n @event = Event.find params[:event_id]\n @tiers = @event.tiers\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lore }\n end\n end",
"def new\n @hpt_history = HptHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hpt_history }\n end\n end",
"def new\n @receita = Receita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receita }\n end\n end",
"def new\n @clicker = Clicker.new\n\n \n respond_to do |format|\n \n format.html # new.html.erb\n \nformat.xml { render :xml => @clicker }\n \n end\n \nend",
"def new\n logger.debug 'new_some interesting information'\n @comdty = Comdty.new\n setvariables\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comdty }\n end\n end",
"def new\n @breadcrumb = 'create'\n @ticket = Ticket.new\n $attachment = Attachment.new\n destroy_attachment\n @offices = offices_dropdown\n @technicians = technicians_dropdown\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ticketrezs }\n end\n end",
"def new\n @travel_log = TravelLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel_log }\n end\n end",
"def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scraper }\n end\n end",
"def new\n @typo = Typo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @typo }\n end\n end",
"def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end",
"def new\n @retain_node = RetainNode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retain_node }\n format.json { render :json => @retain_node }\n end\n end",
"def new\n @lookup_rad = LookupRad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_rad }\n end\n end",
"def new\n @serie = Serie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @serie }\n end\n end",
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @invoice }\n end\n end",
"def new\n @latestinfo = Latestinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @latestinfo }\n end\n end",
"def new\n @tcliente = Tcliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tcliente }\n end\n end",
"def new\n respond_to do |format|\n format.xml { render :xml => @schedule }\n end\n end",
"def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @po }\n end\n end",
"def newX\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @server }\n end\n end",
"def new\n @Roc = Roc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @Roc }\n end\n end",
"def new\n @tdoc = Tdoc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tdoc }\n end\n end"
] | [
"0.7298363",
"0.7298363",
"0.7298363",
"0.7298363",
"0.72870874",
"0.71958387",
"0.7041266",
"0.69705427",
"0.6679059",
"0.66732913",
"0.66107196",
"0.65843314",
"0.6580438",
"0.6559251",
"0.6538751",
"0.6493178",
"0.64846313",
"0.64846313",
"0.64846313",
"0.64846313",
"0.6457264",
"0.6447166",
"0.6441959",
"0.6434376",
"0.6432204",
"0.6432204",
"0.64255464",
"0.6419863",
"0.64136297",
"0.6409478",
"0.6376924",
"0.6372531",
"0.6368564",
"0.63654655",
"0.6356113",
"0.6356",
"0.6346236",
"0.6339661",
"0.6338905",
"0.63383317",
"0.6329918",
"0.6325265",
"0.6325119",
"0.6317566",
"0.63149714",
"0.63125736",
"0.6312477",
"0.6304214",
"0.630097",
"0.630097",
"0.62942535",
"0.62935114",
"0.6286994",
"0.6283233",
"0.6271339",
"0.6268823",
"0.6265111",
"0.6259585",
"0.62573886",
"0.62506646",
"0.6249802",
"0.62479955",
"0.6247682",
"0.62444824",
"0.6238397",
"0.62376577",
"0.6237223",
"0.62225616",
"0.6220164",
"0.6219659",
"0.62167025",
"0.6211323",
"0.6208441",
"0.6205123",
"0.62027407",
"0.62006",
"0.6200236",
"0.61965305",
"0.61896163",
"0.61825085",
"0.6182364",
"0.61823404",
"0.6182001",
"0.6179638",
"0.6179563",
"0.6178393",
"0.6178193",
"0.617774",
"0.61763954",
"0.617627",
"0.6174456",
"0.61730576",
"0.61713934",
"0.61642087",
"0.6163833",
"0.6163343",
"0.6161772",
"0.61608213",
"0.6159906",
"0.6155728",
"0.6154945"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.