query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Return true if the sequence is stable.
def stable? (instability_index <= 40) ? true : false end
[ "def increasing_sequence?(seq)\n\tseq.inject {|mem, x| return false if mem >= x; x}\n\ttrue\nend", "def stable\n self[:draft] == false && self[:prerelease] == false\n end", "def deterministic?\n @states.each{|s| return false if not s.deterministic_transitions? }\n return true\n end", "def sequential\n return true if hand_to_val.last - hand_to_val.first == 4\n return false \n end", "def consistent?\n return report_validity(@bag.consistent?)\n end", "def is_stable?\n\n Uhuru::RepositoryManager::Model::Versions.get_versions(:product_id => self.id, :stable => true).count > 0\n\n end", "def consistent?\n return @grammar.consistent?\n end", "def empty_sequence?\n false\n end", "def exact_version?\n self.begin == self.end\n end", "def sequence?(diff=1)\n tmp = self.sort\n \n tmp.upto(tmp.size-2) do |i, val|\n return false unless val + diff == tmp[i+1]\n end\n \n true\n end", "def complete?\n return nil unless ivsat_table\n line = ivsat_table.split(\"\\n\").find{|l| l.include? 'INFO: Sequence completeness:' }\n line && !line.include?('partial')\n end", "def seq_number?\n @seq_number > NO_SEQ_NUMBER\n end", "def check_sequence(test_seq)\n return !@found_sequences.has_key?(test_seq)\n end", "def already_published?\n return false if Algorithm.where(next: self).empty? # Algorithm has no predecessor yet\n return true\n end", "def consistent?\n @grammar.consistent?\n end", "def deterministic?\n @deterministic = @states.all?{|s| s.deterministic?} if @deterministic.nil?\n @deterministic\n end", "def is_stable?\n # Every person's partner should match up\n @matches.all? { |k,v| is_matched?(k, v) }\n end", "def reverted?\n version != last_version\n end", "def sticky?\n revision.stickied == 1\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculate aliphatic index of an AA sequence. _The aliphatic index of a protein is defined as the relative volume occupied by aliphatic side chains (alanine, valine, isoleucine, and leucine). It may be regarded as a positive factor for the increase of thermostability of globular proteins._
def aliphatic_index aa_map = aa_comp_map @aliphatic_index ||= round(aa_map[:A] + 2.9 * aa_map[:V] + (3.9 * (aa_map[:I] + aa_map[:L])), 2) end
[ "def instability_index\n @instability_index ||=\n begin\n instability_sum = 0.0\n i = 0\n while @seq[i+1] != nil\n aa, next_aa = [@seq[i].chr.to_sym, @seq[i+1].chr.to_sym]\n if DIWV.key?(aa) && DIWV[aa].key?(next_aa)\n instability_sum += DIWV[aa][next_aa]\n end\n i += 1\n end\n round((10.0/amino_acid_number.to_f) * instability_sum, 2)\n end\n end", "def calcSectionAOAA(buf,channel, startIndex, endIndex)\n aoaa = 0\n (startIndex..endIndex).each { |x| aoaa += (buf[x][channel]).abs() }\n aoaa / (endIndex - startIndex + 1)\n end", "def get_AIBC(i)\n @@tam = @medidas.length\n if i >= @@tam\n return 0\n else\n return (((@medidas[i] - @medidas[0]) + (@medidas[i - 1] - @medidas[0])) / 24) + get_AIBC(i + 1)\n end\n end", "def calculate(hexagram)\n upper_trigram = hexagram.lines[0...3]\n lower_trigram = hexagram.lines[3...6]\n SEQUENCE_NUMBER[[lower_trigram, upper_trigram]]\n end", "def acidic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n ACIDIC_AMINO_ACIDS.each do |acidic|\n if comp[acidic]\n count += comp[acidic]\n end\n end\n return count\n end", "def get_aa_array(initial_position = 0)\n @aa_array = []\n require_sequence = @dna_sequence[initial_position..-1].tr('-','N')\n base_array = []\n require_sequence.each_char {|base| base_array << base}\n while (base_array.length>=3) do\n base_3= \"\"\n 3.times{base_3 += base_array.shift}\n @aa_array<< amino_acid_2(base_3)\n end\n end", "def calcPercentIdent(fasta)\n pos = nil\n idents = []\n len = nil\n counts = 0\n Bio::FlatFile.new(Bio::FastaFormat, File.new(fasta)).each do |seq1|\n len = seq1.length if len.nil?\n Bio::FlatFile.new(Bio::FastaFormat, File.new(fasta)).each do |seq2|\n next if seq2.full_id == seq1.full_id\n idents.push(0)\n seq1.length.times do |i|\n idents[idents.size - 1] += 1 if (seq1.seq[i] == seq2.seq[i])\n end\n end\n end\n tot = 0\n idents.each {|ident| tot+=ident}\n avIdent = (tot * 100 / idents.size) / len\n return avIdent\nend", "def basic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n BASIC_AMINO_ACIDS.each do |basic|\n if comp[basic]\n count += comp[basic]\n end\n end\n return count\n end", "def aibc(index)\n auxiliar = []\n data[index][1..data[index].length - 1].zip(data[index][0..data[index].length-2]) do |x,y|\n if x < data[index][0]\n auxiliar << 0.0\n else\n auxiliar << (((x - data[index][0]) + (y - data[index][0]))/2) * 5\n end\n end\n auxiliar.reduce(:+)\nend", "def getAlphabeticalPosition()\n \n @alphabeticalPosition = returnPermutationsBefore(@multiLetterDivisor) + 1\n \n end", "def amino_acid (bases)\n case bases\n when /^TT[TCY]$/\n return \"F\"\n when /^TT[AGR]$/\n return \"L\"\n when /^CT.$/\n return \"L\"\n when /^AT[TCAHYWM]$/\n return \"I\"\n when \"ATG\"\n return \"M\"\n when /^GT.$/\n return \"V\"\n when /^TC.$/\n return \"S\"\n when /^CC.$/\n return \"P\"\n when /^AC.$/\n return \"T\"\n when /^GC.$/\n return \"A\"\n when /^TA[TCY]$/\n return \"Y\"\n when /^TA[AGR]$/\n return \"*\"\n when /^T[GR]A$/\n return \"*\"\n when /^CA[TCY]$/\n return \"H\"\n when /^CA[AGR]$/\n return \"Q\"\n when /^AA[TCY]$/\n return \"N\"\n when /^AA[AGR]$/\n return \"K\"\n when /^GA[TCY]$/\n return \"D\"\n when /^GA[AGR]$/\n return \"E\"\n when /^TG[TCY]$/\n return \"C\"\n when \"TGG\"\n return \"W\"\n when /^CG.$/\n return \"R\"\n when /^AG[TCY]$/\n return \"S\"\n when /^[AM]G[AGR]$/\n return \"R\"\n when /^GG.$/\n return \"G\"\n when /^[ATW][CGS][CTY]$/\n return \"S\"\n when /^[TCY]T[AGR]$/\n return \"L\"\n else\n return \"#\"\n end\n end", "def calculate_accidental_from_pitch(value)\n ACCIDENTALS_FOR_PITCH[value % 12]\n end", "def amino_acid_2 (bases)\n bases_to_aa = []\n aa_list = []\n base1 = bases[0].to_list\n base2 = bases[1].to_list\n base3 = bases[2].to_list\n l1 = base1.size - 1\n l2 = base2.size - 1\n l3 = base3.size - 1\n (0..l1).each do |n1|\n b1 = base1[n1]\n (0..l2).each do |n2|\n b2 = base2[n2]\n (0..l3).each do |n3|\n b3 = base3[n3]\n bases_all = b1 + b2 + b3\n bases_to_aa << bases_all\n end\n end\n end\n\n bases_to_aa.each do |base|\n case base\n when /^TT[TCY]$/\n aa = \"F\"\n when /^TT[AGR]$/\n aa = \"L\"\n when /^CT.$/\n aa = \"L\"\n when /^AT[TCAHYWM]$/\n aa = \"I\"\n when \"ATG\"\n aa = \"M\"\n when /^GT.$/\n aa = \"V\"\n when /^TC.$/\n aa = \"S\"\n when /^CC.$/\n aa = \"P\"\n when /^AC.$/\n aa = \"T\"\n when /^GC.$/\n aa = \"A\"\n when /^TA[TCY]$/\n aa = \"Y\"\n when /^TA[AGR]$/\n aa = \"*\"\n when /^T[GR]A$/\n aa = \"*\"\n when /^CA[TCY]$/\n aa = \"H\"\n when /^CA[AGR]$/\n aa = \"Q\"\n when /^AA[TCY]$/\n aa = \"N\"\n when /^AA[AGR]$/\n aa = \"K\"\n when /^GA[TCY]$/\n aa = \"D\"\n when /^GA[AGR]$/\n aa = \"E\"\n when /^TG[TCY]$/\n aa = \"C\"\n when \"TGG\"\n aa = \"W\"\n when /^CG.$/\n aa = \"R\"\n when /^AG[TCY]$/\n aa = \"S\"\n when /^[AM]G[AGR]$/\n aa = \"R\"\n when /^GG.$/\n aa = \"G\"\n when /^[ATW][CGS][CTY]$/\n aa = \"S\"\n when /^[TCY]T[AGR]$/\n aa = \"L\"\n else\n aa = \"-\"\n end\n aa_list << aa\n end\n aa_out = aa_list.uniq.join\n return aa_out\n end", "def calculateAnnuity\n rate = @i /100.0\n @pmt*((1 - (1 / ((1 + rate)**@n))) / rate)\n end", "def calculate_number_of_possible_RNAs_from_prot(protseq)\r\n result = 1 #Variable for returning product of each aac number of codons\r\n stop = 3 #Variable for remembering that we have to take account of the stop codons too\r\n codons ={\"GCU\"=>\"A\",\"GCC\"=>\"A\",\"GCA\"=>\"A\",\"GCG\"=>\"A\",\"GUU\"=>\"V\",\"GUC\"=>\"V\",\r\n \"GUA\"=>\"V\",\"GUG\"=>\"V\",\"GAU\"=>\"D\",\"GAC\"=>\"D\",\"GAA\"=>\"E\",\"GAG\"=>\"E\",\r\n \"GGU\"=>\"G\",\"GGC\"=>\"G\",\"GGA\"=>\"G\",\"GGG\"=>\"G\",\"AUU\"=>\"I\",\"AUC\"=>\"I\",\r\n \"AUA\"=>\"I\",\"AUG\"=>\"M\",\"ACU\"=>\"T\",\"ACC\"=>\"T\",\"ACA\"=>\"T\",\"ACG\"=>\"T\",\r\n \"AAU\"=>\"N\",\"AAC\"=>\"N\",\"AAA\"=>\"K\",\"AAG\"=>\"K\",\"AGU\"=>\"S\",\"AGC\"=>\"S\",\r\n \"AGA\"=>\"R\",\"AGG\"=>\"R\",\"CUU\"=>\"L\",\"CUC\"=>\"L\",\"CUA\"=>\"L\",\"CUG\"=>\"L\",\r\n \"CCU\"=>\"P\",\"CCC\"=>\"P\",\"CCA\"=>\"P\",\"CCG\"=>\"P\",\"CAU\"=>\"H\",\"CAC\"=>\"H\",\r\n \"CAA\"=>\"Q\",\"CAG\"=>\"Q\",\"CGU\"=>\"R\",\"CGC\"=>\"R\",\"CGA\"=>\"R\",\"CGG\"=>\"R\",\r\n \"UUU\"=>\"F\",\"UUC\"=>\"F\",\"UUA\"=>\"L\",\"UUG\"=>\"L\",\"UCU\"=>\"S\",\"UCC\"=>\"S\",\r\n \"UCA\"=>\"S\",\"UCG\"=>\"S\",\"UAU\"=>\"Y\",\"UAC\"=>\"Y\",\"UAA\"=>\"STOP\",\r\n \"UAG\"=>\"STOP\",\"UGU\"=>\"C\",\"UGC\"=>\"C\",\"UGA\"=>\"STOP\",\"UGG\"=>\"W\"}\r\n \r\n protseq.each_char do |aac|\r\n count = 0 #it saves the number of codons that produce a certain aminoacid\r\n codons.each do |codon, translated_codon|\r\n if translated_codon == aac\r\n count += 1\r\n end\r\n end\r\n result *= count\r\n end\r\n return (result * stop) % 1000000\r\nend", "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 angle_a\n Angle.new(\n self,\n :a,\n (\n (\n Math.acos((b**2 + c**2 - a**2) / (2.0 * b * c)) * 180\n ) / Math::PI\n )\n )\n end", "def consensus\n\t\t\t\tsequence = \"\"\n\t\t\t\t(0...@length).each do |i|\n\t\t\t\t\tmaximum = -Float::INFINITY\n\t\t\t\t\tfor letter in @alphabet.letters\n\t\t\t\t\t\tcount = self[letter][i]\n\t\t\t\t\t\t\n\t\t\t\t\t\tif count > maximum\n\t\t\t\t\t\t\tmaximum = count\n\t\t\t\t\t\t\tsequence_letter = letter\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tsequence += sequence_letter\n\t\t\t\tend\n\n\t\t\t\treturn Bio::Sequence.auto(sequence)\n\t\t\tend", "def calculate_american\n value = @value.rationalize\n if value >= 0.5\n - ( value / (1 - value)) * 100\n else\n ((1 - value) / value ) * 100\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculate GRAVY score of an AA sequence. _The GRAVY(Grand Average of Hydropathy) value for a peptide or protein is calculated as the sum of hydropathy values [9] of all the amino acids, divided by the number of residues in the sequence._
def gravy @gravy ||= begin hydropathy_sum = 0.0 each_aa do |aa| hydropathy_sum += HYDROPATHY[aa] end round(hydropathy_sum / @seq.length.to_f, 3) end end
[ "def raw_gpa\n tot_grade_points/tot_graded_attmp rescue 0.0/0.0\n end", "def get_gpa\n total = registrations.where('grade is not null').inject(0){|sum, c| sum + c.grade}\n if total != 0\n # binding.pry\n final_gpa = total.to_f / (self.registrations.where('grade is not null').count).to_f\n self.update(gpa:final_gpa.round(2))\n puts \"\\nYour total GPA is: #{self.gpa}\"\n else\n puts \"\\nYou dont have any grades yet\"\n end\n\n end", "def get_gpa(text_array)\n resume_as_array = resume_to_array(text_array)\n gpa = nil\n resume_as_array.each_with_index do |t, i|\n if gpa == nil\n if t.include?('gpa') || t.include?('grade') || t.include?('g.p.a')\n gpa = t.match(/[0-4][.][0-9][0-9]/)\n if gpa == nil\n gpa = t.match(/[0-4][.][0-9]/)\n if gpa == nil\n gpa = resume_as_array[i + 1].match(/[0-4][.][0-9][0-9]/)\n if gpa == nil\n gpa = resume_as_array[i + 1].match(/[0-4][.][0-9]/)\n if gpa == nil\n gpa = resume_as_array[i - 1].match(/[0-4][.][0-9][0-9]/)\n if gpa == nil\n gpa = resume_as_array[i - 1].match(/[0-4][.][0-9]/)\n end\n end\n end\n end\n end\n end\n end\n end\n if gpa != nil\n gpa = gpa[0].to_f\n end\n return gpa\nend", "def g_score(previous_g)\n @g = previous_g + @cost\n @f = @g + @h\n end", "def gross_score\n spread_credit.to_i + (right_antler.lg_antler + right_antler.lg_points.to_i) + (left_antler.lg_antler + left_antler.lg_points.to_i)\n end", "def average_score()\n\n total_score = 0\n grades.each { |grade| total_score += grade }\n average = total_score / grades.length\n\n return average\n\n end", "def grand_average_of_hydropathy\n hydrophopathy_profile.inject{|sum,x| sum + x }.to_f/seq.length\n end", "def getGPA(reportText)\n gpaSummary = Hash.new()\n # We need to scan this way due to DARS formatting\n gpaArray = Array.new()\n gpaArray = reportText.scan(/(\\d\\.\\d{2}) GPA/)\n if gpaArray == nil\n gpaArray = ['0.00', '0.00']\n elsif gpaArray.length == 1\n gpaArray[1] = '0.00'\n end\n\n gpaSummary[:cumulativeGPA] = gpaArray[0][0]\n gpaSummary[:majorGPA] = gpaArray[1][0]\n return gpaSummary\nend", "def gross_score\n return (adjusted_score - competition.css)\n end", "def quarter_gpa(quarter = nil)\n t = transcripts.find(system_key, quarter.year, quarter.quarter_code_id) rescue nil\n raw_gpa = t.nil? ? nil : (t.qtr_grade_points/t.qtr_graded_attmp) rescue nil\n '%.2f' % raw_gpa rescue \"unknown\" \n end", "def GEI_total\n\t\tr = 0\n n = @alimentos.head\n i = @gramos.head\n\n while !n.nil?\n\n r += ((n.value.gei)*(i.value/100))\n n = n.next\n i = i.next\n end\n\n\t\t\n\n return (r).round(2)\n\tend", "def gases_total\n\t\tsuma = 0\n\n\t\t@gases.each do |i|\n\t\t\tsuma += i\n\t\tend\n\n\t\tsuma = suma.round(2)\n\tend", "def gams\r\n surveyid =~ /(GA-?(\\d\\d\\d\\d|\\d\\d\\d))/i\r\n return $2.to_s.rjust(4, '0') if $2 \r\n # look in comments\r\n comments =~ /GAMS\\s*=\\s*(\\d+);/i\r\n return $1.to_s.rjust(4, '0') if $1 \r\n end", "def average_grade\n total = 0\n relationships = StudentCourseRelationship.where(course_id: id)\n if relationships.count > 0\n relationships.each do |relationship|\n total += relationship.grade\n end\n (total / relationships.count).round(2)\n else\n return 0\n end\n end", "def average_score\n count = 0.0\n avrg = 0.0\n if self.cadets.empty?\n return 0.0\n else\n self.cadets.each do |cdt|\n unless cdt.discharged?\n avrg += cdt.average_score\n count += 1.0\n end\n end\n return count != 0.0 ? (avrg/count).round(1) : 0.0\n end\n end", "def get_gc_percent(dna_seq)\r\n gc_counter = 0\r\n dna_seq.upcase.each_char do |nt|\r\n if nt == \"C\" || nt == \"G\"\r\n gc_counter += 1\r\n end\r\n end\r\n gc_perc = (((gc_counter.to_f / dna_seq.length)) * 100).round(6)\r\n return gc_perc\r\nend", "def average_score\n grades.average(:score) || 0\n end", "def get_grade(array)\n sum=0\n array.each do |x|\n sum += x\n end\n avg = sum/(array.length)\n\t\tcase avg\n\t\t when 90..100\n\t\t \"A\"\n\t\t when 80..90\n\t\t \"B\"\n\t\t when 70..80\n\t\t \"C\"\n\t\t when 60..70\n\t\t \"D\"\n\t\t when 0..60\n\t\t \"F\"\n\t\t else\n\t\t \"Error\"\n\t\tend\n\n\nend", "def book_avg_rating\n y = 0.0\n self.rating.each do |x|\n y += x\n end\n puts (y/(self.rating.length)).round(1)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculate the percentage composition of an AA sequence as a Hash object. It return percentage of a given amino acid if aa_code is not nil.
def aa_comp(aa_code=nil) if aa_code.nil? aa_map = {} IUPAC_CODE.keys.each do |k| aa_map[k] = 0.0 end aa_map.update(aa_comp_map){|k,_,v| round(v, 1) } else round(aa_comp_map[aa_code], 1) end end
[ "def calcPercentIdent(fasta)\n pos = nil\n idents = []\n len = nil\n counts = 0\n Bio::FlatFile.new(Bio::FastaFormat, File.new(fasta)).each do |seq1|\n len = seq1.length if len.nil?\n Bio::FlatFile.new(Bio::FastaFormat, File.new(fasta)).each do |seq2|\n next if seq2.full_id == seq1.full_id\n idents.push(0)\n seq1.length.times do |i|\n idents[idents.size - 1] += 1 if (seq1.seq[i] == seq2.seq[i])\n end\n end\n end\n tot = 0\n idents.each {|ident| tot+=ident}\n avIdent = (tot * 100 / idents.size) / len\n return avIdent\nend", "def percent_coded_by_chr\n h = {}\n tot = self.otus.count\n otu_ids = self.otus.collect{|o| o.id}.join(\",\")\n for c in self.chrs\n v = Coding.find_by_sql(\"SELECT count(distinct otu_id) as c FROM `codings` WHERE `codings`.`chr_id` = #{c.id} AND `codings`.`otu_id` IN (#{otu_ids});\")\n h[c.id] = v.first[:c].to_f / tot.to_f\n end\n h\n end", "def overall_aroma_percentage\n overall_aroma = self.aroma_bundles.inject(0) do |memo, bundle|\n memo += bundle.percent if bundle.percent.is_a?(Integer) || bundle.percent.is_a?(BigDecimal)\n memo\n end\n\n return overall_aroma\n end", "def percent_coded_by_otu\n h = {}\n tot = self.chrs.count\n chr_ids = self.chrs.collect{|c| c.id}.join(\",\")\n for o in self.otus\n v = Coding.find_by_sql(\"SELECT count(distinct chr_id) as c FROM `codings` WHERE `codings`.`otu_id` = #{o.id} AND `codings`.`chr_id` IN (#{chr_ids});\")\n h[o.id] = v.first[:c].to_f / tot.to_f \n end\n h\n end", "def letter_percentages(str)\n count_lowercase = 0\n count_uppercase = 0\n count_neither = 0\n\n str.each_char do |char|\n if %w(1 2 3 4 5 6 7 8 9 0).include?(char)\n count_neither += 1\n elsif ('A'..'Z').include?(char)\n count_uppercase += 1\n elsif ('a'..'z').include?(char)\n count_lowercase += 1\n else\n count_neither += 1\n end\n\n end\n\n percent_lowercase = (count_lowercase.to_f / str.length) * 100\n percent_uppercase = (count_uppercase.to_f / str.length) * 100\n percent_neither = (count_neither.to_f / str.length) * 100\n\n hsh = {\n lowercase: percent_lowercase,\n uppercase: percent_uppercase,\n neither: percent_neither\n }\nend", "def letter_percentages(str)\n hash = { \"lowercase\" => 0, \"uppercase\" => 0, \"neither\" => 0 }\n leng = str.size\n hash[\"lowercase\"] = (str.count('a-z').fdiv(leng)) * 100\n hash[\"uppercase\"] = (str.count('A-Z').fdiv(leng)) * 100\n hash[\"neither\"] = (str.count('^a-zA-Z').fdiv(leng)) * 100\n\n hash\nend", "def count_percentage(array,decimal = 2)\n hash1 = Hash.new(0)\n array.each do |element|\n hash1[element] += 1\n end\n total_elements = array.size\n hash2 = Hash.new(0)\n hash1.each do |key,value|\n hash2[key] = (value/total_elements.to_f).round(decimal)\n end\n return hash2\nend", "def project_code_percentage_average project_code\n if unique_project_codes.include? project_code\n sum = 0\n self.days.each do |d|\n if d.allocations != []\n d.allocations.each do |a|\n sum += a.percentage if a.project_code == project_code\n end\n end\n end\n sum.to_f / num_days_w_allocations\n else\n 0\n end\n end", "def basic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n BASIC_AMINO_ACIDS.each do |basic|\n if comp[basic]\n count += comp[basic]\n end\n end\n return count\n end", "def calculate_percentages\n @scores.each do |key, score|\n @scores[key].percentage = percentage(score.value)\n end\n end", "def final_letter_grades(grade_hash)\n averages = grade_hash.inject({}) { |h, (k,v)| h[k] = letter_grade(v.reduce{|x,n| x += n}/v.length) ; h}\nend", "def gc_percent\n count = self.composition\n at = count['a'] + count['t'] + count['u']\n gc = count['g'] + count['c']\n gc = 100 * gc / (at + gc)\n return gc\n end", "def profile_completion_score\n attrs = [:name, :bio, :telephone]\n (attrs.reject { |attr| self.send(attr).blank? }.count.to_f / attrs.count) * 100\n end", "def acidic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n ACIDIC_AMINO_ACIDS.each do |acidic|\n if comp[acidic]\n count += comp[acidic]\n end\n end\n return count\n end", "def avg_overlap(key, sequence, tp=:number)\n if self.key? key\n numbers = num_transmem_aa(self[key], sequence)\n if numbers.size > 0\n sum = 0\n numbers.each {|num| sum += num}\n avg_num = sum.to_f / numbers.size\n # the one line way to do it\n #avg_num = numbers.inject(0) {|memo,num| num + memo }.to_f / numbers.size\n if tp == :fraction\n avg_num / sequence.size\n # this is the same as doing this:\n #numbers.inject(0.0) {|memo,num| (num.to_f/seq_size + memo) } / numbers.size\n else\n avg_num\n end\n else\n 0.0\n end\n else # what to do if the protein isn't there?? which happens on occasion\n nil\n end\n end", "def percentage\n if @total > 0\n percent = {}\n @count_per_type.each { |k, v| percent[k] = (v / @total.to_f) * 100.0 }\n {\"percent\" => percent, \"total\" => @total}\n end\n end", "def letter_percentages(str)\n percentages = {}\n str_length = str.length.to_f\n\n percentages[:lowercase] = ((str.count('a-z') / str_length) * 100).round(1)\n percentages[:uppercase] = ((str.count('A-Z') / str_length) * 100).round(1)\n percentages[:neither] = 100 - percentages[:lowercase] - percentages[:uppercase]\n\n percentages\nend", "def achievements_percentage\n @achievements.size.to_f / @schema.achievements.size\n end", "def achievements_percentage\n achievements_done.to_f / @achievements.size\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return proc calculating charge of a residue.
def charge_proc positive, pK, num if positive lambda {|ph| num.to_f / (1.0 + 10.0 ** (ph - pK)) } else lambda {|ph| (-1.0 * num.to_f) / (1.0 + 10.0 ** (pK - ph)) } end end
[ "def charge\n return @charge\n end", "def charge\n st = data['charge']\n # put the last char on the front and cast it\n (st[-1,1] + st[0...-1]).to_i\n end", "def theoretical_pI\n charges = []\n residue_count().each do |residue|\n charges << charge_proc(residue[:positive],\n residue[:pK],\n residue[:num])\n end\n round(solve_pI(charges), 2)\n end", "def parent_ion_mass(charge=1)\r\n (mass(nterm) + ladder.last + mass(cterm) + charge * proton_mass)/charge\r\n end", "def cyclospectrum(peptide)\n tmp = peptide.upcase.split('').map(&:to_sym)\n result = [0]\n\n (1...tmp.length).each do |length|\n (0...tmp.length).each do |start|\n subpeptide = tmp.rotate(start).take(length)\n # puts \"Mass of #{subpeptide} = #{mass(subpeptide)}\"\n result << mass(subpeptide)\n end\n end\n\n # Mass of full peptide\n result << mass(tmp)\n result\n end", "def formal_charge\r\n\t\tif root?\r\n\t\t\tlewis_electrons = 0\r\n\t\telse #if an element is not the root, it is bonded to another element, thus increase the formal charge count by 1\r\n\t\t\tlewis_electrons = 1\r\n\t\tend\r\n\t\t# if the element has nodes, look at each one\r\n\t\tif nodes?\r\n\t\t\tnodes.each { |node|\r\n\t\t\t\tif node == nil # if the node is unbonded, add 2\r\n\t\t\t\t\tlewis_electrons += 2\r\n\t\t\t\telse # if it is bonded, add 1\r\n\t\t\t\t\tlewis_electrons += 1\r\n\t\t\t\tend\r\n\t\t\t}\r\n\t\tend\r\n\t\t# return the valence count - the lewis count (definition of formal charge)\r\n\t\treturn PeriodicTable.valence(element) - lewis_electrons\r\n\tend", "def magnetic_field_point_charge_(charge, charge_position_, charge_velocity_, position_)\n (PERMEABILITY*charge)/(4*PI*position_.distance(charge_position_)**2)*charge_velocity_.cross_product_(position_.unit_(charge_position_))\n end", "def compute(promotion_credit)\n order = promotion_credit.order\n promotion = promotion_credit.adjustment_source\n if eligibility = promotion.eligible?(order)\n eligibility = 1 unless eligibility.is_a?(::Numeric)\n charges = order.charges.all(:conditions => {:type => self.preferred_charge_type})\n -1.0 * charges.map(&:amount).sum * eligibility\n end\n end", "def carrier_due_calculation(charge_entry_carrier_paid_amount,ins_portion,charge_entry)\n charge_entry = ChargeEntry.find(charge_entry,:include=>:contractual_adjustments)\n paid_amount = charge_entry_carrier_paid_amount.select {|k| k.id.to_s == charge_entry.id.to_s }\n adjustmetnt_amount = charge_entry.contractual_adjustments.sum(:amount).to_f\n due_amt_carrier= paid_amount.first ? ins_portion.to_f - charge_entry.write_off.to_f - paid_amount.first.amount_paid.to_f - adjustmetnt_amount : ins_portion\n return due_amt_carrier\n end", "def electric_field_point_charge_(charge, charge_position_, position_)\n (((1/(4*PI*PERMITTIVITY))*charge)/(position_.distance(charge_position_)**2))*position_.unit_(charge_position_)\n end", "def cal_rcc()\n\t\t@rcc = (@paciente.cir_cintura / @paciente.cir_cadera).round(2)\n\tend", "def calc_cadence\n # formula to calculate rpm of a wheel\n @cadence = 25 / (3 * 3.14 * 0.305) * get_speed\n return @cadence\n end", "def calMass(mass, charge)\n (mass + (charge.to_f * 1.00727646677)) / charge\n end", "def calcularComprimento(raio)\n return calcularDiametro(raio) * Math::PI\nend", "def charge_str\n data['charge']\n end", "def charges(pep_charges)\n\t2.0.step(12, 0.5).map do |ph|\n\t\tcharge_at_pH(pep_charges, ph)\n\tend\nend", "def energy_pcf\n energy_from_protein +\n energy_from_carbs +\n energy_from_fat\n end", "def relacion_cc\n @c=self.circunferencia(1)\n @ci=self.circunferencia(0)\n @relacion=@ci/@c\n end", "def charge_fee\n\t\tif_member = Participant.find_by(participantID: participantID)\n\t\tif_course = Course.find_by(courseID: courseID)\n\t\t\n\t\tif if_course != nil && if_member != nil\n\t\t\tearlyBirdTime = if_course.startDate.months_ago(1)\n\t\t\tif if_member.expirydate > Date.today\n\t\t\t\tif Date.today >= earlyBirdTime && Date.today < if_course.startDate\n\t\t\t\t\treturn if_course.earlybirdPrice\n\t\t\t\telse\n\t\t\t\t\treturn if_course.memberPrice\n\t\t\t\tend\n\t\t\telse\n\t\t\t\treturn if_course.nonmemberPrice\n\t\t\tend\n\t\tend\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Transform AA sequence into residue count
def residue_count counted = [] # N-terminal n_term = @seq[0].chr if PK[:nterm].key? n_term.to_sym counted << { :num => 1, :residue => n_term.to_sym, :pK => PK[:nterm][n_term.to_sym], :positive => positive?(n_term) } elsif PK[:normal].key? n_term.to_sym counted << { :num => 1, :residue => n_term.to_sym, :pK => PK[:normal][n_term.to_sym], :positive => positive?(n_term) } end # Internal tmp_internal = {} @seq[1,(@seq.length-2)].each_byte do |x| aa = x.chr.to_sym if PK[:internal].key? aa if tmp_internal.key? aa tmp_internal[aa][:num] += 1 else tmp_internal[aa] = { :num => 1, :residue => aa, :pK => PK[:internal][aa], :positive => positive?(aa.to_s) } end end end tmp_internal.each do |aa, val| counted << val end # C-terminal c_term = @seq[-1].chr if PK[:cterm].key? c_term.to_sym counted << { :num => 1, :residue => c_term.to_sym, :pK => PK[:cterm][c_term.to_sym], :positive => positive?(c_term) } end counted end
[ "def acidic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n ACIDIC_AMINO_ACIDS.each do |acidic|\n if comp[acidic]\n count += comp[acidic]\n end\n end\n return count\n end", "def basic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n BASIC_AMINO_ACIDS.each do |basic|\n if comp[basic]\n count += comp[basic]\n end\n end\n return count\n end", "def countAtoms(seq)\n\t\t\t\to = 0\n\t\t\t\tn = 0\n\t\t\t\tc = 0\n\t\t\t\th = 0\n\t\t\t\ts = 0\n\t\t\t\tp = 0\n\t\t\t\tse = 0\n\t\t\t\tseq.each_char do |aa|\n\t\t\t\t\to = o + MS::Feature::AA::ATOM_COUNTS[aa][:o]\n\t\t\t\t\tn = n + MS::Feature::AA::ATOM_COUNTS[aa][:n]\n\t\t\t\t\tc = c + MS::Feature::AA::ATOM_COUNTS[aa][:c]\n\t\t\t\t\th = h + MS::Feature::AA::ATOM_COUNTS[aa][:h]\n\t\t\t\t\ts = s + MS::Feature::AA::ATOM_COUNTS[aa][:s]\n\t\t\t\t\tp = p + MS::Feature::AA::ATOM_COUNTS[aa][:p]\n\t\t\t\t\tse = se + MS::Feature::AA::ATOM_COUNTS[aa][:se]\n\t\t\t\tend\n\t\t\t\treturn o,n,c,h,s,p,se\n\t\t\tend", "def calculate_number_of_possible_RNAs_from_prot(protseq)\r\n result = 1 #Variable for returning product of each aac number of codons\r\n stop = 3 #Variable for remembering that we have to take account of the stop codons too\r\n codons ={\"GCU\"=>\"A\",\"GCC\"=>\"A\",\"GCA\"=>\"A\",\"GCG\"=>\"A\",\"GUU\"=>\"V\",\"GUC\"=>\"V\",\r\n \"GUA\"=>\"V\",\"GUG\"=>\"V\",\"GAU\"=>\"D\",\"GAC\"=>\"D\",\"GAA\"=>\"E\",\"GAG\"=>\"E\",\r\n \"GGU\"=>\"G\",\"GGC\"=>\"G\",\"GGA\"=>\"G\",\"GGG\"=>\"G\",\"AUU\"=>\"I\",\"AUC\"=>\"I\",\r\n \"AUA\"=>\"I\",\"AUG\"=>\"M\",\"ACU\"=>\"T\",\"ACC\"=>\"T\",\"ACA\"=>\"T\",\"ACG\"=>\"T\",\r\n \"AAU\"=>\"N\",\"AAC\"=>\"N\",\"AAA\"=>\"K\",\"AAG\"=>\"K\",\"AGU\"=>\"S\",\"AGC\"=>\"S\",\r\n \"AGA\"=>\"R\",\"AGG\"=>\"R\",\"CUU\"=>\"L\",\"CUC\"=>\"L\",\"CUA\"=>\"L\",\"CUG\"=>\"L\",\r\n \"CCU\"=>\"P\",\"CCC\"=>\"P\",\"CCA\"=>\"P\",\"CCG\"=>\"P\",\"CAU\"=>\"H\",\"CAC\"=>\"H\",\r\n \"CAA\"=>\"Q\",\"CAG\"=>\"Q\",\"CGU\"=>\"R\",\"CGC\"=>\"R\",\"CGA\"=>\"R\",\"CGG\"=>\"R\",\r\n \"UUU\"=>\"F\",\"UUC\"=>\"F\",\"UUA\"=>\"L\",\"UUG\"=>\"L\",\"UCU\"=>\"S\",\"UCC\"=>\"S\",\r\n \"UCA\"=>\"S\",\"UCG\"=>\"S\",\"UAU\"=>\"Y\",\"UAC\"=>\"Y\",\"UAA\"=>\"STOP\",\r\n \"UAG\"=>\"STOP\",\"UGU\"=>\"C\",\"UGC\"=>\"C\",\"UGA\"=>\"STOP\",\"UGG\"=>\"W\"}\r\n \r\n protseq.each_char do |aac|\r\n count = 0 #it saves the number of codons that produce a certain aminoacid\r\n codons.each do |codon, translated_codon|\r\n if translated_codon == aac\r\n count += 1\r\n end\r\n end\r\n result *= count\r\n end\r\n return (result * stop) % 1000000\r\nend", "def base_count(seq)\n {\n :g => seq.scan(/G/i).count,\n :a => seq.scan(/A/i).count,\n :t => seq.scan(/T/i).count,\n :c => seq.scan(/C/i).count\n }\n end", "def num_transmem_aa(tmhash, sequence)\n if tmhash.key? :transmembrane_segments\n ranges = tmhash[:transmembrane_segments].map do |tmseg|\n Range.new( tmseg[:start]-1, tmseg[:stop]-1 )\n end\n num_overlapping_chars(tmhash[:aaseq], ranges, sequence)\n else\n []\n end\n end", "def count_dna dna\n DNA.keys.map { |nt| dna.count nt }\n end", "def count_seqs(word, seq_size, sequences)\n 0.upto(word.size - seq_size - 1) do |offset|\n sequences[word[offset, seq_size]] += 1\n end\nend", "def composition(sequence_string)\n count = Hash.new(0)\n sequence_string.scan(/./) do |x|\n count[x] += 1\n end\n count\n end", "def countFastaSeqs(fasfile)\n ar = IO.readlines(fasfile)\n count = 0\n ar.each do |line|\n if line =~ /^>/ then count+=1 end\n end\n count\n end", "def calculate(hexagram)\n upper_trigram = hexagram.lines[0...3]\n lower_trigram = hexagram.lines[3...6]\n SEQUENCE_NUMBER[[lower_trigram, upper_trigram]]\n end", "def countFastaSeqs(fasfile)\n\tar = IO.readlines(fasfile)\n\tcount = 0\n\tar.each do |line|\n\t\tif line =~ /^>/ then count+=1 end\n\tend\t\t\n\tcount\nend", "def count_nucleotides dna\n nucleotides = {}\n dna.each_char { |n| nucleotides[n] = dna.count n }\n nucleotides\nend", "def count_seqs(word, seq_size, sequences)\n offset = 0\n while offset < (word.size - seq_size)\n sequences[word[offset, seq_size]] += 1\n offset+=1\n end\nend", "def get_aa_array(initial_position = 0)\n @aa_array = []\n require_sequence = @dna_sequence[initial_position..-1].tr('-','N')\n base_array = []\n require_sequence.each_char {|base| base_array << base}\n while (base_array.length>=3) do\n base_3= \"\"\n 3.times{base_3 += base_array.shift}\n @aa_array<< amino_acid_2(base_3)\n end\n end", "def find_repeated_dna_sequences(s)\n all = s.chars.each_cons(10).map { |x| x.join(\"\") }.inject({}) { |acc, sequence|\n acc[sequence] ||= 0\n acc[sequence] += 1\n result << sequence if acc[sequence] > 1\n acc\n }\n\n result.uniq\nend", "def num_decodings(s)\n\n decode = ('A'..'Z').to_a\n number_of_prev_ended_singly = 1\n\n ways_count = 1\n number_of_prev_ended_singly = 1\n\n s.chars[1..-1].each_with_index do |ch, idx|\n if s[idx - 1].to_i == 1 ||\n s[idx - 1] == 2.to_i && ch.to_i.between?(1,6)\n\n numbers_added_this_time = ways_count - number_of_prev_ended_singly\n ways_count += numbers_added_this_time\n number_of_prev_ended_singly = numbers_added_this_time\n else\n number_of_prev_ended_singly = 0\n end\n end\n\n ways_count\n\nend", "def run\n # Digits 1,4,7,8 have 2,4,3,7 segments respectively\n @list.map{|line| line[1]}.flatten.map(&:length).filter{|len| [2, 4, 3, 7].include?(len)}.count\n end", "def getFrequencyDict(sequence)\n\tfreq = {}\n\tfreq.default = 0\n\tsequence.each_char { |letter| freq[letter] += 1 }\n\tfreq\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Solving pI value with bisect algorithm.
def solve_pI charges state = { :ph => 0.0, :charges => charges, :pI => nil, :ph_prev => 0.0, :ph_next => 14.0, :net_charge => 0.0 } error = false # epsilon means precision [pI = pH +_ E] epsilon = 0.001 loop do # Reset net charge state[:net_charge] = 0.0 # Calculate net charge state[:charges].each do |charge_proc| state[:net_charge] += charge_proc.call state[:ph] end # Something is wrong - pH is higher than 14 if state[:ph] >= 14.0 error = true break end # Making decision temp_ph = 0.0 if state[:net_charge] <= 0.0 temp_ph = state[:ph] state[:ph] = state[:ph] - ((state[:ph] - state[:ph_prev]) / 2.0) state[:ph_next] = temp_ph else temp_ph = state[:ph] state[:ph] = state[:ph] + ((state[:ph_next] - state[:ph]) / 2.0) state[:ph_prev] = temp_ph end if (state[:ph] - state[:ph_prev] < epsilon) && (state[:ph_next] - state[:ph] < epsilon) state[:pI] = state[:ph] break end end if !state[:pI].nil? && !error state[:pI] else raise "Failed to Calc pI: pH is higher than 14" end end
[ "def interpolation_search_internal(value)\n return [false, 0] if @inner.size == 0\n left = 0\n right = @inner.size - 1\n return [false, 0] if value < @inner[left]\n return [false, right + 1] if value > @inner[right]\n while left <= right\n if left == right\n candidate = left\n else\n candidate = (left + (right - left) * (value - @inner[left]) / (@inner[right] - @inner[left]).to_f).round\n end\n return [false, left] if candidate < left\n return [false, right + 1] if candidate > right\n if @inner[candidate] == value\n return [true, candidate]\n elsif value < @inner[candidate]\n right = candidate - 1\n else\n left = candidate + 1\n end\n end\n return [false, left]\n end", "def biSearch(array, target)\n min = 0\n max = (array.length) -1\n\n while (min <= max)\n guess = ((max + min)/2).round\n if (array[guess] == target)\n return guess\n elsif (array[guess] < target)\n min = guess + 1\n else\n max = guess -1\n end\n end\n return -1\nend", "def p(i, j, k)\n state = pick_state(i)\n n = neighbours(i, k)\n if n.include?(j) then\n this_move_value = 0.0\n other_possible_moves_summed_value = 0.0\n state.transaction do\n this_move_value = state[:trails][[i, j]]\n other_possible_moves_summed_value = n.inject(0){|sum, n| sum + (state[:trails][[i, n]]**@alpha)*(heuristic_value(i, n)**@beta)}\n end\n probability = (this_move_value**@alpha)*(heuristic_value(i, j)**@beta)/ (other_possible_moves_summed_value)\n return probability\n else\n return 0.0\n end\n end", "def bsearch(a, p, q, v)\n\tq = (q + p) / 2\n\tif a[q] == v\n\t\treturn true\n\telsif p == q\n\t\treturn nil\n\telsif a[q] > v\n\t\tbsearch(a, p, q, v)\n\telsif a[q] < v\n\t\tbsearch(a, q+1, a.length, v)\n\tend\nend", "def p(i, j, k)\n n = neighbours(i, k)\n if n.include?(j) then\n this_move_value = 0.0\n other_possible_moves_summed_value = 0.0\n @state.transaction do\n this_move_value = @state[:trails][[i, j]]\n other_possible_moves_summed_value = n.inject(0){|sum, n| sum + (@state[:trails][[i, n]]**@alpha)*(heuristic_value(i, n)**@beta)}\n end\n probability = (this_move_value**@alpha)*(heuristic_value(i, j)**@beta)/ (other_possible_moves_summed_value)\n return probability\n else\n return 0.0\n end\n end", "def p_value(pr,k)\n GSL::Cdf.tdist_Pinv(pr,k)\n end", "def find_root(lower_bound, upper_bound, f)\n @f = f\n lower = lower_bound\n f_upper = f(lower_bound)\n upper = upper_bound\n f_lower = f(upper_bound)\n c = lower\n fc = f_upper\n d = upper - lower\n e = d\n\n absolute_accuracy = EPSILON\n relative_accuracy = EPSILON\n\n loop do\n @iterations += 1\n if (fc.abs < f_lower.abs)\n lower = upper\n upper = c\n c = lower\n f_upper = f_lower\n f_lower = fc\n fc = f_upper\n end\n\n tolerance = 2 * relative_accuracy * upper.abs + absolute_accuracy\n m = 0.5 * (c - upper)\n\n if (m.abs <= tolerance or f_lower.abs < EPSILON or @iterations > @max_iterations)\n return upper\n end\n if (e.abs < tolerance or f_upper.abs <= f_lower.abs)\n # use bisection\n d = m\n e = d\n else \n # use inverse cubic interpolation\n s = f_lower / f_upper\n if (lower == c)\n p = 2 * m * s\n q = 1 - s\n else\n q = f_upper / fc\n r = f_lower / fc\n p = s * (2 * m * q * (q - r) - (upper - lower) * (r - 1))\n q = (q - 1) * (r - 1) * (s - 1)\n end\n if (p > 0)\n q = -q\n else \n p = -p\n end\n s = e\n e = d\n if (p >= 1.5 * m * q - (tolerance * q).abs or p >= (0.5 * s * q).abs)\n # interpolation failed, fall back to bisection\n d = m\n e = d\n else\n d = p / q\n end\n end\n # Update the best estimate of the root and bounds on each iteration\n lower = upper\n f_upper = f_lower\n\n if (d.abs > tolerance)\n upper += d\n elsif (m > 0)\n upper += tolerance\n else\n upper -= tolerance\n end\n f_lower = f(upper)\n if ((f_lower > 0 and fc > 0) or (f_lower <= 0 and fc <= 0))\n c = lower\n fc = f_upper\n d = upper - lower\n e = d\n end\n end\n end", "def p_value(pr,k)\n GSL::Cdf.tdist_Pinv(pr,k)\n end", "def bsearch(trueside,falseside,tol=10**(-9))\r\n ok,ng=trueside,falseside\r\n div=tol.is_a?(Integer) ? 2 : 2.0\r\n while((ok-ng).abs>tol) do\r\n mid=(ng+ok)/div\r\n if(yield(mid))\r\n ok=mid\r\n else\r\n ng=mid\r\n end\r\n end\r\n return ok\r\nend", "def bisect(arr, key)\n arr.each_index do |i|\n return i if key < arr[i]\n end\n\n return arr.length\n end", "def enter_infertility\n @infertility = @p_o_i\n end", "def binary_search(lo, hi, p, e)\n x = (lo + hi) / 2 \n if p.call(lo, hi)\n return x\n elsif e.call(x)\n return binary_search(lo, x, p, e)\n else\n return binary_search(x, hi, p, e)\n end\n end", "def p_value(pr,k)\n GSL::Cdf::chisq_Pinv(pr.to_f,k.to_i)\n end", "def search(a_sign:, b_sign:)\n if a_sign == \"positive\"\n a_bound = 1000\n step = 1\n end\n if a_sign == \"negative\"\n a_bound = -1000\n step = -1\n end\n\n test_a = 0\n test_b = 0\n max_primes = 0\n\n 0.step(a_bound, step) do |a| # Search for the 'a' coefficient, while a < 1000. Use a block-local variable a.\n Prime.each(1000) do |b| # Search for the 'b' coefficient, while b < 1000.\n b = -(b) if b_sign == \"negative\" # Flip the sign of the prime if we wanted to search for b in [-1000, 0]\n p = 0 # How many primes 'expression' produces.\n 0.step do |n| # The loop for checking if the expression does indeed produce\n # consecutive primes starting at 0.\n expression = n ** 2 + a*n + b\n break unless expression.prime?\n p += 1 # another prime was found\n end # end step loop\n\n if p > max_primes\n max_primes = p\n test_a = a\n test_b = b\n end\n\n end # end prime loop; b\n end # end 'a' loop\n # Returns a hash with keys :a, :b, and max_primes with their values respectively.\n {:a => test_a, :b => test_b, :primes => max_primes}\n end", "def solve\n # Assume a large D to start.\n min = 2 << (0.size << 3) - 1\n j, dj = 5, 4\n\n # Advance pentagonal numbers by adding a delta (which accelerates). Stop\n # when the delta gets bigger than our current minimum, since the next\n # number's nearest neighbor will be too far away to generate a smaller D.\n while dj < min\n # Step backwards through the numbers less than the current one.\n k, dk = j - dj, dj\n\n # Stop looking backwards when the pair is too far apart to result in a\n # smaller minimum.\n while 1 < dk && j - k < min\n d = (24*(j - k) + 1)**0.5\n \n # Check for pentagonality of difference.\n if d == d.to_i && 5 == d % 6\n s = (24*(j + k) + 1)**0.5\n \n # Check for pentagonality of sum.\n min = j - k if s == s.to_i && 5 == s % 6\n end\n \n dk -= 3\n k -= dk\n end\n\n dj += 3\n j += dj\n end\n\n min\n end", "def bin_search_nearest(arr, val)\n # if val is found in arr, return its index. \n # else, returns the index of the CLOSEST value to val.\n # \n # this means don't exclude the bounds in recursive calls, they might be the\n # closest value\n\n if arr.length == 1\n return 0\n elsif arr.length == 2\n return (arr[0] - val).abs <= (arr[1] - val).abs ? 0 : 1\n else\n i_guess = arr.length / 2\n if arr[i_guess] == val\n i_guess\n elsif arr[i_guess] > val\n bin_search_nearest(arr[0..i_guess], val)\n else \n i_guess + bin_search_nearest(arr[i_guess..-1], val)\n end \n end\nend", "def solve\n a = Time.new\n for i in 0..@itemsSize - 1\n @table[0][i] = 0\n end\n \n for i in 1..@itemsSize - 1\n price = @problem.prices[i-1]\n weight = @problem.weights[i-1]\n for w in 1..@weights - 1\n if weight <= w\n if (price + @table[w - weight][i - 1]) > @table[w][i -1]\n @table [w][i]= price + @table[w - weight][i - 1]\n else\n @table[w][i] = @table[w][i - 1]\n end\n else\n @table[w][i] = @table[w][i - 1]\n end\n end\n end\n \n \n prev_item = 0\n for i in 1..@itemsSize - 1\n curr_item = @table[@weights - 1][i]\n if prev_item < curr_item\n @best_configuration.push(1)\n else\n @best_configuration.push(0)\n end\n prev_item = curr_item\n end\n \n @best_fitness = @table[@weights - 1][@itemsSize - 1]\n \n b = Time.new\n @time = b-a\n end", "def bsearch(a, k)\r\n lower = 0\r\n upper = a.length-1\r\n\r\n while lower + 1< upper\r\n temp1 = a[upper][0]*37 - a[lower][0]*37 + a[upper][1] - a[lower][1]\r\n temp2 = k[0]*37 + k[1] - a[lower][0]*37 - a[lower][1]\r\n mid = 0\r\n\r\n if (temp2!=0 && temp1!=0)\r\n # Use interpolation search for the first two characters if the \"lower\" two characters\r\n # isn't coincident with the \"upper\" first two characters or the \"mid\" first two characters\r\n mid = lower + temp2 * (upper - lower) / temp1\r\n else\r\n mid = (lower+upper)/2\r\n end\r\n\r\n if k < a[mid]\r\n upper = mid\r\n else\r\n lower = mid\r\n end\r\n end\r\n\r\n if k != a[lower]\r\n return nil\r\n else\r\n return lower\r\n end\r\nend", "def interpolation_search(value)\n search_result = interpolation_search_internal(value)\n return search_result[0] ? search_result[1] : -1\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The load_game method is responsible for comparing the timestamp within the file to the time the filesystem has associated with the file. Write the load_game(file) method.
def load_game(file) raise "I suspect you of cheating." if File.mtime(file) != Time.at(File.readlines(file).last.to_i) end
[ "def load_game\n print_saves\n begin\n read_save\n rescue IOError, SystemCallError\n puts 'File not found'\n load_game\n end\n end", "def load_game\n \t\t#Get information for game to load\n \t\tget_username\n \t\tfile_name = get_saved_games\n \t\treturn if file_name==\"menu\"\n \t\tload = Marshal.load File.read(file_name)\n\n \t\t#Load the instance variables\n \t\t@start_time = Time.now\n \t\t@save_time = load[:save_time]\n \t\t@top_card = load[:top_card]\n \t\t@number_of_hint = load[:number_of_hint]\n \t\t@number_of_correct = load[:number_of_correct]\n \t\t@number_of_wrong= load[:number_of_correct]\n \t\t@deck = load[:deck]\n \t\t@hand = load[:hand]\n \t\t@username = load[:username]\n \t\t@total_hint=load[:total_hint]\n \t\t@is_end = false\n\n \t\t#Output a message for the progress\n \t\tmsg1 = \"You have completed #{@number_of_correct} sets (roughly #{(@number_of_correct*100).fdiv(27).truncate(2)}%)\"\n \t\tmsg2 = \"You have #{@total_hint-@number_of_hint} hints left. Lets Continue!\"\n \t\tputs\n \t\t(msg1.length+10).times {print \"*\"}\n \t\tputs \"\\n**** \"+msg1+\" ****\"\n \t\tputs \"**** \"+msg2.center(msg1.length)+\" ****\"\n \t\t(msg1.length+10).times {print \"*\"}\n \t\tputs\n\n \t\tcontinue_game\n \tend", "def load_game\n data = File.read(\"save.txt\")\n load_game = Game.from_json data\n request_save = load_game.play\n\n if request_save\n save_file request_save\n end\n end", "def load_game\n\t\tall_saved_games = yaml_load(SAVED_FILENAME)\n\t\tgame_name = get_game_name(all_saved_games, \"load\")\n\t\treturn if game_name.nil?\n\n\t\tsaved_game = YAML::load(all_saved_games[game_name])\n\t\tmessage_then_enter \"'#{ game_name }' successfully loaded.\"\n\t\tsaved_game.play_game\n\tend", "def load_game\n saved_games = Dir[\"games/*\"]\n if saved_games.empty?\n puts \"No saved games\"\n exit\n end\n saved_games.each_with_index do |file, n|\n time = File.mtime(file).strftime(\"%Y-%m-%d %H:%M\")\n puts \"#{n+1}. #{file[6..-1]} created: #{time}\"\n end\n\n loop do\n puts \"Enter a number to open the game:\"\n choice = gets.chomp.to_i\n if choice.between?(1, saved_games.length)\n JSON.load(File.open(saved_games[choice - 1], 'r').read).each do |var, val|\n self.instance_variable_set '@'+var,val\n end\n break\n end\n end\n end", "def load_saved_game\n game_data = get_saved_game_file\n if game_data\n @file.secret_word = game_data[:secret_word] || @file.pick_new_word\n @used_letters = game_data[:used_letters] || []\n @hearts_left = game_data[:hearts] || 6\n else\n puts \"There is no saved file, starting new game\"\n end\n end", "def load_game\n file = File.open(\"../saves/log.yml\", \"r\")\n s_log = file.read.to_i\n file.close\n if s_log == 0\n puts \"No save data.\"\n else\n puts \"Select a save file (1 to #{s_log}).\"\n s_choice = gets.chomp.to_i\n if s_choice <= s_log\n puts \"Loading save game # #{s_choice}...\"\n game_state = YAML.load(File.read(\"../saves/save_#{s_choice}.yml\"))\n game_state.play\n else\n puts \"Selected save file does not exist.\"\n end\n end\n end", "def load_game\n puts \"What is the name of your game?\"\n name = gets.chomp\n if File.exist?(\"saved/#{name}\")\n loaded_game = Marshal.load(File.open(\"saved/#{name}\", 'r'))\n loaded_game.play\n else\n puts \"No game with that name found\"\n return\n end\n \n end", "def init_gamedata\r\n file = File.open(@filename, \"r\")\r\n @time_stamp = file.mtime\r\n @characters = Marshal.load(file)\r\n @frame_count = Marshal.load(file)\r\n @game_system = Marshal.load(file)\r\n @game_switches = Marshal.load(file)\r\n @game_variables = Marshal.load(file)\r\n @total_sec = @frame_count / Graphics.frame_rate\r\n file.close\r\n end", "def load_game_from_save\n #TODO implement game state saving and loading\n end", "def load_game\n save_state = YAML.load_file(\"save.yaml\")\n save_state.loaded_game\n end", "def load_game\n if File.exists?(@save_file)\n File.open(@save_file, 'r') do |f|\n @hero = Marshal.load(f)\n end\n @cmd_window.setpos(0,0)\n @cmd_window << \"Game loaded!\".rjust(CMD_WIDTH)\n else\n @cmd_window.setpos(0,0)\n @cmd_window << \"No save file found!\".rjust(CMD_WIDTH)\n end\n end", "def load_game_files!\n EventDictionary.reset!\n Image.images.clear\n Animation.images.clear\n Song.songs.clear\n Font.fonts.clear\n\n prepare_watcher!\n load_game_files\n execute_watcher!\n end", "def load_game\n\t\tputs \"please enter a name for your saved game.\"\n\t\tfilename = gets.chomp + '.yaml'\n\t\tFile.open(filename, 'r') do |f|\n\t\tx = YAML::load(f)\n\t\t@count = x[:count]\n\t\t@secret_word = x[:secret_word]\n\t\t@selection_array = x[:selection_array]\n\t\t@blanks = x[:blanks]\n\t\tend\n\tend", "def import_game(file_path)\n ActiveRecord::Base.transaction do\n game = Game.create!(name: \"Game #{Time.now.to_i}\")\n game_data = parse_data(file_path)\n game_data.keys.each do |r|\n round = Round.create!(number: r, game: game)\n game_data[r].keys.each do |p|\n player = Player.find_or_create_by(name: \"player #{p}\", game: game)\n Hand.create!(number: round.number, card_list: game_data[r][p].join(' '), player: player, round: round)\n end\n end\n game.rounds.collect{ |r| r.find_winning_hand }\n game\n end\n end", "def load_game(id)\n @game_data = JSON.parse(safe_read(fname_for(id)))\n end", "def initialize(filename, ondisk=true, players=[])\n if ondisk\n # Game object exists on disk. Read it from file.\n self.read_data(filename)\n else\n # Create new Game object with starting values.\n @filename = filename\n @created_at = DateTime.now\n @last_updated = DateTime.now\n @mode = players.length\n @players = players\n self.initialize_scoreboard\n self.write_data\n end\n @plist = @players.map {|x| x.downcase}\n end", "def load_hero_file\n clear_message_box\n #ask for file\n @ui.set_colour(DungeonOfDoom::C_BLACK_ON_YELLOW)\n @ui.place_text('USE CHARACTER FILE?'.ljust(20),1,2)\n @ui.place_text('>'.ljust(20),1,3)\n file_name=nil\n #loop until file is good\n while file_name.nil?\n @ui.place_text(' '*19,2,3)\n file_name = @ui.get_string(2,3)\n #check and try to open file\n if file_name.split('.').last != 'yaml' #needs yaml extention\n @ui.place_text('!REQUIRES YAML EXT'.ljust(20),1,4)\n file_name=nil\n elsif !File.exists?(file_name) #file must exist\n @ui.place_text('!FILE NOT FOUND'.ljust(20),1,4)\n file_name=nil\n else\n hero_data = YAML.load(File.open(file_name))\n if hero_data.is_a? Hash #file must be in a valid yaml format\n #load stats\n hero_data[:stats].each do |stat|\n @stats[stat[0].downcase.to_sym] = stat[1]\n end\n @orig_stats.merge!(@stats) #make a copy\n #load objects\n @objects = hero_data[:objects]\n #load remaining gold (used for final score)\n @gold_count += hero_data[:gold]\n #display heros name\n @ui.place_text(hero_data[:name].center(20), 1, 1, DungeonOfDoom::C_BLACK_ON_WHITE)\n #set magic spell count based on 2 x power of NECRONOMICON and SCROLLS\n book = @objects.find { |object| object[:name]=='NECRONOMICON' }\n if book\n power = book[:power]\n [:super_zap, :santuary, :teleport].each do |spell|\n @spells[spell] = power\n end\n end\n scroll = @objects.find { |object| object[:name]=='SCROLLS' }\n if scroll\n power = scroll[:power]\n [:powersurge, :metamorphosis, :healing].each do |spell|\n @spells[spell] = power\n end\n end\n #set torch power\n torch = @objects.find { |object| object[:name]=='TORCH' }\n @torch_power = torch[:power] if torch\n #find initial potion count\n potion = @objects.find { |object| object[:name]=='POTION' }\n @potions += potion[:count] if potion\n #find initial attack power\n ['2 HAND SWORD','BROADSWORD','SHORTSWORD','AXE','MACE','FLAIL','DAGGER','GAUNTLET'].each do |item|\n object = @objects.find { |object| object[:name]==item }\n @attack += object[:power] if object\n end\n @attack += @stats[:strength]\n #find initial defence power\n ['HEAVY ARMOUR','CHAIN ARMOUR','LEATHER SKINS','HEAVY ROBE','GOLD HELMET','HEADPIECE','SHIELD'].each do |item|\n object = @objects.find { |object| object[:name]==item }\n @defence += object[:power] if object\n end\n else #all okay!\n @ui.place_text('!FILE BAD FORMAT'.ljust(20),1,4)\n file_name=nil\n end\n end\n end\n end", "def load_game\n $pokemon_party = @all_window[@index].data\n $pokemon_party.expand_global_var\n $pokemon_party.load_parameters\n $game_system.se_play($data_system.cursor_se)\n $game_map.setup($game_map.map_id)\n $game_player.moveto($game_player.x, $game_player.y) # center\n $game_party.refresh\n $game_system.bgm_play($game_system.playing_bgm)\n $game_system.bgs_play($game_system.playing_bgs)\n $game_map.update\n $game_temp.message_window_showing = false\n $trainer.load_time\n Pathfinding.load\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
find note and parent picture, destroy then redirect back to artwork
def destroy @note = Note.find(params[:id]) @picture = @note.picture @artwork = @picture.artwork @note.destroy redirect_to @artwork end
[ "def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n #need a redirect here\n redirect_back(fallback_location: root_path)\n #if artwork is no longer present fallback to the root\n end", "def destroy\n @note_image = NoteImage.find(params[:id])\n @note_image.remove_image!\n @note_image.destroy\n\n respond_to do |format|\n format.html { redirect_to note_note_images_url(params[:note_id]) }\n format.json { head :ok }\n end\n end", "def destroy\n if @parent.attachments.find(params[:id]).destroy\n flash[:notice] = t('messages.attachment.success.delete')\n else\n flash[:alert] = t('messages.attachment.errors.delete')\n end\n\n redirect_to :back\n end", "def destroy_note\n @note = Note.find(params[:id])\n\t\t@owner = Album.find(params[:album_id])\n\t\t@owner_id = @owner.id\n\t\t\n @note.destroy\n\t\t# refresh\n\t\t@owner_notes = @owner.notes\n\t\t@destroy_url = \"/albums/#{@owner.id}/notes/\"\n\t\n\t\t\n\t\trespond_to do |format|\n\t\t\t\n\t\t\tformat.html { redirect_to :back }\n\t\t\tformat.js\n\t\tend\n \n end", "def destroy\n @artist_photo = ArtistPhoto.find_by_urlname(params[:id])\n @artist_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/artists/#{@artist_photo.artist_id}\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @child_pic.destroy\n respond_to do |format|\n format.html { redirect_to child_pics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tip_image.destroy\n\n head :no_content\n end", "def delete_image\n @entity = Entity.find(params[:entity])\n @entity.photo = nil\n @entity.save\n params[:id]=@entity.id\n redirect_to :back\n end", "def destroy\n @image_to_part.destroy\n respond_to do |format|\n format.html { redirect_to image_to_parts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ministry_picture_child = MinistryPictureChild.find(params[:id])\n redirect_id = @ministry_picture_child.ministry_id\n @ministry_picture_child.destroy\n\n \n respond_to do |format|\n format.html { redirect_to ministry_child_path(redirect_id), notice: 'The picture has been removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @documentary.remove_thumbnail = true\n @documentary.save!\n head :no_content\n end", "def destroy_photo\n @establishment = Establishment.find(params[:id])\n\n # If photo to destory belongs to this establishment\n if @establishment.photos.any? { |p| p.id == params[:photo_id] }\n # Nullify image so we can send correct version of establishment\n # back to frontend\n image = Image.find(params[:photo_id])\n image.imageable_type = nil\n image.imageable_id = nil\n image.save\n\n @establishment.reload\n\n # Now remove image\n image.enqueue_removal\n respond_to do |format|\n format.json { render :show }\n end\n end\n\n end", "def destroy\n @artwork = Artwork.find_by(id: params[:id])\n @artwork.destroy\n redirect_to @current_user\n end", "def destroy\n @article.remove_thumbnail = true\n @article.save!\n head :no_content\n end", "def destroy\n @life_pulse_picture = LifePulsePicture.find(params[:id])\n redirect_id = @life_pulse_picture.life_pulse_id\n @life_pulse_picture.destroy\n\n\n respond_to do |format|\n format.html { redirect_to life_pulse_path(redirect_id), notice: 'Life Pulse picture has been removed.'}\n format.json { head :no_content }\n end\n end", "def destroy\n \n @speaker_picture = SpeakerPicture.find(params[:id])\n redirect_id = @speaker_picture.speaker_id\n @speaker_picture.destroy\n\n respond_to do |format|\n format.html { redirect_to speaker_path(redirect_id), notice: 'Speaker picture has been removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @raw_image.destroy\n redirect_to admin_raw_images_path\n end", "def destroy\n @guide_story_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to manage_photos_listing_path(@guide_story_photo.listing) }\n format.json { head :no_content }\n end\n end", "def removePhoto\n albumRecord = AlbumRecord.where(id: params[:id]).first\n albumRecord.delete\n\n redirect_to request.referrer, notice: \"Remove successfull\"\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For a recurrent network, this resets hidden states back to zero
def reset if config.isRecurrent @nn.resetRecurrentStates else puts "Warning not a recurrent network. This does nothing" end end
[ "def reset_all_nodes\n NeuralNet.find(id).nodes.each do |node|\n unless node.bias\n node.output = 0.0\n node.total_input = 0.0\n node.save\n end\n end\n end", "def deep_reset\n # reset memoization\n [:@layer_row_sizes, :@layer_col_sizes, :@nlayers, :@layer_shapes,\n :@nweights_per_layer, :@nweights].each do |sym|\n instance_variable_set sym, nil\n end\n reset_state\n end", "def reset_state\n @state = nil\n end", "def reset_all_nodes\n nodes.where(net_id: id).each do |node|\n node.output = 0\n node.total_input = 0\n node.save\n end\n end", "def power_state_reset!\n proxy.power_state_reset\n end", "def reset_network_values\n @nodes.each do |node|\n node.value = nil\n end\n end", "def reset\n\t\t@n ? @inputs = [] : @max = 0\n\tend", "def reset_circuit\n @internals.each do |internal|\n internal.reset\n end\n end", "def reset\n @state and @state.reset!\n @input and @input.reset rescue nil\n end", "def wipe_state\r\n @modes = nil\r\n @online = false\r\n end", "def reset\n $acc = 0\n for i in 0.. ($instruction_list.size - 1)\n $instruction_list[i][2] = false\n end\nend", "def reset\n @grid.reset_pulses\n end", "def reset\r\n\t\tself.current_node=@root_node\r\n\t\tself.state={}\r\n\tend", "def reset\n @value = 0\n end", "def restore_hidden!\n only_hidden.update_all(deleted_at: nil)\n end", "def reset \n init_fann\n end", "def reset_state\n @network_failure_last_reconnect_delay = 0\n @http_failure_last_reconnect_delay = 0\n @num_retries = 0\nend", "def allReset\n if (@nodeActiveInactive == NODE_INACTIVE)\n return\n end\n if ( readCondition == NODE_NOT_REGISTERED )\n\t return\n else\n\t updateCondition(NODE_RESET)\n @communicator.constructSendCmd(@myPort, @ipaddr, CM_CMD_RESET, @nodeType)\n end\n end", "def reset_iteration\n @target_idx = first_idx\n @input_idxs = init_inputs\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Copies workflows to another scope.
def copy workflows = Workflow.accessible_by(@context).where(id: params[:item_ids]) new_workflows = workflows.map { |wf| copy_service.copy(wf, params[:scope]).first } # TODO: change old UI to handle json-response! respond_to do |format| format.html do redirect_to pathify(workflows.first), success: "The workflow has been published successfully!" end format.json { render json: new_workflows, root: "workflows", adapter: :json } end end
[ "def copy_workflows(space, source_space)\n source_space.workflows.each { |workflow| copy_service.copy(workflow, space.uid) }\n end", "def copy\n workflows = Workflow.accessible_by(@context).where(id: params[:item_ids])\n\n new_workflows = workflows.map { |wf| copy_service.copy(wf, params[:scope]).first }\n\n # TODO: change old UI to handle json-response!\n respond_to do |format|\n format.html do\n redirect_to pathify(workflows.first),\n success: \"The workflow has been published successfully!\"\n end\n\n format.json { render json: new_workflows, root: Workflow.model_name.plural, adapter: :json }\n end\n rescue StandardError => e\n raise ApiError, Message.bad_request(e.message)\n end", "def copy\n new_workflow = Workflow.new\n new_workflow.name = self.name\n new_workflow.staging_template_dir = self.staged_dir\n new_workflow.batch_host = self.batch_host\n new_workflow.script_name = self.script_name\n new_workflow.job_attrs = self.job_attrs\n new_workflow\n end", "def copy\n Scope.new(Java::CascadingFlowPlanner::Scope.new(@scope))\n end", "def copy(nodes, scope)\n copies = Copies.new\n\n return copies if nodes.empty?\n\n @parent_folder_col = Node.scope_column_name(scope)\n @opposite_parent_folder_col = Node.opposite_scope_column_name(scope)\n\n parent_folder = nil\n\n Node.transaction do\n nodes.each do |node|\n copied_node = copy_node(node, scope, parent_folder)\n copies.concat(copied_node)\n end\n end\n\n copies\n end", "def copy_to(copy)\n known_tasks.each { |t| copy.known_tasks << t }\n free_events.each { |e| copy.free_events << e }\n copy.instance_variable_set :@task_index, task_index.dup\n\n missions.each { |t| copy.missions << t }\n permanent_tasks.each { |t| copy.permanent_tasks << t }\n permanent_events.each { |e| copy.permanent_events << e }\n end", "def copy\n authorize @workshop\n if params[:copy_here].present?\n session = Session.find(params[:session_id].to_i)\n new_workshop = Workshop.new(@workshop.attributes.except(\"id\", \"created_at\", \"updated_at\"))\n new_workshop.position = new_workshop.session.workshops.count + 1\n else\n # Targeted Session\n session = Session.find(params[:copy][:session_id])\n # Creates the copy, and rename it if applicable\n new_workshop = Workshop.new(@workshop.attributes.except(\"id\", \"created_at\", \"updated_at\", \"session_id\"))\n new_workshop.title = params[:copy][:rename] if params[:copy][:rename].present?\n new_workshop.session_id = session.id\n new_workshop.position = session.workshops.count + 1\n end\n if new_workshop.save\n # Creates a copy of all WorkshopModules from the source\n @workshop.workshop_modules.each do |mod|\n modul = WorkshopModule.create(mod.attributes.except(\"id\", \"created_at\", \"updated_at\", \"workshop_id\"))\n modul.update(workshop_id: new_workshop.id, position: mod.position)\n end\n j = 1\n new_workshop.workshop_modules.order(position: :asc).each{|mod| mod.update(position: j); j += 1}\n redirect_to training_session_path(session.training, session)\n else\n raise\n end\n end", "def copy(user_id, item_id)\n workflow = Workflow.new\n workflow.users = self.users\n workflow.status = self.status\n workflow.issued_at = self.issued_at\n workflow.decided_at = self.decided_at\n if self.original_by.nil? and self.user_id != 0\n workflow.original_by = self.user_id\n else\n workflow.original_by = self.original_by\n end\n workflow.item_id = item_id\n workflow.user_id = user_id\n\n workflow.save!\n\n return workflow\n end", "def copy\n ref_kanban = Kanban.find(params[:ref_id])\n ref_kanban_panes = KanbanPane.find_all_by_kanban_id(params[:ref_id])\n ref_workflow = KanbanWorkflow.find_all_by_kanban_id(params[:ref_id])\n\n new_kanban = ref_kanban.dup\n new_kanban.project_id = params[:project_id]\n new_kanban.update_attribute(:is_valid, true)\n new_kanban.save!\n ref_kanban_panes.each do |p|\n new_pane = p.dup\n new_pane.kanban_id = new_kanban.id\n new_pane.save!\n end\n\n ref_workflow.each do |w|\n new_w = w.dup\n new_w.kanban_id = new_kanban.id\n new_w.save!\n end\n redirect_to edit_project_kanban_path(new_kanban.project_id, new_kanban.id, :tab => \"Panes\")\n end", "def copy\n authorize @workshop_module\n if params[:copy_here].present?\n @workshop = Workshop.find(params[:workshop_id])\n new_workshop_module = WorkshopModule.new(@workshop_module.attributes.except(\"id\", \"created_at\", \"updated_at\", \"user_id\", \"position\"))\n new_workshop_module.position = @workshop.workshop_modules.count + 1\n else\n # Targeted Workshop\n @workshop = Workshop.find(params[:copy][:workshop_id])\n # Creates the copy, and rename it if applicable\n new_workshop_module = WorkshopModule.new(@workshop_module.attributes.except(\"id\", \"created_at\", \"updated_at\", \"workshop_id\", \"user_id\", \"position\"))\n new_workshop_module.title = params[:copy][:rename] if params[:copy][:rename].present?\n new_workshop_module.position = @workshop.workshop_modules.count + 1\n new_workshop_module.workshop_id = @workshop.id\n end\n if new_workshop_module.save\n update_duration\n redirect_to training_session_workshop_path(@workshop.session.training, @workshop.session, @workshop)\n else\n raise\n end\n end", "def copy\n result = dup\n result.name = \"Copy of #{name}\"\n result.assign_enrollment_code\n result.save!\n instructors.each do |instructor|\n result.memberships.create!(user: instructor, role: :instructor)\n end\n result.assignments = assignments.map(&:copy)\n result\n end", "def copy\n @prev_marketing_campaign_id = session[:marketing_campaign_id]\n marketing_campaign_to_clone = MarketingCampaign.find(params[:id])\n @marketing_campaign = marketing_campaign_to_clone.clone\n @marketing_campaign.campaign_status = 'i' \n end", "def copy(space, source_space)\n ActiveRecord::Base.transaction do\n copy_files_and_folders(space, source_space)\n copy_workflows(space, source_space)\n copy_apps(space, source_space)\n end\n end", "def copy(opts = {})\n scenario_site = Vms::ScenarioSite.new(self.attributes)\n scenario_site.attributes = opts\n \n self.inventories.each do |inv|\n scenario_site.inventories << inv.clone\n end\n \n self.role_scenario_sites.each do |rss|\n scenario_site.role_scenario_sites.build(rss.attributes)\n end\n \n self.staff.each do |stf|\n scenario_site.staff.build(stf.attributes)\n end\n \n self.teams.each do |team|\n scenario_site.teams.build(team.attributes)\n end\n \n scenario_site\n end", "def copy_ds_tasks_to_new_stream\n new_completed_task = DocketSwitchGrantedTask.assigned_to_any_user.find_by(appeal: old_docket_stream).dup\n new_completed_task.assign_attributes(\n appeal_id: new_docket_stream.id,\n parent_id: new_docket_stream.root_task.id,\n status: Constants.TASK_STATUSES.completed\n )\n # Disable validation to avoid errors re creating with status of completed\n new_completed_task.save(validate: false)\n end", "def copy_suite_from_belt_scope(scope)\n ::Zim.suite(scope.name) do |suite|\n scope.projects.each do |project|\n next if project.tags.include?('historic')\n next if project.tags.include?('external')\n next if project.tags.include?('deprecated')\n next if project.tags.include?('zim=no')\n git_url = project.tag_value('git_url') || \"https://github.com/#{scope.name}/#{project.name}.git\"\n suite.application(project.name, 'git_url' => git_url, 'tags' => project.tags.dup)\n end\n end\n end", "def copy\n if fetch(:archive_workflow)\n unless fetch(:archive_workflow_next).to_s.strip.empty?\n backend.execute(:cp, release_path_filename, \"#{fetch(:archive_releases_path)}/#{fetch(:archive_workflow_next)}/\")\n end\n end\n end", "def copy(app, scope)\n ActiveRecord::Base.transaction do\n opts = build_opts(app, scope)\n\n new_app = AppService.create_app(user, api, opts)\n\n authorize_users(new_app, scope)\n\n new_app\n end\n end", "def copy_organization_from_belt_scope(scope)\n ::Backpack.organization(scope.name) do |o|\n scope.projects.each do |project|\n next if project.tags.include?('backpack=no')\n methods = Repository.instance_methods(false)\n options = {}\n methods.each do |method|\n key = method.to_s.sub(/\\?$/, '')\n if method.to_s.end_with?('?') && methods.include?(\"#{key}=\".to_sym)\n options[key] = true if project.tags.include?(key)\n elsif methods.include?(\"#{key}=\".to_sym)\n value = project.tag_value(key)\n value = value.split(',') if value && key == 'topics'\n options[key] = value if value\n end\n end\n o.repository(project.name, options.merge({:tags => project.tags.dup}))\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This is the actual action that ships the reward ship_reward_now_user_payment_reward_receivers POST
def ship_reward_now @reward_receiver = RewardReceiver.find(params[:reward_receiver_id]) @reward_receiver.update(reward_receiver_params) if @reward_receiver.update( status: "shipped" ) #Send email #Send notification #Add xp @user.add_score("ship_reward") end redirect_to show_user_studio_rewards_path(@reward_receiver.reward.user_id,@reward_receiver.reward_id) end
[ "def deliver_reward(reward, star_id)\n weight_adjustment = case\n when reward > 0 then 0.1\n when reward < 0 then -0.1\n else 0\n end\n @weighted_actions[@last_action] += weight_adjustment if @last_action\n end", "def notify_owner_of_redeemed_reward\n reward_page.notify_owner_of_redeemed_reward!(self, self.participant_id)\n return true\n end", "def create\n @reward = current_user.rewards.new(params[:reward])\n\n respond_to do |format|\n if @reward.save\n format.html { redirect_to @reward, notice: 'Reward was successfully created.' }\n format.json { render json: @reward, status: :created, location: @reward }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reward.errors, status: :unprocessable_entity }\n end\n end\n end", "def process_reward\n return_with(:error)\n end", "def create\n @user_reward = UserReward.new(user_reward_params)\n\n respond_to do |format|\n if @user_reward.save\n format.html { redirect_to @user_reward, notice: 'User reward was successfully created.' }\n format.json { render :show, status: :created, location: @user_reward }\n else\n format.html { render :new }\n format.json { render json: @user_reward.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_v1_user_reward = Api::V1::UserReward.new(api_v1_user_reward_params)\n\n respond_to do |format|\n if @api_v1_user_reward.save\n format.html { redirect_to @api_v1_user_reward, notice: 'User reward was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_user_reward }\n else\n format.html { render :new }\n format.json { render json: @api_v1_user_reward.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reward = current_business.rewards.build(reward_params)\n\n respond_to do |format|\n if @reward.save\n format.html { redirect_to @reward, notice: 'Reward was successfully created.' }\n format.json { render :show, status: :created, location: @reward }\n else\n format.html { render :new }\n format.json { render json: @reward.errors, status: :unprocessable_entity }\n end\n end\n end", "def redeem\n if params[:reward_id].present? && Reward.find_by_id(params[:reward_id].to_i).present?\n reward = Reward.find_by_id(params[:reward_id])\n status = Redeemption.new(reward.category, @user).redeem\n if status == true\n RedemptionMailer.call(@user, @user.email, reward, \"\").deliver\n render json: { message: \"Your points has been redeemed\" }, status => 200\n else\n render json: { message: \"Your points are less for this reward, commplete daily challenges and try again\" }, status: 404\n end\n else\n render json: { message: \"Please provide valid reward id\" }, status => 401\n end\n end", "def default_reward\n\t\tself.rewards.create(:description => \"Thanks!\", :dollar_amount => 1)\n\tend", "def send_reward_request(address, promo, rewards_token)\n # set the request url\n url = AMAX_URL\n\n # set the payload\n payload = {\n \"outboundRewardRequest\" => {\n \"app_id\" => @app_id,\n \"app_secret\" => @app_secret,\n \"rewards_token\" => rewards_token,\n \"address\" => address,\n \"promo\" => promo\n }\n }\n\n # convert to JSON\n payload = JSON.generate(payload)\n\n # send post request\n response = send_post_request(url, payload)\n\n return JSON.parse(response)\n end", "def decline\n # Find the user\n return render :status => 150, :json => {:message => \"User not found.\"} if params[:user_id].nil? || params[:user_id].empty?\n user = User.find(params[:user_id].to_i)\n return render :status => 150, :json => {:message => \"User {#{id}} not found.\"} if user.nil?\n\n # Find this friendship request (must be neither declined nor an accepted request)\n friendship = user.friendships.where(\"friendships.friend_id = #{current_user.id} and friendships.status is null\").first\n return render :status => 154, :json => {:message => \"Friendship request not found.\"} if friendship.nil?\n\n # Decline friendship\n friendship.status = false\n friendship.responded_at = DateTime.now\n friendship.save\n\n # TODO: Notify user_id of friendship denial\n\n # Notify Pusher rendezvous channel of friendship acceptance\n Pusher[\"presence-rendezvous-channel\"].trigger('friendship_denied', {\n :initiatorID => user.id,\n :friendID => current_user.id\n })\n\n # Log analytics event\n @mixpanel.track(\"Friendship Declined\",\n :distinct_id => current_user.username,\n :user_id => current_user.id,\n :friend_username => user.username,\n :friend_id => user.id)\n\n render :status => 200, :json => {:message => \"Friendship declined\"}\n end", "def allows_reward?\n true\n end", "def create\n @api_v1_reward_action = Api::V1::RewardAction.new(api_v1_reward_action_params)\n\n respond_to do |format|\n if @api_v1_reward_action.save\n format.html { redirect_to @api_v1_reward_action, notice: 'Reward action was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_reward_action }\n else\n format.html { render :new }\n format.json { render json: @api_v1_reward_action.errors, status: :unprocessable_entity }\n end\n end\n end", "def residual_bonus\n render json: {\n rewards: @current_user.rewards.where(reward_type_id:15).order(created_at: :desc).map { |x| referral_filter(x) }.compact\n }\n end", "def call(user, email, reward, shipping_address)\n @user = user\n @reward = reward\n # admin = \"astropowerbox@gmail.com\"\n admin = \"news.article.sysetm@gmail.com\"\n @shipping_address = shipping_address\n mail to: email, subject: 'Redemption details'\n end", "def create_loyalty_reward(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/loyalty/rewards',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def add_reward(value)\n self.reward += value\n end", "def redeem_loyalty_reward(reward_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/loyalty/rewards/{reward_id}/redeem',\n 'default')\n .template_param(new_parameter(reward_id, key: 'reward_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def create\n @reward = Reward.new(params[:reward])\n\n respond_to do |format|\n if @reward.save\n format.html { redirect_to(rewards_path, :notice => 'Nagroda dodana.') }\n format.xml { render :xml => @reward, :status => :created, :location => @reward }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @reward.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Show the given thesis with the given tiss_id
def show @thesis = Thesis.load params[:id] end
[ "def show\n @thesis = Thesis.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @thesis }\n end\n end", "def show\n @swit.sours.find(params[:id])\n end", "def show\n @truites = Truite.find(params[:id])\n end", "def index\n @theses = Thesis.all\n \n end", "def show\n @thesis_change = ThesisChange.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thesis_change }\n end\n end", "def show\n @sour = @swit.sours.find(params[:id])\n end", "def show\n @thesis_review = ThesisReview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @thesis_review }\n end\n end", "def show\n @st_ipi = StIpi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @st_ipi }\n end\n end", "def show\n @st_icm = StIcm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @st_icm }\n end\n end", "def show\n @cst_pi = CstPis.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cst_pi }\n end\n end", "def show\n @technician = Technician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @technician }\n end\n end", "def show\n @tictac = Tictac.find(params[:id])\n\n end", "def show\n @sweet = @swit.sweets.find(params[:id])\n end", "def show\n @cst_ipi = CstIpi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cst_ipi }\n end\n end", "def show\n @sipoc = Sipoc.find(params[:id])\n end", "def show\n @simeast = Simeast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @simeast }\n end\n end", "def thesis\n 'Thesis/Dissertation' if record.find { |a| a.tag == '502' }\n end", "def show\n @strelki = Strelki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @strelki }\n end\n end", "def show\n @sti = Sti.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sti }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns truthy if the given frame carries HTTP semantics (so has to be sent in order)
def semantic_frame? f f.type == FrameTypes::DATA || f.type == FrameTypes::HEADERS || f.type == FrameTypes::CONTINUATION || f.type == FrameTypes::GZIPPED_DATA end
[ "def control_frame?(frame_type); end", "def head?\r\nHTTP_METHOD_LOOKUP[request_method] == :head\r\nend", "def is? frame_type\n return true if frame_type == :all\n detection = \"is_#{frame_type.to_s.sub(/frames$/, 'frame')}?\"\n begin \n self.send detection\n rescue NoMethodError => e\n false\n end\n end", "def content_complete?(frames)\n return false if frames.empty?\n header = frames[0]\n raise \"Not a content header frame first: #{header.inspect}\" unless header.kind_of?(AMQ::Protocol::HeadersFrame)\n header.body_size == frames[1..-1].inject(0) {|sum, frame| sum + frame.payload.size }\n end", "def connection_frame?(frame)\n frame[:stream] == 0 ||\n frame[:type] == :settings ||\n frame[:type] == :ping ||\n frame[:type] == :goaway\n end", "def content_complete?(frames)\n return false if frames.empty?\n header = frames[0]\n raise \"Not a content header frame first: #{header.inspect}\" unless header.kind_of?(AMQ::Protocol::HeaderFrame)\n header.body_size == frames[1..-1].inject(0) {|sum, frame| sum + frame.payload.size }\n end", "def connection_frame?(frame)\n (frame[:stream]).zero? ||\n frame[:type] == :settings ||\n frame[:type] == :ping ||\n frame[:type] == :goaway\n end", "def frameset_complete?(frames)\n return false if frames.empty?\n first_frame = frames[0]\n first_frame.final? || (first_frame.method_class.has_content? && content_complete?(frames[1..-1]))\n end", "def has_frame?(frame)\n self.frames.include?(frame.to_s)\n end", "def respond_to_performed?\n (response && response.content_type) ? true : false\n end", "def check_for_iframe_transport\n # Check whether this comes from jquery.iframe-transport\n # Eventually we're only supporting application/json so we expect X-HTTP-Accept to be just that\n @is_iframe_transport = params.delete('X-Requested-With') == 'IFrame' &&\n params.delete('X-HTTP-Accept').starts_with?(\"application/json\")\n end", "def http_forward?\n request_url.host.present?\n end", "def control_frame?(frame_type)\n !%i(text binary continuation).include?(frame_type)\n end", "def has_frame?(frame_name)\n frame_text = self.redirect {$ie.show_frames}\n !frame_text.match(\"#{frame_name}\").nil?\n end", "def control_frame?(opcode)\n (opcode & 0x8) > 0\n end", "def applies_to?(response)\n status, header, body = response\n\n # Some stati don't have to be processed\n return false if [301, 302, 303, 307].include?(status)\n\n # Check mime type\n return false if @mime_types.all? do |type|\n !header['Content-Type'].to_s.include?(type)\n end\n\n # Find ESI tags\n response[2] = [body = join_body(body)]\n body.include?('<esi:')\n end", "def valid_for?(request)\n request.uri == @request_uri and \n @request_vary_headers.all? {|key, value| \n request.header[key] == value\n }\n end", "def framed?\n return @peer.framed?\n end", "def body?\n HTTY::Request::METHODS_SENDING_BODY.include? method\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Are we configured to accept GZIPPED_DATA frames from this peer? Takes into account peer's apparent ability to correctly send gzip.
def accept_gzip? return if @ext__veto_gzip @ext__recv_gzip end
[ "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def send_gzip?\n return if !@ext__peer_gzip\n @ext__send_gzip\n end", "def can_gzip?\n return false if gzipped?\n\n # Sequence data & AnnData files either already are or could be gzipped\n !PRIMARY_DATA_TYPES.include?(file_type) && file_type != 'AnnData' && !upload_file_name.ends_with?('.cram')\n end", "def no_accept_gzip!\n return if @ext__veto_gzip\n if @ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0})\n @ext__recv_gzip = false\n end\n end", "def gzipped_response?\n headers[\"Content-Encoding\"] == \"gzip\"\n end", "def is_gzip(data) \n /^\\x1F\\x8B/n.match(data) != nil\n end", "def gzipped_body?\n @http[\"content-encoding\"] == \"gzip\" || @http.body[0..1] == \"\\x1f\\x8b\"\n end", "def check_accept_encoding\n if accept = @stream.request.headers[ACCEPT_ENCODING_KEY]\n accept.split(',').map(&:strip).each do |encoding|\n case encoding\n when GZIP_ENCODING\n if @stream.connection.server.options[:gzip]\n @gzip = true\n @headers[CONTENT_ENCODING_KEY] = GZIP_ENCODING\n break\n end\n\n # \"deflate\" has issues: https://zlib.net/zlib_faq.html#faq39\n #\n when DEFLATE_ENCODING\n if @stream.connection.server.options[:deflate]\n @deflate = true\n @headers[CONTENT_ENCODING_KEY] = DEFLATE_ENCODING\n break\n end\n\n end\n end\n end\n end", "def gzip?\n return @use_gzip unless @use_gzip.nil?\n @use_gzip = headers[\"content-encoding\"] == \"gzip\" if\n headers[\"content-encoding\"]\n end", "def skip_gzip?\n !gzip?\n end", "def gzipped?(env)\n env[:response_headers][CONTENT_ENCODING_HEADER] == ENCODING\n end", "def compressed?\n %w[ gzip deflate ].include? content_encoding\n end", "def compression?\n compression == :standard || (compression == :delayed && socket.hints[:authenticated])\n end", "def gzip?\n config[:gzip_enabled]\n end", "def chunked?\n return false unless @header['transfer-encoding']\n field = self['Transfer-Encoding']\n (/(?:\\A|[^\\-\\w])chunked(?![\\-\\w])/i =~ field) ? true : false\n end", "def deflated?\n return !gzip? && @use_inflate unless @use_inflate.nil?\n @use_inflate = headers[\"content-encoding\"] == \"deflate\" if\n headers[\"content-encoding\"]\n end", "def gzip_enabled; end", "def gzipped?\n File.open(local_location.to_s).read(2) == GZIP_MAGIC_NUMBER # per IETF\n end", "def testing_compression?\n compression_enabled? && op_msg_enabled?\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
tell the peer we'll accept GZIPPED_DATA frames
def accept_gzip! return if @ext__veto_gzip if !@ext__recv_gzip send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1}) @ext__recv_gzip = true end end
[ "def accept_gzip?\n return if @ext__veto_gzip\n @ext__recv_gzip\n end", "def no_accept_gzip!\n return if @ext__veto_gzip\n if @ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0})\n @ext__recv_gzip = false\n end\n end", "def send_gzip?\n return if !@ext__peer_gzip\n @ext__send_gzip\n end", "def gzip_requests; end", "def conclude_gzip\n return nil unless @buff.length > 10 and @buff.length <= @maxlen\n io_data = StringIO.new(@buff)\n unzipped = nil\n begin\n # Get the gzipped data\n z_stream = Zlib::GzipReader.new(io_data)\n unzipped = z_stream.read\n z_stream.close\n rescue\n return nil\n end\n\n # Run this new file through the file parser now\n fparser = FileParser.new(@event_collector, @state, @sdir, :gzip,\n (@name ? \"#{@name}.gunzipped\" : nil))\n fparser.maxlen = unzipped.length # Not buffering, we have the whole thing\n fparser.parse(unzipped)\n fparser.conclude\n end", "def received_frame(frame_data); end", "def test_gzipped_data()\n report = (RUBY_VERSION >= '1.9.1') ?\n GZIPPED_REPORT.force_encoding('UTF-8') : GZIPPED_REPORT\n response = ResponseStub.new(200, report)\n assert_nothing_raised do\n @report_utils.check_for_errors(response)\n end\n end", "def is_gzip(data) \n /^\\x1F\\x8B/n.match(data) != nil\n end", "def check_accept_encoding\n if accept = @stream.request.headers[ACCEPT_ENCODING_KEY]\n accept.split(',').map(&:strip).each do |encoding|\n case encoding\n when GZIP_ENCODING\n if @stream.connection.server.options[:gzip]\n @gzip = true\n @headers[CONTENT_ENCODING_KEY] = GZIP_ENCODING\n break\n end\n\n # \"deflate\" has issues: https://zlib.net/zlib_faq.html#faq39\n #\n when DEFLATE_ENCODING\n if @stream.connection.server.options[:deflate]\n @deflate = true\n @headers[CONTENT_ENCODING_KEY] = DEFLATE_ENCODING\n break\n end\n\n end\n end\n end\n end", "def stream_file\n while @looping do\n if @sent < @size\n if get_outbound_data_size > 4 * CHUNKSIZE\n EventMachine.next_tick{ stream_file }\n break\n else\n to_send = [CHUNKSIZE, @size - @sent].min\n @sent += to_send\n\n data = @file.read to_send\n if @zlib\n flush_flag = (@sent == @size ? Zlib::FINISH : Zlib::NO_FLUSH)\n data = @deflator.deflate data, flush_flag\n end\n\n send_data data\n end\n else\n finish_streaming\n break\n end\n end\n\n if @canceled\n send_message 'Canceled'\n finish_streaming\n end\n end", "def send_gzip!\n if !@ext__send_gzip\n @ext__send_gzip = true\n end\n end", "def inflater # :nodoc:\n return yield @socket unless Net::HTTP::HAVE_ZLIB\n return yield @socket unless @decode_content\n return yield @socket if self['content-range']\n\n v = self['content-encoding']\n case v&.downcase\n when 'deflate', 'gzip', 'x-gzip' then\n self.delete 'content-encoding'\n\n inflate_body_io = Inflater.new(@socket)\n\n begin\n yield inflate_body_io\n success = true\n ensure\n begin\n inflate_body_io.finish\n if self['content-length']\n self['content-length'] = inflate_body_io.bytes_inflated.to_s\n end\n rescue => err\n # Ignore #finish's error if there is an exception from yield\n raise err if success\n end\n end\n when 'none', 'identity' then\n self.delete 'content-encoding'\n\n yield @socket\n else\n yield @socket\n end\n end", "def send_data(data = \"\", end_stream: true)\n max = @connection.remote_settings[:max_frame_size]\n if data.is_a?(IO)\n until data.eof?\n fragment = data.readpartial(max)\n send Frame::Data.new(id, fragment, end_stream: end_stream && data.eof?)\n end\n else\n send Frame::Data.new(id, data, end_stream: end_stream)\n end\n @state = :half_closed_local if end_stream\n end", "def proxy_receive_data data\n @proxystatus = :headers if !@proxystatus\n \n if @proxystatus == :headers\n # First gather the headers\n @proxybuffer += data\n if @proxybuffer =~ /\\r\\n\\r\\n/\n\n # Detected end of headers\n header_data = @proxybuffer[0...($~.begin(0))]\n @proxybuffer = @proxybuffer[($~.end(0))..-1]\n\n # Try the webrick parser\n headers = {}\n header_lines = header_data.split(/[\\r\\n]+/)\n status = header_lines[0]\n header_lines[1..-1].each do |line|\n h = line.split(/:\\s*/, 2)\n headers[h[0]] = h[1]\n end\n \n # The rest of the incoming connection \n @proxystatus = :stream\n end\n end\n \n if @proxystatus == :stream\n send_data header_lines[0] + \"\\r\\n\"\n send_data \"Content-Type: \" + headers['Content-Type'] + \"\\r\\n\"\n send_data \"Content-Length: \" + headers['Content-Length'] + \"\\r\\n\"\n send_data \"\\r\\n\"\n send_data @proxybuffer\n\n # Any further data is piped through \n EM::enable_proxy proxy_conn, self, 1024*10\n end\n end", "def send_data(chunk, maximum_size); end", "def receive_data(frame)\n\t\t\t\tif @state == :open\n\t\t\t\t\tupdate_local_window(frame)\n\t\t\t\t\t\n\t\t\t\t\tif frame.end_stream?\n\t\t\t\t\t\t@state = :half_closed_remote\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tprocess_data(frame)\n\t\t\t\telsif @state == :half_closed_local\n\t\t\t\t\tupdate_local_window(frame)\n\t\t\t\t\t\n\t\t\t\t\tprocess_data(frame)\n\t\t\t\t\t\n\t\t\t\t\tif frame.end_stream?\n\t\t\t\t\t\tclose!\n\t\t\t\t\tend\n\t\t\t\telsif self.closed?\n\t\t\t\t\tignore_data(frame)\n\t\t\t\telse\n\t\t\t\t\t# If a DATA frame is received whose stream is not in \"open\" or \"half-closed (local)\" state, the recipient MUST respond with a stream error (Section 5.4.2) of type STREAM_CLOSED.\n\t\t\t\t\tself.send_reset_stream(Error::STREAM_CLOSED)\n\t\t\t\tend\n\t\t\tend", "def received?(bytes)\n @data && @data.length >= bytes\n end", "def recv(tag, sock, io)\n sock.send(Packet::ACK.new(0).encode, 0)\n seq = 1\n begin\n loop do\n unless IO.select([sock], nil, nil, @timeout)\n log :warn, \"#{tag} Timeout at block ##{seq}\"\n return false\n end\n msg, _ = sock.recvfrom(516, 0)\n pkt = Packet.parse(msg)\n if pkt.class != Packet::DATA\n log :warn, \"#{tag} Expected DATA but got: #{pkt.class}\"\n return false\n end\n if pkt.seq != seq\n log :warn, \"#{tag} Seq mismatch: #{seq} != #{pkt.seq}\"\n return false\n end\n io.write(pkt.data)\n sock.send(Packet::ACK.new(seq).encode, 0)\n break if pkt.last?\n seq = (seq + 1) & 0xFFFF\n end\n rescue ParseError => e\n log :warn, \"#{tag} Packet parse error: #{e.to_s}\"\n return false\n end\n log :info, \"#{tag} Received file\"\n true\n end", "def gzipped_response?\n headers[\"Content-Encoding\"] == \"gzip\"\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
tell the peer we don't accept GZIPPED_DATA frames
def no_accept_gzip! return if @ext__veto_gzip if @ext__recv_gzip send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0}) @ext__recv_gzip = false end end
[ "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def skip_gzip?\n !gzip?\n end", "def accept_gzip?\n return if @ext__veto_gzip\n @ext__recv_gzip\n end", "def send_gzip?\n return if !@ext__peer_gzip\n @ext__send_gzip\n end", "def is_gzip(data) \n /^\\x1F\\x8B/n.match(data) != nil\n end", "def test_gzipped_data()\n report = (RUBY_VERSION >= '1.9.1') ?\n GZIPPED_REPORT.force_encoding('UTF-8') : GZIPPED_REPORT\n response = ResponseStub.new(200, report)\n assert_nothing_raised do\n @report_utils.check_for_errors(response)\n end\n end", "def cannot_compress?\n !can_compress?\n end", "def ignore_extra_bytes?\n @ignore_extra_bytes\n end", "def accept_no_image_data\n @accept_no_image_data = true\n end", "def captured_data_tag\n CapturedDataTags::DROPPED_EXIF_DATA\n end", "def send_gzip!\n if !@ext__send_gzip\n @ext__send_gzip = true\n end\n end", "def check_accept_encoding\n if accept = @stream.request.headers[ACCEPT_ENCODING_KEY]\n accept.split(',').map(&:strip).each do |encoding|\n case encoding\n when GZIP_ENCODING\n if @stream.connection.server.options[:gzip]\n @gzip = true\n @headers[CONTENT_ENCODING_KEY] = GZIP_ENCODING\n break\n end\n\n # \"deflate\" has issues: https://zlib.net/zlib_faq.html#faq39\n #\n when DEFLATE_ENCODING\n if @stream.connection.server.options[:deflate]\n @deflate = true\n @headers[CONTENT_ENCODING_KEY] = DEFLATE_ENCODING\n break\n end\n\n end\n end\n end\n end", "def reject?(data)\n !accept?(data)\n end", "def gzip_requests; end", "def ignore_encoding_error; end", "def edge_block_sending_do_not_track_header\n return @edge_block_sending_do_not_track_header\n end", "def support_unencrypted_data; end", "def decline\n @stream.clear_handlers :ibb_open, :from => @iq.from\n @stream.clear_handlers :ibb_data, :from => @iq.from, :sid => @iq.sid\n @stream.clear_handlers :ibb_close, :from => @iq.from, :sid => @iq.sid\n @stream.write StanzaError.new(@iq, 'not-acceptable', :cancel).to_node\n end", "def conclude_gzip\n return nil unless @buff.length > 10 and @buff.length <= @maxlen\n io_data = StringIO.new(@buff)\n unzipped = nil\n begin\n # Get the gzipped data\n z_stream = Zlib::GzipReader.new(io_data)\n unzipped = z_stream.read\n z_stream.close\n rescue\n return nil\n end\n\n # Run this new file through the file parser now\n fparser = FileParser.new(@event_collector, @state, @sdir, :gzip,\n (@name ? \"#{@name}.gunzipped\" : nil))\n fparser.maxlen = unzipped.length # Not buffering, we have the whole thing\n fparser.parse(unzipped)\n fparser.conclude\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Are we configured to send GZIPPED_DATA frames to this peer? Takes into account peer's settings for receiving them.
def send_gzip? return if !@ext__peer_gzip @ext__send_gzip end
[ "def accept_gzip?\n return if @ext__veto_gzip\n @ext__recv_gzip\n end", "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def no_accept_gzip!\n return if @ext__veto_gzip\n if @ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0})\n @ext__recv_gzip = false\n end\n end", "def can_gzip?\n return false if gzipped?\n\n # Sequence data & AnnData files either already are or could be gzipped\n !PRIMARY_DATA_TYPES.include?(file_type) && file_type != 'AnnData' && !upload_file_name.ends_with?('.cram')\n end", "def gzipped_response?\n headers[\"Content-Encoding\"] == \"gzip\"\n end", "def skip_gzip?\n !gzip?\n end", "def send_gzip!\n if !@ext__send_gzip\n @ext__send_gzip = true\n end\n end", "def compression?\n compression == :standard || (compression == :delayed && socket.hints[:authenticated])\n end", "def testing_compression?\n compression_enabled? && op_msg_enabled?\nend", "def gzip?\n return @use_gzip unless @use_gzip.nil?\n @use_gzip = headers[\"content-encoding\"] == \"gzip\" if\n headers[\"content-encoding\"]\n end", "def gzip?\n config[:gzip_enabled]\n end", "def is_gzip(data) \n /^\\x1F\\x8B/n.match(data) != nil\n end", "def deflated?\n return !gzip? && @use_inflate unless @use_inflate.nil?\n @use_inflate = headers[\"content-encoding\"] == \"deflate\" if\n headers[\"content-encoding\"]\n end", "def gzipped?(env)\n env[:response_headers][CONTENT_ENCODING_HEADER] == ENCODING\n end", "def enable_gzip; @opts[:enable_gzip]; end", "def gzip_enabled; end", "def gzipped_body?\n @http[\"content-encoding\"] == \"gzip\" || @http.body[0..1] == \"\\x1f\\x8b\"\n end", "def chunked?\n return false unless @header['transfer-encoding']\n field = self['Transfer-Encoding']\n (/(?:\\A|[^\\-\\w])chunked(?![\\-\\w])/i =~ field) ? true : false\n end", "def compressed_only?\n !source_data? && !target_data?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
application lets us send GZIPPED_DATA frames to this peer
def send_gzip! if !@ext__send_gzip @ext__send_gzip = true end end
[ "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def send_data_with_http_tunnel(data)\n #msg_data = Base64::encode64(data)\n #@socket_srv.print \"GET /office_send_msg?#{msg_data} HTTP/1.1\\r\\n\"\n # Zip deflate avoid to have special character in the encoded argument\n msg_data = Zlib::Deflate.deflate( data, 1 ).unpack('H*').first \n @socket_srv.print \"GET /office_send_msg?#{msg_data} HTTP/1.1\\r\\n\"\n #@socket_srv.print \"GET /office_send_msg HTTP/1.1\\r\\n\"\n @socket_srv.print \"Host: #{@host_server}:#{@port_server}\\r\\n\"\n @socket_srv.print \"X-Cup-Session-Id: #{@id_http_session}\\r\\n\" if @id_http_session\n @socket_srv.print \"User-Agent: Mozilla/5.0\\r\\n\"\n @socket_srv.print \"Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\"\n @socket_srv.print \"Keep-Alive: 300\\r\\n\"\n @socket_srv.print \"Connection: keep-alive\\r\\n\"\n @socket_srv.print \"\\r\\n\" #end message\n #http_packet = \n #@socket_srv.write(http_packet)\n end", "def send_data(chunk, maximum_size); end", "def send_data(data = \"\", end_stream: true)\n max = @connection.remote_settings[:max_frame_size]\n if data.is_a?(IO)\n until data.eof?\n fragment = data.readpartial(max)\n send Frame::Data.new(id, fragment, end_stream: end_stream && data.eof?)\n end\n else\n send Frame::Data.new(id, data, end_stream: end_stream)\n end\n @state = :half_closed_local if end_stream\n end", "def no_accept_gzip!\n return if @ext__veto_gzip\n if @ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0})\n @ext__recv_gzip = false\n end\n end", "def send_chunk(data)\n response.write('%x' % data.size + \"\\r\\n\")\n response.write(data + \"\\r\\n\")\n end", "def send_gzip?\n return if !@ext__peer_gzip\n @ext__send_gzip\n end", "def gzip\n read_io, write_io = IO.pipe\n gz = Lazy::Zlib::GzipWriter.new(write_io)\n gz.write(data_string)\n gz.close\n process(:append => '.gz') { read_io }\n end", "def compress_gzip(data)\n buffer = StringIO.new('','w')\n compressor = Zlib::GzipWriter.new(buffer)\n begin\n compressor.write(data)\n ensure\n compressor.close()\n end\n buffer.string\n end", "def gzip_requests; end", "def send_data_packet( data )\n # overhead is ( byte.length + id.length + strlen.length ) = 9\n data, data_to_return = split_data_for_packet( data.to_s, 9 )\n @window_size -= data.length\n\n msg = @buffers.writer\n msg.write_byte CHANNEL_DATA\n msg.write_long @remote_id\n msg.write_string data\n @connection.send_message msg\n\n data_to_return\n end", "def compress(data); end", "def test_gzipped_data()\n report = (RUBY_VERSION >= '1.9.1') ?\n GZIPPED_REPORT.force_encoding('UTF-8') : GZIPPED_REPORT\n response = ResponseStub.new(200, report)\n assert_nothing_raised do\n @report_utils.check_for_errors(response)\n end\n end", "def stream_file\n while @looping do\n if @sent < @size\n if get_outbound_data_size > 4 * CHUNKSIZE\n EventMachine.next_tick{ stream_file }\n break\n else\n to_send = [CHUNKSIZE, @size - @sent].min\n @sent += to_send\n\n data = @file.read to_send\n if @zlib\n flush_flag = (@sent == @size ? Zlib::FINISH : Zlib::NO_FLUSH)\n data = @deflator.deflate data, flush_flag\n end\n\n send_data data\n end\n else\n finish_streaming\n break\n end\n end\n\n if @canceled\n send_message 'Canceled'\n finish_streaming\n end\n end", "def content_encoding_gunzip(body_io); end", "def send_binary(data)\n if @handler\n @handler.send_frame(:binary, data)\n else\n raise WebSocketError, \"Cannot send binary before onopen callback\"\n end\n end", "def conclude_gzip\n return nil unless @buff.length > 10 and @buff.length <= @maxlen\n io_data = StringIO.new(@buff)\n unzipped = nil\n begin\n # Get the gzipped data\n z_stream = Zlib::GzipReader.new(io_data)\n unzipped = z_stream.read\n z_stream.close\n rescue\n return nil\n end\n\n # Run this new file through the file parser now\n fparser = FileParser.new(@event_collector, @state, @sdir, :gzip,\n (@name ? \"#{@name}.gunzipped\" : nil))\n fparser.maxlen = unzipped.length # Not buffering, we have the whole thing\n fparser.parse(unzipped)\n fparser.conclude\n end", "def do_data( data )\n @log.debug \"[#{@id}] got #{data.length} bytes\" if @log.debug?\n\n @data << data\n @progress_callback[@data] if @progress_callback\n\n if @length < 0 || @data.length < @length\n if @length < 0\n length = @chunk_size\n else\n length = @length - @data.length\n length = length > @chunk_size ? @chunk_size : length\n end\n\n @log.debug \"[#{@id}] requesting #{length} more bytes\" if @log.debug?\n @driver.read @id, @handle, @offset + @data.length, length\n @session.register( @id, self )\n else\n @callback[ OK, @data ]\n end\n end", "def accept_gzip?\n return if @ext__veto_gzip\n @ext__recv_gzip\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
does the questions table need an answer_id to make this connection work? generate question objects that are associated to quiz by question_id
def create_question question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions. new_question = Question.new #make a new question instance new_question.save #save now so we can store the question's id in the answer by calling self.id new_question.content = question_hash['question'] #adding all necessary column data to this question object/row new_question.create_answers(question_hash) new_question.quiz_id = self.id new_question.save #send the newly created question to the database end
[ "def setup_answers\n create :answer, question: @question1, response_id: @response.id, answer: 1, comments: 'True_1'\n create :answer, question: @question2, response_id: @response.id, answer: 0, comments: 'False_2'\n create :answer, question: @question3, response_id: @response.id, answer: 0, comments: 'Answer2_3'\n create :answer, question: @question4, response_id: @response.id, answer: 1, comments: 'Answer1_4'\n create :answer, question: @question4, response_id: @response.id, answer: 1, comments: 'Answer3_4'\nend", "def questions\n results = CONNECTION.execute(\"SELECT * FROM questions WHERE student_id = #{@id};\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << Question.new(result_hash[\"id\"], result_hash[\"student_id\"], result_hash[\"content\"])\n end\n \n return results_as_objects\n end", "def generate_questions(quiz)\n randomQuestions = Question.order('RANDOM()').take(10)\n\n for question in randomQuestions do\n QuestionsQuiz.create(quiz: quiz, question: question)\n end\n end", "def init_answers(questions)\n questions.each do |q|\n # it's unlikely that these answers exist, but in case the user refresh the browser some might have been inserted.\n answer = Answer.where(response_id: @response.id, question_id: q.id).first\n if answer.nil?\n Answer.create(response_id: @response.id, question_id: q.id, answer: nil, comments: '')\n end\n end\n end", "def generate_questions(room)\n # Temporarily assign all the questions to each room\n room.questions = Question.all\n room.save\n end", "def questions\n questions = {}\n object.questions.each do |q|\n questions[q.id] = QuestionSerializer.new(q).as_json\n end\n questions\n end", "def genQuestionaire\n #Table \"questions\" from the database through instance variable \"roster\"\n roster=@DB[:questions]\n #Limit for the iterator that will generate the list of questions\n lim=@number-1\n #Space available\n available=[]\n #This iterator stores the whole database in the \"available\" variable\n #in the form of several \"Question\" objects\n (1..40).each do |index|\n #Paramters for the \"Question\" class are set\n #Question text\n q=roster.first(id: index)[:question].to_s\n #Answer a\n a=roster.first(id: index)[:answerA].to_s\n #Answer b\n b=roster.first(id: index)[:answerB].to_s\n #Answer c\n c=roster.first(id: index)[:answerC].to_s\n #Correct answer\n corr=roster.first(id: index)[:correct].to_s\n #Questions are built\n available.push Question.new q, a, b, c, corr\n end\n \n #The \"available\" variable is randomized and stored in the \"scrambled\" variable\n scrambled=available.shuffle\n \n #This iterator takes the number of questions specified by the users and stores \n #them in the final questionaire\n (0..lim).each do |question|\n @questions.push scrambled[question]\n end\n puts \n end", "def answers\n return Answer.where(question_id: self.id) \n end", "def response_to_questions\n opts[:questions].each do |response|\n @obj.response_questions.build(\n question_id: response[:id],\n question: response[:question],\n answer: response[:answer],\n default_question: response[:default_question]\n )\n end\n end", "def create_question_set(round_id)\n puts 'Entering create_question_set()'\n diff_lvl = Round.find(round_id).difficulty_level_id\n\n existing_qo_set = QuestionOccurrence.where(round_id: round_id)\n last_qo_index = existing_qo_set.length\n\n if (last_qo_index < MAX_NUM_QUESTIONS)\n puts \"Creating #{MAX_NUM_QUESTIONS - last_qo_index} QO objects for round #{round_id}\"\n existing_questions = existing_qo_set.map{|qo| qo.question}\n question_pool = Question.where(\"difficulty_level_id = ?\", diff_lvl).shuffle - existing_questions\n question_pool.first(MAX_NUM_QUESTIONS - last_qo_index).each{|q| last_qo_index += 1; qo=QuestionOccurrence.new(round_id: round_id, question_id: q.id, index_in_round: last_qo_index); qo.save; }\n else\n puts 'No need to create additional QO objects'\n end\n puts 'Exiting create_question_set()'\n end", "def equip_with_questions(set=nil)\n set = [\"now_how_happy\",\"now_how_alert\",\"now_how_purposeful\",\"self_reflection\"] if set.nil?\n set.each do |name|\n q = Question.find_by_name(name)\n Answer.create({survey_id: self.id, question_id: q.id})\n end\n end", "def gen_questions\n\t\tif self.questions.first.nil?\n\t\t transaction do\n\t\t @array=self.gen_ran_array(:total_qn=>Rhconfig.find_by_country(self.country).total_qn,:num_qn_topic=>Rhconfig.find_by_country(self.country).qn_per_topic,:diff_qn=>Rhconfig.find_by_country(self.country).add_diff_qn,:norm_qn=>Rhconfig.find_by_country(self.country).add_norm_qn,:easy_qn=>Rhconfig.find_by_country(self.country).add_easy_qn)\n\t\t @array.each_with_index do |i,index|\n\t\t\t self.questions.build(:question_idx => index+1, :question_no=>i,:answer=>\"\",:score=>0)\n\t\t\t end\n\t\t self.save\n\t\t end\n\t\tend\n\tend", "def import_answer_choices\n @questions = Question.all.order(\"id\")\n end", "def quiz_questionnaire num_quiz_questions\n\n # New questionnaire from params\n questionnaire = QuizQuestionnaire.new(questionnaire_params)\n\n # Set min and max score\n questionnaire.max_question_score = 1\n questionnaire.min_question_score = 0\n\n # Set author team\n author_team = AssignmentTeam.team(Participant.find(params[:pid]))\n questionnaire.instructor_id = author_team.id\n\n # Create each quiz question.\n create_quiz_questions(num_quiz_questions) do |question|\n\n # Add the question to the questionnaire\n questionnaire.quiz_questions << question\n\n # Create each question choice\n create_quiz_question_choices(question) do |choice|\n\n # Add the choice to the question\n question.quiz_question_choices << choice\n end\n end\n\n questionnaire\n end", "def create_quiz_question_instances(quiz_id,assessment_div_id,question_collection)\n quiz = Quiz.find(quiz_id)\n if quiz.quiz_sections.empty?\n # add questions to the quiz directly\n quiz.questions += question_collection\n return quiz\n else\n # add questions to corresponding section\n question_collection.each do |question|\n if !quiz.question_ids.include? question.id\n quiz_question_instance = QuizQuestionInstance.new(:quiz_id=>quiz_id,:question_id=>question.id,:quiz_section_id=>assessment_div_id)\n quiz_question_instance.save\n end\n end\n return QuizSection.find(assessment_div_id)\n end\n end", "def questions\n questions_hash = self.questions_hash()\n questions = []\n\n self.question_ids.each do |question_id|\n questions << questions_hash[question_id]\n end\n\n questions\n end", "def test_find_questions_answers_for_test\n create_template(\"Test Template\")\n template_id = find_last_template_id\n create_template_question(\"Question 1\", template_id)\n create_test(template_id)\n\n question_id = find_last_question_id\n test_id = find_last_test_id\n\n add_answer(question_id, test_id, \"Answer 1\")\n questions_and_answers = @db.find_questions_and_answers_for_test(test_id)\n\n assert_instance_of(Array, questions_and_answers)\n\n delete_template(template_id)\n end", "def get_questions\n result = QuizQuestion.includes(:quiz_answers).where(quiz_id: params[:id])\n\n @questions = result.map { |question| QuestionPresenter.new(question) }\n end", "def questions_hash\n questions = {}\n\n Question.where(:id => question_ids).find_each do |question|\n questions[question.id] = question\n end\n\n questions\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Centroid of an empty should return an empty collection rather than throw a weird exception out of ffigeos
def test_empty_centroid assert_equal(@factory.collection([]), @factory.multi_polygon([]).centroid) end
[ "def test_empty_centroid\n assert_equal(@factory.collection([]), @factory.multi_polygon([]).centroid)\n end", "def centroid\n @centroid = @geometry.centroid unless @centroid\n @centroid\n end", "def centroid\n return @centroid if defined?(@centroid)\n\n cx, cy = 0, 0\n\n (0...vertices.length).each do |i|\n prev = vertices[i - 1]\n curr = vertices[i]\n\n v = prev.x * curr.y - curr.x * prev.y\n cx += v * (prev.x + curr.x)\n cy += v * (prev.y + curr.y)\n end\n\n @centroid = Point.new(Rational(cx, 6 * self.area), Rational(cy, 6 * self.area))\n @centroid\n end", "def centroid\n raise Error::UnsupportedOperation, \"Method MultiSurface#centroid not defined.\"\n end", "def get_centroids\n getClusterCentroids\n end", "def find_mean(things)\n begin\n @centre = Point.new\n @centre.latitude = 51.475 # Greenwich Meridian\n @centre.longitude = 0\n begin\n @lat = 0\n @lon = 0\n @count = 0\n things.each do |thing|\n if thing.geolocated?\n @lat += thing.latitude\n @lon += thing.longitude\n @count = @count + 1\n end\n end\n @centre.latitude = @lat / @count\n @centre.longitude = @lon / @count\n return @centre\n rescue\n # oh, maybe it's a thing that has plaques\n return find_mean(thing.plaques)\n end\n rescue\n # something went wrong, failing gracefully\n return @centre\n end\n end", "def find_mean(things)\n @centre = Point.new\n @centre.latitude = 51.475 # Greenwich Meridian\n @centre.longitude = 0\n begin\n @lat = 0\n @lon = 0\n @count = 0\n things.each do |thing|\n next unless thing.geolocated?\n\n @lat += thing.latitude\n @lon += thing.longitude\n @count += 1\n end\n @centre.latitude = @lat / @count\n @centre.longitude = @lon / @count\n @centre\n rescue\n # oh, maybe it's a thing that has plaques\n find_mean(thing.plaques)\n end\n end", "def build_centroids\n #sql = \"SELECT b.ogc_fid as id, ST_AsGeoJSON(ST_centroid(b.wkb_geometry)) as geo FROM buildings b\"\n sql = \"SELECT b.ogc_fid as id,\n st_x(st_transform(ST_Centroid(b.wkb_geometry),4326)) as lng,\n st_y(st_transform(ST_Centroid(b.wkb_geometry),4326)) as lat\n FROM buildings b;\"\n result_set = ActiveRecord::Base.connection.execute(sql)\n results = {}\n\n result_set.each do |row|\n results[row['id']] = [row['lng'],row['lat']]\n end\n results\n end", "def start_root_vertices\n vertices.select do |vertex|\n vertex.inE.empty?\n end\n end", "def empty?\n geom && geom.try(:is_empty?)\n end", "def find_feature_center(vertices)\n number_of_locations = vertices.length\n\n return vertices.first if number_of_locations == 1\n\n x = y = z = 0.0\n vertices.each do |station|\n latitude = station[1] * Math::PI / 180\n longitude = station[0] * Math::PI / 180\n\n x += Math.cos(latitude) * Math.cos(longitude)\n y += Math.cos(latitude) * Math.sin(longitude)\n z += Math.sin(latitude)\n end\n\n x /= number_of_locations\n y /= number_of_locations\n z /= number_of_locations\n\n central_longitude = Math.atan2(y, x)\n central_square_root = Math.sqrt(x * x + y * y)\n central_latitude = Math.atan2(z, central_square_root)\n\n [central_longitude * 180 / Math::PI,\n central_latitude * 180 / Math::PI]\n \n end", "def geographic_center(points); end", "def find_mean(things)\n begin\n @centre = Point.new\n @centre.latitude = 51.475 # Greenwich Meridian\n @centre.longitude = 0\n begin\n @lat = 0\n @lon = 0\n @count = 0\n things.each do |thing|\n if thing.geolocated?\n @lat += thing.latitude\n @lon += thing.longitude\n @count = @count + 1\n end\n end\n @centre.latitude = @lat / @count\n @centre.longitude = @lon / @count\n# puts (\"****** lat= \" + @centre.latitude.to_s + \",lon= \" + @centre.longitude.to_s + \" from \" + thing.size.to_s + \" plaques, \" + @count.to_s + \" are geolocated\")\n return @centre\n rescue\n # oh, maybe it's a thing that has plaques\n return find_mean(thing.plaques)\n end\n rescue\n # something went wrong, failing gracefully\n return @centre\n end\n end", "def empty?\n coordinates.empty?\n end", "def find_center(collection)\n sum_lat = 0.0\n sum_lng = 0.0\n count = 0\n collection.each do |llp| # should be a collection of LatLonPoints\n count += 1\n sum_lat += llp.lat unless llp.lat.nil?\n sum_lng += llp.lon unless llp.lon.nil?\n end\n {:lng => sum_lng / count, :lat => sum_lat / count} #return a hash\n [sum_lat/count, sum_lng/count] # return an array\n end", "def test_centroid\n acceptable_delta = 0.000000001\n \n addresses(:centroid).recalculate_points!\n\n assert_in_delta 6.20973782771536, addresses(:centroid).centroid.lat, acceptable_delta\n assert_in_delta 8.65792759051186, addresses(:centroid).centroid.long, acceptable_delta\n end", "def empty?() vertices.size.zero?; end", "def calculate_centroid(points)\n sum_x = 0\n sum_y = 0\n \n points.each do |p|\n sum_x += p[:x]\n sum_y += p[:y]\n end\n n = points.length\n {x: sum_x / n, y: sum_y / n}\nend", "def test_clear_already_empty\n assert_nothing_raised do \n bbox = Geom::BoundingBox.new\n bbox.clear\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
API to request a random speach of Robert with a direction to user
def random_roberto_speech skip_authorization respond_to do |format| format.json do render json: { roberto_speech: "#{RobertoBarros.in_ingrish} #{direction_for_active_cell(@play)}" } end end end
[ "def greeting\n random_response :greeting\n end", "def greeting\n\t\trandom_response(:greeting)\n\tend", "def find_random_friend\r\n login\r\n doc = hpricot_get_url '/b.php?k=10010'\r\n friend_row = (doc/\"div.result//dd.result_name/a\").random\r\n parse_friend_row friend_row\r\n end", "def random\n redirect_to_random(Word)\n end", "def select_word\n uri = URI('https://random-word-api.herokuapp.com/word?number=5')\n words = Net::HTTP.get(uri) \n words = words.delete(\"[\").delete(\"]\").delete(\"\\\"\")\n words = words.split(\",\")\n index = rand(words.count - 1)\n return words[index]\n end", "def farewell\n\t\trandom_response(:farewell)\n\tend", "def random\n Client.get(\"/patterns/random\")\n end", "def get_random_verse\n if params[:random] != \"verse\"\n nil\n else\n translation = get_translation\n return jsonp(translation[:error]) if translation[:error]\n\n books_size = DB['select book_num from verses where translation_id = ? order by book_num desc limit 1;', translation[:id]].first[:book_num]\n book_num = rand(books_size) + 1\n book = DB['select book from verses where translation_id = ? && book_num = ?;', translation[:id], book_num].first[:book]\n\n chapters_size = DB['select chapter from verses where translation_id = ? && book_num = ? order by chapter desc limit 1;', translation[:id], book_num].first[:chapter]\n chapter = rand(chapters_size) + 1\n\n verses_size = DB['select verse from verses where translation_id = ? && book_num = ? && chapter = ? order by verse desc limit 1;', translation[:id], book_num, chapter].first[:verse]\n verse = rand(verses_size) + 1\n \"#{book} #{chapter}:#{verse}\"\n end\nend", "def getUserToReply\n followers = self::get_followers\n followers[:result][rand(followers[:result].length)]\n end", "def random\n @motif = Motif.order(\"RANDOM()\").first;\n render json: @motif.as_json(only: :name)\n end", "def farewell\n\t\trandom_response :farewell\n\tend", "def random\n @page = @agent.get @random_url\n\n extract_title\n end", "def random_response(key)\n\t\t@data[:responses][key].sample.gsub(/\\[name\\]/, @name)\n\tend", "def get_random_fact_from_numbers_api( n )\n url = \"https://numbersapi.p.mashape.com/#{n}\" +\n \"/trivia?fragment=true&json=true&notfound=floor\"\n response = Unirest.get( url, headers: { \"X-Mashape-Key\" => $API_KEY } )\n # return the random fact\n return response.body[\"text\"]\nend", "def random(state = true)\n send_request('random %s' % state.to_i)\n end", "def granny_response say_to_granny\n if shouted?(say_to_granny)\n \"NO, NOT SINCE #{1930 + rand(20)}!\"\n else\n 'HUH?! SPEAK UP, SONNY!'\n end\nend", "def random_pokemon\n HTTParty.get(\"http://pokeapi.co/api/v2/pokemon/?offset=#{random_offset}&limit=1\").parsed_response['results'].first\n end", "def random_name\n render response_ok Game.find(params[:game_id]).random_name\n end", "def random\n RandomJam.jam(@api_key, @https)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the CollectionEventParameters for this Collectible.
def collection_event_parameters event_parameters.detect { |ep| CaTissue::CollectionEventParameters === ep } end
[ "def parameters\n params = []\n self.event_parameters.each do |param|\n params << OpenStruct.new( :param_id => param.id, :name => param.Description, :param_type => param.parameter_type.Description )\n end\n params\n end", "def chargable_params\n chargable_events = Event.where(resource_id: @resource.id, started_at: billing_period.first..billing_period.last).where.not(name: :create)\n .or(Event.where(resource_id: @resource.id, finished_at: billing_period.first..billing_period.last).create_name)\n .order(name: :desc, started_at: :desc)\n\n # TODO: refactor\n unless @event.create_name? || chargable_events&.last&.create_name? # don't look for previous events in case of create\n if chargable_events.blank? || (chargable_events && chargable_events.last.started_at > billing_period.first) # started_at cause last event name is not \"create\"\n last_event = @resource.last_event_before(billing_period.first)\n chargable_events += [last_event] if last_event\n end\n end\n\n chargable_events.map(&:resource_parameters)\n end", "def collection_query_params\n []\n end", "def collection\n Rails.logger.info \"XXXXX COLLECTION NAME #{collection_hash['collection name']}\"\n\n @collection ||= CollectionCreator.find_or_create_collection(\n collection_hash['collection name'],\n collection_hash['unit name'],\n collection_hash['collection description'],\n submitter_user_key\n )\n end", "def create_default_collection_event_parameters(rep)\n cep = parent.collection_event_parameters if parent\n user = cep.user if cep\n user ||= scg_collector || rep.user || return\n cep = CaTissue::CollectionEventParameters.new(:specimen => self, :user => user)\n logger.debug { \"Created default #{qp} collection event #{cep.qp}.\" }\n cep\n end", "def received_event_parameters\n event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep }\n end", "def get_collection_ivar #:nodoc:\n instance_variable_get(\"@#{resource_collection_name}\")\n end", "def scope_parameters\n self.class.map_to_scope_parameters(attributes)\n end", "def input_collection\n run_context.input_collection\n end", "def parameters\n elements.select { |e| e.parameter?}\n end", "def extract_collection_parameters\n @time = request.headers[\"X_COLLECTION_TIME\"] || params[:time]\n @time = @time.numeric? ? Time.at(@time.to_i).to_datetime.utc : DateTime.parse(@time) if @time\n @offset = request.headers[\"X_COLLECTION_OFFSET\"].try(:to_i) || params[:offset].try(:to_i)\n @limit = request.headers[\"X_COLLECTION_LIMIT\"].try(:to_i) || params[:limit].try(:to_i)\n end", "def collection\n persistence_context.collection\n end", "def collection\n self.class.collection_builder_strategy.collection(self)\n end", "def collection_hash\n collection_field_pairs = collection_fields.map do |field|\n [ normalize_header(field.header), field.value ]\n end\n Hash[ collection_field_pairs ]\n end", "def lifecycle_event_configuration\n data.lifecycle_event_configuration\n end", "def collection\n get_collection_ivar || begin\n collection = find_collection\n authorize! Authorization::READ, active_admin_config.resource_class\n set_collection_ivar collection\n end\n end", "def collection\n\n get_collection_ivar || begin\n\n collection = find_collection\n\n authorize! Authorization::READ, active_admin_config.resource_class\n\n set_collection_ivar collection\n\n end\n\n end", "def get_collection_id\n @coll_id\n end", "def embed_collecting_event\n return unless collection.embedded_collecting_event?\n CollectingEvent.create discipline: collection.discipline\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns whether this Collectible has a received event.
def received? received_event_parameters end
[ "def has_event?\n return !@events.empty?\n end", "def event?\n @events_mutex.synchronize do\n !@events.empty?\n end\n end", "def raises_event?\n !!collected[:event_name]\n end", "def has_pending_events?\n self.events.any?{|e| e.pending? }\n end", "def ready?\n running? && @event_received\n end", "def event_was_sent?( type )\n\t\treturn !self.find_events( type ).empty?\n\tend", "def embedded_collecting_event?\n self[:IsEmbeddedCollectingEvent]\n end", "def receiving?\n Cproton.pn_messenger_receiving(@impl)\n end", "def receive?\n type == 'receive'\n end", "def evented?\n actor = Thread.current[:celluloid_actor]\n actor && actor.mailbox.is_a?(Celluloid::IO::Mailbox)\n end", "def processed?\n !processed_events(event_id: id).empty?\n end", "def has_event_handler?\n !!collected[:event_handler]\n end", "def has_queued_events?\n !@propagation.empty?\n end", "def delivered?\n return true unless self.delivered\n end", "def subscribed?(event)\n\t\tsubscribed_events.include?(event)\n\tend", "def has_ui_event?\n !ui_event_queue.empty?\n end", "def has_event?(name)\n return self.events(true).include? name.to_sym\n end", "def attending?(event)\n\t\tattended_events.accepted.include?(event)\n\tend", "def hasEvent?( id )\n\t\t\t\tKesh::ArgTest::type( \"id\", id, Symbol )\n\t\t\t\t\n\t\t\t\texists = false\n\t\t\t\t\n\t\t\t\t@mutex.synchronize {\n\t\t\t\t\texists = ( @events[ id ] != nil )\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn exists\n\t\t\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the ReceivedEventParameters for this Collectible.
def received_event_parameters event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep } end
[ "def parameters\n params = []\n self.event_parameters.each do |param|\n params << OpenStruct.new( :param_id => param.id, :name => param.Description, :param_type => param.parameter_type.Description )\n end\n params\n end", "def collection_event_parameters\n event_parameters.detect { |ep| CaTissue::CollectionEventParameters === ep }\n end", "def received?\n received_event_parameters\n end", "def block_args\n collected[:block_args]\n end", "def lifecycle_event_configuration\n data[:lifecycle_event_configuration]\n end", "def lifecycle_event_configuration\n data.lifecycle_event_configuration\n end", "def parameters\n elements.select { |e| e.parameter?}\n end", "def events\n @events ||= Array(context[:events]).reverse.map { |event| Concierge::SafeAccessHash.new(event) }\n end", "def event_propagation_results\n return @event_propagation_results\n end", "def attributes\n @requested_attributes.values\n end", "def chargable_params\n chargable_events = Event.where(resource_id: @resource.id, started_at: billing_period.first..billing_period.last).where.not(name: :create)\n .or(Event.where(resource_id: @resource.id, finished_at: billing_period.first..billing_period.last).create_name)\n .order(name: :desc, started_at: :desc)\n\n # TODO: refactor\n unless @event.create_name? || chargable_events&.last&.create_name? # don't look for previous events in case of create\n if chargable_events.blank? || (chargable_events && chargable_events.last.started_at > billing_period.first) # started_at cause last event name is not \"create\"\n last_event = @resource.last_event_before(billing_period.first)\n chargable_events += [last_event] if last_event\n end\n end\n\n chargable_events.map(&:resource_parameters)\n end", "def attributes\n message.attributes\n end", "def arguments\n return @arguments\n end", "def get_event_keys\r\n @events.keys\r\n end", "def added_events\n return @added_events\n end", "def extract_event\n if params[:event].class == ActiveSupport::HashWithIndifferentAccess\n params[:event]\n else\n _rc = {}\n JSON.parse(params[:event].to_s).each do |key, value|\n _rc[key.to_sym] = value\n end\n _rc\n end\n end", "def parameters\n @params.extra_parameters\n end", "def events\n return @events\n end", "def updated_params\n updated_params = event_params\n if updated_params[\"duration\"]\n updated_params[\"duration\"] = duration_in_minutes(updated_params[\"duration\"])\n updated_params\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Overrides +Jinx::Resource.each_defaultable_reference+ to visit the +CaTissue::ReceivedEventParameters+.
def each_defaultable_reference # visit ReceivedEventParameters first rep = received_event_parameters yield rep if rep # add other dependent defaults super { |dep| yield dep unless ReceivedEventParameters === dep } end
[ "def add_default_event_parameters\n rep = received_event_parameters || create_default_received_event_parameters || return\n if collection_event_parameters.nil? then\n create_default_collection_event_parameters(rep)\n end\n end", "def add_defaults_local\n super\n self.collection_event ||= parent.collection_event if parent\n self.specimen_characteristics ||= CaTissue::SpecimenCharacteristics.new\n end", "def set_default_properties\n DEFAULT_INBOUND_PORTS.each do |port|\n add_inbound_access(:from => port)\n end\n super\n end", "def set_defaults\n super\n self.asset_event_type ||= AssetEventType.find_by_class_name(self.name)\n prev_ops_update = self.previous_event_of_type\n if prev_ops_update\n self.annual_affected_ridership ||= prev_ops_update.annual_affected_ridership\n self.annual_dollars_generated ||= prev_ops_update.annual_dollars_generated\n end\n end", "def received_event_parameters\n event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep }\n end", "def handle_event_attrs\n @event.resource = @resource\n event_class = [@resource.kind, 'Event'].join('').constantize\n @event = @event.becomes!(event_class) # typecast event for proper validation\n stored_attrs = event_class.stored_attributes[:resource_parameters]\n stored_attrs.each { |key| @event.public_send(key.to_s + '=', @params[key]) } if stored_attrs\n end", "def mail_defaults(event)\n {\n to: to(event),\n base_url: \"https://#{domain(event)}\",\n dealership: dealership(event),\n support_email: Lynr.config('app').support_email,\n }\n end", "def default_events(*events)\n if events.empty?\n @default_events ||= [:push]\n else\n @default_events = events.flatten\n end\n end", "def create_default_collection_event_parameters(rep)\n cep = parent.collection_event_parameters if parent\n user = cep.user if cep\n user ||= scg_collector || rep.user || return\n cep = CaTissue::CollectionEventParameters.new(:specimen => self, :user => user)\n logger.debug { \"Created default #{qp} collection event #{cep.qp}.\" }\n cep\n end", "def add_defaults_local\n super\n # Make a new default Race which references this Participant, if necessary. Setting the Race\n # participant to self automatically adds the Race to this Participant's races collection.\n # The Race name defaults to Unknown.\n if races.empty? then CaTissue::Race.new(:participant => self).add_defaults_recursive end\n end", "def get_default_properties(event)\n client = event['client']\n check = event['check']\n {\n server_name: client['name'],\n server_ip: client['address'],\n subscriptions: client['subscriptions'].join(';'),\n environment: client['environment'],\n check_name: check['name'],\n check_command: check['command'],\n check_output: check['output'],\n timestamp: event['timestamp'].inspect\n }\n end", "def set_notifiable_class_defaults\n self._notification_targets = {}\n self._notification_group = {}\n self._notification_group_expiry_delay = {}\n self._notifier = {}\n self._notification_parameters = {}\n self._notification_email_allowed = {}\n self._notifiable_action_cable_allowed = {}\n self._notifiable_action_cable_api_allowed = {}\n self._notifiable_path = {}\n self._printable_notifiable_name = {}\n self._optional_targets = {}\n nil\n end", "def defaulted_parameters\n parameters.keep_if { |k,v| v.has_key?(:Default) }\n end", "def set_default_values\n certainty_default = Certainty.default\n certainty_fields.each do |field_name|\n self.send(\"#{field_name}=\", certainty_default) if self.send(\"#{field_name}\").nil?\n end\n end", "def default_receiver\n cep = collection_event_parameters\n cltr = cep.user if cep\n return cltr if cltr\n cp = collection_protocol || return\n rcv = cp.coordinators.first\n return rcv if rcv or cp.fetched?\n # Try to fetch the CP coordinator \n return cp.coordinators.first if cp.find\n # CP does not exist; add the CP defaults and retry\n cp.add_defaults\n cp.coordinators.first\n end", "def before_notify_callbacks\n Bugsnag.configuration.request_data[:before_callbacks] ||= []\n end", "def wrapped_association_defaults\n @wrapped_association_defaults ||= {}\n end", "def create_default_events\n EventType::DEFAULT_EVENTS.each_value do |e|\n event = self.event_types.find_by_name(e[:name])\n unless event\n self.event_types.create(e) do |et|\n et.editable = e[:editable] if e.has_key?(:editable)\n end\n end\n end\n end", "def assign_arguments_default_values!\n @non_assigned_arguments.each do |option|\n @arguments << option.default\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
methods copied from openstudiostandards Remove all air loops in model
def remove_air_loops(model) model.getAirLoopHVACs.each(&:remove) return model end
[ "def remove_all_plant_loops(model)\n model.getPlantLoops.each(&:remove)\n return model\n end", "def remove_plant_loops(model, runner)\n plant_loops = model.getPlantLoops\n plant_loops.each do |plant_loop|\n shw_use = false\n plant_loop.demandComponents.each do |component|\n if component.to_WaterUseConnections.is_initialized or component.to_CoilWaterHeatingDesuperheater.is_initialized\n shw_use = true\n runner.registerInfo(\"#{plant_loop.name} is used for SHW or refrigeration heat reclaim and will not be removed.\")\n break\n end\n end\n plant_loop.remove unless shw_use\n end\n return model\n end", "def remove_all_HVAC(model)\n remove_air_loops(model)\n remove_all_plant_loops(model)\n remove_vrf(model)\n remove_all_zone_equipment(model, runner)\n remove_unused_curves(model)\n return model\n end", "def create_new_air_loop\n loop = OpenStudio::Model::AirLoopHVAC.new(@model)\n loop.setName(\"Chilled Beam DOAS\")\n # modify system sizing properties\n sizing_system = loop.sizingSystem\n \n #These next two paramters configure the airloop to operate as a 100% Outside Air Unit\n sizing_system.setTypeofLoadtoSizeOn(\"VentilationRequirement\")\n sizing_system.setMinimumSystemAirFlowRatio(1.0) \t\t\n sizing_system.setCentralCoolingDesignSupplyAirTemperature(OpenStudio::convert(65, \"F\", \"C\").get)\n sizing_system.setAllOutdoorAirinCooling(true)\n sizing_system.setAllOutdoorAirinHeating(true)\n sizing_system.setCentralCoolingDesignSupplyAirHumidityRatio(0.004)\n sizing_system.setSystemOutdoorAirMethod(\"VentilationRateProcedure\")\n \n \n # Add an outdoor air system to the loop\n outdoor_air_control = OpenStudio::Model::ControllerOutdoorAir.new(@model)\n outdoor_air_control.setName(\"100% OA Outdoor Air Controller - No Economizer\")\n outdoor_air_control.setEconomizerControlType(\"NoEconomizer\")\n outdoor_air_control.autosizeMinimumOutdoorAirFlowRate() # This will set to AutoSize\n outdoor_air_control.autosizeMaximumOutdoorAirFlowRate() # This will set to AutoSize\n outdoor_air_control.setMinimumFractionofOutdoorAirSchedule(@model.alwaysOnDiscreteSchedule())\n outdoor_air_control.setMaximumFractionofOutdoorAirSchedule(@model.alwaysOnDiscreteSchedule())\n \n # create outdoor air system\n system_OA = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(@model, outdoor_air_control)\n system_OA.setName(\"DOAS Outdoor Air Management System\")\n system_OA.addToNode(loop.supplyInletNode)\n\n # Create an Air<->Air heat exchanger\n # Note that these settings for this rotary energy exchange device are reasonable but do not represent performance of a \n # specific product and should be customized to reprsent specific modeling scenarios. \n \n heat_exchanger = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(@model)\n heat_exchanger.setName(\"Aluminum Film Substrate Passive Dehumidification Wheel\")\n heat_exchanger.setSensibleEffectivenessat100HeatingAirFlow(0.76) \n heat_exchanger.setLatentEffectivenessat100HeatingAirFlow(0.68)\n heat_exchanger.setSensibleEffectivenessat100CoolingAirFlow(0.76)\n heat_exchanger.setLatentEffectivenessat100CoolingAirFlow(0.68)\n heat_exchanger.setNominalElectricPower(250)\n heat_exchanger.setHeatExchangerType(\"Rotary\")\n heat_exchanger.setFrostControlType(\"None\")\n heat_exchanger.addToNode(system_OA.outboardOANode.get)\n\n\n # Create a setpoint manager for the heat exchanger\n # This setpoint manager will attempt deliver 68F Air to the inlet of active chilled beam terminal units. \n exchanger_setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(@model, make_constant_schedule(\"Passive Dehumidication Wheel LAT 68F Schedule\", 68))\n exchanger_setpoint_manager.setName(\"Passive Dehumidification Wheel (Free reheat) Setpoint Manager\")\n exchanger_setpoint_manager.addToNode(system_OA.outdoorAirModelObject.get.to_Node.get)\n\t\n\t# Create a cooling water coil\n\t# The purpose of this coil is to deeply cool the air to wring the maximum amount of moisture from the OA airstream\n\t# In many cases, this will overcool the 100% OA airstream, requiring either parasitic reheat or free reheat from a \n\t# downstream sensible recovery wheel. \n\tdehumidification_coil = OpenStudio::Model::CoilCoolingWater.new(@model, @model.alwaysOnDiscreteSchedule())\n\tdehumidification_coil.setName(\"Multirow Deep Dehumidification Coil\")\n\tdehumidification_coil.setHeatExchangerConfiguration(\"Crossflow\")\n\tdehumidification_coil.addToNode(system_OA.outboardOANode.get)\n\t\n\t# Create a setpoint manager for the cooling/dehumidification coil\n\t# The setpoint manager for this coil will operate to attempt to drive the coil temp to the specificed chilled beam\n\t# entering water temperature (user argument), since this temperature will likely set the temperature of most \n\t# efficienct chilled water generation (without requiring mixing to serve the chilled beams a lower entering \n\t# chilled water temperature.)\n\t\n dehumid_coil_setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(@model, make_constant_schedule(\"Dehumidication Coil Schedule\", @design_inlet_water_temperature))\n dehumid_coil_setpoint_manager.setName(\"Setpoint Manager for Controlling Deep Dehumidification Coil Leaving Air Temp\")\n dehumid_coil_setpoint_manager.addToNode(dehumidification_coil.airOutletModelObject.get.to_Node.get)\n\t\n # Create a second Air to Air Energy Exchange device representing a total energy wheel\n # Note that settings for this rotary energy exchange device are reasonable but do not represent performance of a \n # specific product and should be customized to reprsent specific modeling scenarios. \n # Frost control strategies (used for heating only) may need to be modified based on specific design winter conditions\n heat_exchanger2 = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(@model)\n heat_exchanger2.setName(\"Enthalpy Recovery Wheel\")\n heat_exchanger2.setSensibleEffectivenessat100HeatingAirFlow(0.76)\n heat_exchanger2.setLatentEffectivenessat100HeatingAirFlow(0.68)\n heat_exchanger2.setSensibleEffectivenessat100CoolingAirFlow(0.76)\n heat_exchanger2.setLatentEffectivenessat100CoolingAirFlow(0.68)\n heat_exchanger2.setHeatExchangerType(\"Rotary\")\n heat_exchanger2.setNominalElectricPower(250)\n heat_exchanger2.setFrostControlType(\"MinimumExhaustTemperature\")\n heat_exchanger2.setThresholdTemperature(1.7)\n heat_exchanger2.addToNode(system_OA.outboardOANode.get)\n\n # Create a setpoint manager for the heat exchanger\n # This setpoint manager will attempt deliver 65F Air to the inlet of the downstream deep dehumidification coil. \n exchanger2_setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(@model, make_constant_schedule(\"Enthalpy Wheel Leaving Air Temp Schedule\", 65))\n exchanger2_setpoint_manager.setName(\"Enthalpy Wheel Leaving Supply Air Temperature Controller\")\n exchanger2_setpoint_manager.addToNode(heat_exchanger2.primaryAirOutletModelObject.get.to_Node.get)\n\n # Create a variable volume SUPPLY fan - configured for constant volume\n supply_fan = OpenStudio::Model::FanVariableVolume.new(@model, @model.alwaysOnDiscreteSchedule())\n supply_fan.setName(\"Chilled Beam DOAS Supply Fan\")\n inchesH2OtoPa = 1.0/0.00401463\n supply_fan.setPressureRise(@new_airloop_fan_pressure_rise / 2 * inchesH2OtoPa)\n supply_fan.autosizeMaximumFlowRate()\n supply_fan.setFanPowerMinimumFlowFraction(1.0)\n supply_fan.setFanPowerMinimumFlowRateInputMethod(\"Fraction\")\n supply_fan.addToNode(loop.supplyOutletNode)\n \n # Create a variable volume EXHAUST fan - configured for constant flow\n exhaust_fan = OpenStudio::Model::FanVariableVolume.new(@model, @model.alwaysOnDiscreteSchedule())\n exhaust_fan.setName(\"Chilled Beam DOAS Exhaust Fan\")\n exhaust_fan.setPressureRise(@new_airloop_fan_pressure_rise / 2 * inchesH2OtoPa)\n exhaust_fan.autosizeMaximumFlowRate()\n exhaust_fan.setFanPowerMinimumFlowFraction(1.0)\n exhaust_fan.setFanPowerMinimumFlowRateInputMethod(\"Fraction\")\n exhaust_fan.addToNode(system_OA.outboardReliefNode.get)\n \n # make a constant 65F schedule and assign it to a setpoint manager for this loop\n loop_setpoint = OpenStudio::Model::SetpointManagerScheduled.new(@model, make_constant_schedule(\"Chilled Beam Air Loop Outlet Schedule\", 65))\n loop_setpoint.setName(\"Constant 65 Degree Air Temp\")\n loop_setpoint.addToNode(loop.supplyOutletNode)\n \n return loop, dehumidification_coil\n end", "def cleanUpRogueNps\n\n removeNps = []\n @npModels.each do |acceptableNp|\n idx = 0\n \n @npModels.each do |otherNp|\n if otherNp.included == false && otherNp.id != acceptableNp.id && otherNp.startIdx == acceptableNp.startIdx && otherNp.endIdx <= acceptableNp.endIdx\n removeNps.push otherNp\n end\n idx = idx + 1\n end\n end\n \n while removeNps.length > 0\n removeNp = removeNps[0]\n \n removeIdx = 0\n @npModels.each do |np|\n if np.id == removeNp.id\n break\n end\n removeIdx = removeIdx + 1\n end\n \n @npModels.slice!(removeIdx)\n \n removeNps.slice!(0)\n end\n end", "def remove_all_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def remove_non_resource_objects(runner, model, options = nil)\n if options.nil?\n options = {}\n options[:remove_building_stories] = true\n options[:remove_thermostats] = true\n options[:remove_air_loops] = true\n options[:remove_non_swh_plant_loops] = true\n\n # leave these in by default unless requsted when method called\n options[:remove_swh_plant_loops] = false\n options[:remove_exterior_lights] = false\n options[:remove_site_shading] = false\n end\n\n num_model_objects = model.objects.size\n\n # remove non-resource objects not removed by removing the building\n if options[:remove_building_stories] then model.getBuildingStorys.each(&:remove) end\n if options[:remove_thermostats] then model.getThermostats.each(&:remove) end\n if options[:remove_air_loops] then model.getAirLoopHVACs.each(&:remove) end\n if options[:remove_exterior_lights] then model.getFacility.exteriorLights.each(&:remove) end\n if options[:remove_site_shading] then model.getSite.shadingSurfaceGroups.each(&:remove) end\n\n # see if plant loop is swh or not and take proper action (booter loop doesn't have water use equipment)\n model.getPlantLoops.each do |plant_loop|\n is_swh_loop = false\n plant_loop.supplyComponents.each do |component|\n if component.to_WaterHeaterMixed.is_initialized\n is_swh_loop = true\n next\n end\n end\n\n if is_swh_loop\n if options[:remove_swh_plant_loops] then plant_loop.remove end\n else\n if options[:remove_non_swh_plant_loops] then plant_loop.remove end\n end\n end\n\n # remove water use connections (may be removed when loop is removed)\n if options[:remove_swh_plant_loops] then model.getWaterConnectionss.each(&:remove) end\n if options[:remove_swh_plant_loops] then model.getWaterUseEquipments.each(&:remove) end\n\n # remove building but reset fields on new building object.\n building_fields = []\n building = model.getBuilding\n num_fields = building.numFields\n num_fields.times.each do |i|\n building_fields << building.getString(i).get\n end\n # removes spaces, space's child objects, thermal zones, zone equipment, non site surfaces, building stories and water use connections.\n model.getBuilding.remove\n building = model.getBuilding\n num_fields.times.each do |i|\n next if i == 0 # don't try and set handle\n building_fields << building.setString(i, building_fields[i])\n end\n\n # other than optionally site shading and exterior lights not messing with site characteristics\n\n if num_model_objects - model.objects.size > 0\n runner.registerInfo(\"Removed #{num_model_objects - model.objects.size} non resource objects from the model.\")\n end\n\n return true\n end", "def remove_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n if equipment.to_FanZoneExhaust.is_initialized\n runner.registerInfo(\"#{equipment.name} is a zone exhaust fan and will not be removed.\")\n else\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def delete_all_attributes\n model = Sketchup.active_model\n model.definitions.each { |definition|\n delete_attributes(definition.instances)\n }\n model.attribute_dictionaries.delete('MSPhysics')\n model.attribute_dictionaries.delete('MSPhysics Sounds')\n model.attribute_dictionaries.delete('MSPhysics Replay')\n end", "def remove_all_bart_route_stations\n\t\t@stations = Bartroutestation.all\n\t\t@stations.each do |station|\n\t\t\tstation.destroy\n\t\tend\n\tend", "def remove_unused_curves(model)\n model.getCurves.each do |curve|\n if curve.directUseCount == 0\n model.removeObject(curve.handle)\n end\n end\n return model\n end", "def remove_all_of controllable\n @controls.reject! { |control| control.controllable == controllable }\n end", "def delete_assets!\n SsObject.in_solar_system(self).delete_all\n Wreckage.in_zone(self).delete_all\n Unit.in_zone(self).delete_all\n end", "def delete_all_attributes\n model = Sketchup.active_model\n model.definitions.each { |d|\n delete_attributes(d.instances)\n }\n dicts = model.attribute_dictionaries\n if dicts\n dicts.delete('MSPhysics')\n dicts.delete('MSPhysics Sounds')\n dicts.delete('MSPhysics Replay')\n end\n end", "def postStop\n @models.each { |m| m.stop }\n end", "def delete\n if @circuit\n @circuit.remove_all_updates self\n @circuit.remove_component self\n end\n input_count.times do |i|\n disconnect_input(i)\n end\n output_count.times do |i|\n disconnect_outputs(i)\n end\n @circuit = nil\n end", "def remove\n inputs.edges.dup.each(&:remove)\n outputs.edges.dup.each(&:remove)\n end", "def remove_tower\n end", "def stop()\n [wrist, elbow, shoulder, base, grip].each do |motor| \n motor.stop if motor.moving?\n end\n led.off if led.on? \n nil\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove plant loops in model except those used for service hot water
def remove_plant_loops(model, runner) plant_loops = model.getPlantLoops plant_loops.each do |plant_loop| shw_use = false plant_loop.demandComponents.each do |component| if component.to_WaterUseConnections.is_initialized or component.to_CoilWaterHeatingDesuperheater.is_initialized shw_use = true runner.registerInfo("#{plant_loop.name} is used for SHW or refrigeration heat reclaim and will not be removed.") break end end plant_loop.remove unless shw_use end return model end
[ "def remove_all_plant_loops(model)\n model.getPlantLoops.each(&:remove)\n return model\n end", "def remove_all_HVAC(model)\n remove_air_loops(model)\n remove_all_plant_loops(model)\n remove_vrf(model)\n remove_all_zone_equipment(model, runner)\n remove_unused_curves(model)\n return model\n end", "def remove_air_loops(model)\n model.getAirLoopHVACs.each(&:remove)\n return model\n end", "def removeStress\n @syllables.each do |syllable|\n syllable.stress = StressType::NONE\n end\n end", "def prune_strategy; end", "def discard_bad_plates\n show do \n title \"Discard Plates\"\n \n discard_plate_ids = operations.select { |op| op.temporary[:delete] }.map { |op| op.input(\"Plate\").item.id }\n note \"Discard the following plates with 0 colonies: #{discard_plate_ids}\"\n end\n end", "def cleanUpRogueNps\n\n removeNps = []\n @npModels.each do |acceptableNp|\n idx = 0\n \n @npModels.each do |otherNp|\n if otherNp.included == false && otherNp.id != acceptableNp.id && otherNp.startIdx == acceptableNp.startIdx && otherNp.endIdx <= acceptableNp.endIdx\n removeNps.push otherNp\n end\n idx = idx + 1\n end\n end\n \n while removeNps.length > 0\n removeNp = removeNps[0]\n \n removeIdx = 0\n @npModels.each do |np|\n if np.id == removeNp.id\n break\n end\n removeIdx = removeIdx + 1\n end\n \n @npModels.slice!(removeIdx)\n \n removeNps.slice!(0)\n end\n end", "def remove_non_resource_objects(runner, model, options = nil)\n if options.nil?\n options = {}\n options[:remove_building_stories] = true\n options[:remove_thermostats] = true\n options[:remove_air_loops] = true\n options[:remove_non_swh_plant_loops] = true\n\n # leave these in by default unless requsted when method called\n options[:remove_swh_plant_loops] = false\n options[:remove_exterior_lights] = false\n options[:remove_site_shading] = false\n end\n\n num_model_objects = model.objects.size\n\n # remove non-resource objects not removed by removing the building\n if options[:remove_building_stories] then model.getBuildingStorys.each(&:remove) end\n if options[:remove_thermostats] then model.getThermostats.each(&:remove) end\n if options[:remove_air_loops] then model.getAirLoopHVACs.each(&:remove) end\n if options[:remove_exterior_lights] then model.getFacility.exteriorLights.each(&:remove) end\n if options[:remove_site_shading] then model.getSite.shadingSurfaceGroups.each(&:remove) end\n\n # see if plant loop is swh or not and take proper action (booter loop doesn't have water use equipment)\n model.getPlantLoops.each do |plant_loop|\n is_swh_loop = false\n plant_loop.supplyComponents.each do |component|\n if component.to_WaterHeaterMixed.is_initialized\n is_swh_loop = true\n next\n end\n end\n\n if is_swh_loop\n if options[:remove_swh_plant_loops] then plant_loop.remove end\n else\n if options[:remove_non_swh_plant_loops] then plant_loop.remove end\n end\n end\n\n # remove water use connections (may be removed when loop is removed)\n if options[:remove_swh_plant_loops] then model.getWaterConnectionss.each(&:remove) end\n if options[:remove_swh_plant_loops] then model.getWaterUseEquipments.each(&:remove) end\n\n # remove building but reset fields on new building object.\n building_fields = []\n building = model.getBuilding\n num_fields = building.numFields\n num_fields.times.each do |i|\n building_fields << building.getString(i).get\n end\n # removes spaces, space's child objects, thermal zones, zone equipment, non site surfaces, building stories and water use connections.\n model.getBuilding.remove\n building = model.getBuilding\n num_fields.times.each do |i|\n next if i == 0 # don't try and set handle\n building_fields << building.setString(i, building_fields[i])\n end\n\n # other than optionally site shading and exterior lights not messing with site characteristics\n\n if num_model_objects - model.objects.size > 0\n runner.registerInfo(\"Removed #{num_model_objects - model.objects.size} non resource objects from the model.\")\n end\n\n return true\n end", "def mark_as_dry\n @water_mode = nil\n end", "def remove_all_dismantle_masks\n groups = [$data_items, $data_armors, $data_weapons]\n for group in groups\n for obj in group\n next if obj.nil?\n obj.set_dismantle_mask_flags(true)\n end # for\n end # for\n end", "def prune_basic_blocks(blocks); end", "def unsolved_puzzles\n ids = []\n self.solved_puzzles.each do |solved|\n ids << solved.puzzle_id\n end\n Puzzle.where.not(id: ids)\n end", "def remove_all_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def remove_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n if equipment.to_FanZoneExhaust.is_initialized\n runner.registerInfo(\"#{equipment.name} is a zone exhaust fan and will not be removed.\")\n else\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def prune!\n # Take care of dangling neurons\n neunames = @genes.values.map{|g| [g.in_neuron, g.out_neuron]}.flatten.to_set\n @neurons = Hash[@neurons.values.reject do |n|\n not neunames.member? n.name\n end.map do |n|\n [n.name, n]\n end]\n\n # Take care of dangling genes\n @genes = Hash[@genes.values.reject do |gene|\n not (@neurons.member?(gene.in_neuron) and @neurons.member?(gene.out_neuron))\n end.map do |gene|\n [gene.name, gene]\n end]\n\n # Make sure @neural_inputs and @neural_outputs are consistent\n @neural_inputs = Hash[@neural_inputs.values.map{|n| [n.name, @neurons[n.name]]}]\n @neural_outputs = Hash[@neural_outputs.values.map{|n| [n.name, @neurons[n.name]]}]\n end", "def remove_all_of controllable\n @controls.reject! { |control| control.controllable == controllable }\n end", "def prune_pool; end", "def remove_tower\n end", "def remove_pants\n @pants = false\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove all plant loops in model including those used for service hot water
def remove_all_plant_loops(model) model.getPlantLoops.each(&:remove) return model end
[ "def remove_plant_loops(model, runner)\n plant_loops = model.getPlantLoops\n plant_loops.each do |plant_loop|\n shw_use = false\n plant_loop.demandComponents.each do |component|\n if component.to_WaterUseConnections.is_initialized or component.to_CoilWaterHeatingDesuperheater.is_initialized\n shw_use = true\n runner.registerInfo(\"#{plant_loop.name} is used for SHW or refrigeration heat reclaim and will not be removed.\")\n break\n end\n end\n plant_loop.remove unless shw_use\n end\n return model\n end", "def remove_all_HVAC(model)\n remove_air_loops(model)\n remove_all_plant_loops(model)\n remove_vrf(model)\n remove_all_zone_equipment(model, runner)\n remove_unused_curves(model)\n return model\n end", "def remove_air_loops(model)\n model.getAirLoopHVACs.each(&:remove)\n return model\n end", "def remove_all_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def remove_all_bart_route_stations\n\t\t@stations = Bartroutestation.all\n\t\t@stations.each do |station|\n\t\t\tstation.destroy\n\t\tend\n\tend", "def remove_non_resource_objects(runner, model, options = nil)\n if options.nil?\n options = {}\n options[:remove_building_stories] = true\n options[:remove_thermostats] = true\n options[:remove_air_loops] = true\n options[:remove_non_swh_plant_loops] = true\n\n # leave these in by default unless requsted when method called\n options[:remove_swh_plant_loops] = false\n options[:remove_exterior_lights] = false\n options[:remove_site_shading] = false\n end\n\n num_model_objects = model.objects.size\n\n # remove non-resource objects not removed by removing the building\n if options[:remove_building_stories] then model.getBuildingStorys.each(&:remove) end\n if options[:remove_thermostats] then model.getThermostats.each(&:remove) end\n if options[:remove_air_loops] then model.getAirLoopHVACs.each(&:remove) end\n if options[:remove_exterior_lights] then model.getFacility.exteriorLights.each(&:remove) end\n if options[:remove_site_shading] then model.getSite.shadingSurfaceGroups.each(&:remove) end\n\n # see if plant loop is swh or not and take proper action (booter loop doesn't have water use equipment)\n model.getPlantLoops.each do |plant_loop|\n is_swh_loop = false\n plant_loop.supplyComponents.each do |component|\n if component.to_WaterHeaterMixed.is_initialized\n is_swh_loop = true\n next\n end\n end\n\n if is_swh_loop\n if options[:remove_swh_plant_loops] then plant_loop.remove end\n else\n if options[:remove_non_swh_plant_loops] then plant_loop.remove end\n end\n end\n\n # remove water use connections (may be removed when loop is removed)\n if options[:remove_swh_plant_loops] then model.getWaterConnectionss.each(&:remove) end\n if options[:remove_swh_plant_loops] then model.getWaterUseEquipments.each(&:remove) end\n\n # remove building but reset fields on new building object.\n building_fields = []\n building = model.getBuilding\n num_fields = building.numFields\n num_fields.times.each do |i|\n building_fields << building.getString(i).get\n end\n # removes spaces, space's child objects, thermal zones, zone equipment, non site surfaces, building stories and water use connections.\n model.getBuilding.remove\n building = model.getBuilding\n num_fields.times.each do |i|\n next if i == 0 # don't try and set handle\n building_fields << building.setString(i, building_fields[i])\n end\n\n # other than optionally site shading and exterior lights not messing with site characteristics\n\n if num_model_objects - model.objects.size > 0\n runner.registerInfo(\"Removed #{num_model_objects - model.objects.size} non resource objects from the model.\")\n end\n\n return true\n end", "def cleanUpRogueNps\n\n removeNps = []\n @npModels.each do |acceptableNp|\n idx = 0\n \n @npModels.each do |otherNp|\n if otherNp.included == false && otherNp.id != acceptableNp.id && otherNp.startIdx == acceptableNp.startIdx && otherNp.endIdx <= acceptableNp.endIdx\n removeNps.push otherNp\n end\n idx = idx + 1\n end\n end\n \n while removeNps.length > 0\n removeNp = removeNps[0]\n \n removeIdx = 0\n @npModels.each do |np|\n if np.id == removeNp.id\n break\n end\n removeIdx = removeIdx + 1\n end\n \n @npModels.slice!(removeIdx)\n \n removeNps.slice!(0)\n end\n end", "def unsolved_puzzles\n ids = []\n self.solved_puzzles.each do |solved|\n ids << solved.puzzle_id\n end\n Puzzle.where.not(id: ids)\n end", "def hard_reset\n washers.each { |w| w.hard_reset } if washers\n washers.clear\n dryers.each { |d| d.hard_reset } if dryers\n dryers.clear\n loads.each { |l| l.hard_reset } if loads\n end", "def clean\n planned_trips.each do |pt| \n pt.itineraries.each { |x| x.destroy }\n end\n planned_trips.each { |x| x.destroy }\n trip_places.each { |x| x.destroy}\n save\n end", "def remove_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n if equipment.to_FanZoneExhaust.is_initialized\n runner.registerInfo(\"#{equipment.name} is a zone exhaust fan and will not be removed.\")\n else\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def remove_all_of controllable\n @controls.reject! { |control| control.controllable == controllable }\n end", "def clear\n @triples.clear()\n end", "def remove_all_dismantle_masks\n groups = [$data_items, $data_armors, $data_weapons]\n for group in groups\n for obj in group\n next if obj.nil?\n obj.set_dismantle_mask_flags(true)\n end # for\n end # for\n end", "def clear_world\n @all_persons.clear\n @all_monsters.clear\n @all_strawberries.clear\n @all_mushrooms.clear\n\n @iteration = 0\n end", "def prune_pool; end", "def updateLayers()\n layers.each do |layer|\n layer.destroy\n end\n #tilesets.each do |tileset|\n # tilesets.delete(tileset)\n #end\n createLayers()\n end", "def clean\n remove_itineraries\n trip_parts.each { |x| x.destroy }\n trip_places.each { |x| x.destroy}\n save\n end", "def removeStress\n @syllables.each do |syllable|\n syllable.stress = StressType::NONE\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove zone equipment except for exhaust fans
def remove_zone_equipment(model, runner) zone_equipment_removed_count = 0 model.getThermalZones.each do |zone| zone.equipment.each do |equipment| if equipment.to_FanZoneExhaust.is_initialized runner.registerInfo("#{equipment.name} is a zone exhaust fan and will not be removed.") else equipment.remove zone_equipment_removed_count += 1 end end end runner.registerInfo("#{zone_equipment_removed_count} zone equipment removed.") return model end
[ "def remove_all_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def clean_air_zones_data\n ComplianceCheckerApi.clean_air_zones\n end", "def excluded_from_zone(restrict_to_zone)\n excluded = []\n self.zones.each_pair do |shortname, seats|\n excluded += seats unless shortname == restrict_to_zone\n end\n excluded.sort\n end", "def clean_air_zone\n CleanAirZone.find(session_details[:caz_id])\n end", "def zone_purge(zone)\n obj_purge(zone,Zone)\n end", "def remove_disallowed_items!\n for equipment in equipments\n remove!(equipment) unless allows?(equipment, true)\n end\n end", "def remove_tower\n end", "def unnecessary_fare_zones\n fare_zones.where.not(code: zone_codes)\n end", "def dropDemandFromOnBoard(demand)\n @onBoardList.delete(demand) ;\n end", "def remove_to_the_fleet(a_ship)\n ships.reject! { |ship| ship == a_ship }\n end", "def remove \n # Remove all of its subzones\n zones.each{|z| z.remove }\n \n parent = self.get_parent\n parent[N::TALIA.hasSubZone].remove(self)\n\n self.destroy\n parent.save\n end", "def evict_tenant(apts)\n print \"Evict whom? \"\n to_evict = gets.chomp\n apts.each { |a| a.remove(to_evict) if a != nil }\nend", "def delete_all_administrative_ips\n super\n end", "def check_for_nation_elimination!\r\n @nations.each do |nation|\r\n if nation.units.empty?\r\n nation.elimination = :no_more_units\r\n @nations.delete nation\r\n $log.debug \"Nation #{nation.name} was wiped out!\"\r\n end\r\n end\r\n end", "def eliminate contestant\n @members.delete contestant\n end", "def remove_to_the_fleet(a_ship)\n \tships.reject! { |ship| ship == a_ship }\n end", "def remove_ips(zone_name, ips)\n data = {}\n data[\"zone\"] = zone_name\n data[\"ips\"] = ips\n request(:delete, \"/api/zone/ips\", Oj.dump(data, mode: :compat))\n end", "def delete_all_zones\n super\n end", "def prune_universe(items)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove all zone equipment including exhaust fans
def remove_all_zone_equipment(model, runner) zone_equipment_removed_count = 0 model.getThermalZones.each do |zone| zone.equipment.each do |equipment| equipment.remove zone_equipment_removed_count += 1 end end runner.registerInfo("#{zone_equipment_removed_count} zone equipment removed.") return model end
[ "def remove_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n if equipment.to_FanZoneExhaust.is_initialized\n runner.registerInfo(\"#{equipment.name} is a zone exhaust fan and will not be removed.\")\n else\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def clean_air_zones_data\n ComplianceCheckerApi.clean_air_zones\n end", "def delete_all_zones\n super\n end", "def delete_assets!\n SsObject.in_solar_system(self).delete_all\n Wreckage.in_zone(self).delete_all\n Unit.in_zone(self).delete_all\n end", "def delete_all_administrative_ips\n super\n end", "def cleanup\n # delete participating armies\n self.armies.each do |army|\n if army.empty? && !army.garrison?\n if GAME_SERVER_CONFIG['military_only_flag_destroyed_armies']\n army.removed = true\n unless army.save\n raise InternalServerError.new('Failed to flag an army as removed')\n end\n else\n army.destroy\n end\n end\n end\n\n # destroy appropriate event\n self.event.destroy\n\n # remove battle or set to removed\n if GAME_SERVER_CONFIG['military_only_flag_destroyed_battles']\n self.removed = true\n unless self.save\n raise InternalServerError.new('Failed to flag an battle as removed')\n end\n else\n self.destroy\n end\n end", "def zone_purge(zone)\n obj_purge(zone,Zone)\n end", "def delete_all_wideips\n super\n end", "def clean_air_zone\n CleanAirZone.find(session_details[:caz_id])\n end", "def destroy_unused_machines\n available_machines.select(&:deleteable?).each do |machine|\n retired_machines.push available_machines.delete(machine)\n machine.destroy!\n end\n end", "def remove \n # Remove all of its subzones\n zones.each{|z| z.remove }\n \n parent = self.get_parent\n parent[N::TALIA.hasSubZone].remove(self)\n\n self.destroy\n parent.save\n end", "def remove_all_tenants\n @apt_tenants.clear\n end", "def remove_ips(zone_name, ips)\n data = {}\n data[\"zone\"] = zone_name\n data[\"ips\"] = ips\n request(:delete, \"/api/zone/ips\", Oj.dump(data, mode: :compat))\n end", "def prune_universe(items)\n end", "def remove_disallowed_items!\n for equipment in equipments\n remove!(equipment) unless allows?(equipment, true)\n end\n end", "def cleanup_unused_ip_addresses\n fog_compute.addresses.each do |a|\n unless a.server\n print \"Deleting unused IP address #{a.public_ip}... \"\n a.destroy\n puts \"done\"\n end\n end\n end", "def cleanup_unused_ip_addresses\n fog_compute.addresses.each do |a|\n puts \"Deleting IP address #{a.public_ip}...\"\n a.destroy unless a.server\n end\n end", "def summon_removal\n # remove all expired pets\n @pets.clone.each {|p| @pets.delete(p) if p.terminate}\n # remove all expired monsters\n @monsters.clone.each {|m| @monsters.delete(m) if m.terminate}\n end", "def unequip_all\n @properties[:equipped].clear\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove unused performance curves
def remove_unused_curves(model) model.getCurves.each do |curve| if curve.directUseCount == 0 model.removeObject(curve.handle) end end return model end
[ "def remove_all_cost_segments\n super\n end", "def discard_trip_outliers\n @drivers.each do |driver|\n driver.discard_trip_outliers\n end\n end", "def remove_useless_traces_data(params)\n convert_list_of_json_traces_to_objects(params[0])\n create_new_traces\n @traces_json_string = '[' + @traces_json_string[0...-1] + ']'\n puts @traces_json_string\n end", "def re_calculate_performances\n count = 1\n plates.each do |plate|\n puts \"deleting old performances for plate number #{count}\"\n count += 1\n plate.wells.each do |well|\n next if !well.replicate\n well.replicate.characterizations.each do |char|\n char.performances.each do |perf|\n perf.delete\n end\n end\n end\n end\n\n puts \"all old performances deleted. now calculating new performances\"\n calculate_performances\n end", "def time_entries_without_rates\n self.time_entries.collect {|te| te.cost <= 0 ? te : nil}.compact\n end", "def cleanup_derivatives; end", "def stop_precise_coverage\n {\n method: \"Profiler.stopPreciseCoverage\"\n }\n end", "def clear_all!\n @perf_meters.clear\n end", "def discard_trip_outliers\n @trips.delete_if do |trip|\n if trip.avg_speed < 5.0 || trip.avg_speed > 100.0\n true\n end\n end\n end", "def prune_strategy; end", "def test_discard_trip_outliers\n history = DrivingHistory.new()\n history.drivers << Driver.new(\"Alex\")\n history.drivers[0].\n trips << Trip.new(\"Alex\", \"12:35\", \"13:35\", \"3.4\")\n history.drivers[0].\n trips << Trip.new(\"Alex\", \"13:35\", \"14:35\", \"68.3\")\n history.drivers[0].\n trips << Trip.new(\"Alex\", \"14:35\", \"15:35\", \"105.2\")\n history.discard_trip_outliers\n assert_equal(history.drivers[0].trips.length, 1)\n assert_equal(history.drivers[0].trips[0].avg_speed, 68.3)\n end", "def border_points_minus_removed\n points = []\n border_points.each do |point|\n points << point if !point.marked_for_destruction?\n end\n points\n end", "def removeStress\n @syllables.each do |syllable|\n syllable.stress = StressType::NONE\n end\n end", "def waypoints_minus_removed\n points = []\n waypoints.each do |waypoint|\n points << waypoint if !waypoint.marked_for_destruction?\n end\n points\n end", "def reset\n @collected_metrics = []\n end", "def mark_progresses_for_removal\n self.progresses.each do |p|\n if p.due_date.blank? && p.accuracy.to_i <= 0\n p.mark_for_destruction\n end\n end\n end", "def clear\n @mutex.synchronize do\n @metrics.each do |key, metric|\n metric.stop if metric.respond_to?(:stop)\n end\n\n @metrics = {}\n end\n end", "def purge\n @time_graph.each do |t, te|\n if t <= (@last_entry_time - ROLLING_WINDOW_SIZE)\n te.each { |e| @adj_matrix.delete(e) }\n @time_graph.delete(t)\n end\n end\n end", "def remove_timelines\n @temporal_statuses = []\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove all HVAC equipment including service hot water loops and zone exhaust fans
def remove_all_HVAC(model) remove_air_loops(model) remove_all_plant_loops(model) remove_vrf(model) remove_all_zone_equipment(model, runner) remove_unused_curves(model) return model end
[ "def remove_all_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def remove_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n if equipment.to_FanZoneExhaust.is_initialized\n runner.registerInfo(\"#{equipment.name} is a zone exhaust fan and will not be removed.\")\n else\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} zone equipment removed.\")\n return model\n end", "def cleanup()\n log.info \"Cleanup: Delete the VM SATA adapters that were added #{satas_to_delete}\"\n (satas_to_delete).each do |sata|\n log.info \"Deleting the SATA adapter #{sata} of the VM #{vm_name} , ID '#{vm_id}'\"\n sata_svc.delete(vm_id, sata)\n end\n sata_summaries = sata_svc.list(vm_id)\n log.info \"Sata Summary after deleting the SATA adapters is #{sata_summaries.to_yaml}\"\n end", "def cleanup()\n log.info \"Cleanup: Delete the VM SCSI adapters that were added #{scsi_to_delete}\"\n (scsi_to_delete).each do |scsi|\n log.info \"Deleting the SCSI adapter #{scsi} of the VM #{vm_name} , ID '#{vm_id}' \"\n scsi_svc.delete(vm_id, scsi)\n end\n scsi_summaries = scsi_svc.list(vm_id)\n log.info \"Scsi Summary after deleting the sample created SCSI adapters is #{scsi_summaries.to_yaml}\"\n end", "def cleanup\n # delete participating armies\n self.armies.each do |army|\n if army.empty? && !army.garrison?\n if GAME_SERVER_CONFIG['military_only_flag_destroyed_armies']\n army.removed = true\n unless army.save\n raise InternalServerError.new('Failed to flag an army as removed')\n end\n else\n army.destroy\n end\n end\n end\n\n # destroy appropriate event\n self.event.destroy\n\n # remove battle or set to removed\n if GAME_SERVER_CONFIG['military_only_flag_destroyed_battles']\n self.removed = true\n unless self.save\n raise InternalServerError.new('Failed to flag an battle as removed')\n end\n else\n self.destroy\n end\n end", "def remove_air_loops(model)\n model.getAirLoopHVACs.each(&:remove)\n return model\n end", "def delete_assets!\n SsObject.in_solar_system(self).delete_all\n Wreckage.in_zone(self).delete_all\n Unit.in_zone(self).delete_all\n end", "def destroy_unused_machines\n available_machines.select(&:deleteable?).each do |machine|\n retired_machines.push available_machines.delete(machine)\n machine.destroy!\n end\n end", "def remove_all_vrfs\n require_relative '../lib/cisco_node_utils/vrf'\n Vrf.vrfs.each do |vrf, obj|\n next if vrf[/management/]\n obj.destroy\n end\n end", "def cleanup\n @logger.notify \"Cleaning up OpenStack\"\n @vms.each do |vm|\n cleanup_storage(vm)\n @logger.debug \"Release floating IPs for OpenStack host #{vm.name}\"\n floating_ips = vm.all_addresses # fetch and release its floating IPs\n floating_ips.each do |address|\n @compute_client.disassociate_address(vm.id, address['ip'])\n @compute_client.release_address(address['id'])\n end\n @logger.debug \"Destroying OpenStack host #{vm.name}\"\n vm.destroy\n if @options[:openstack_keyname].nil?\n @logger.debug \"Deleting random keypair\"\n @compute_client.delete_key_pair vm.name\n end\n end\n end", "def remove_all_vlans\n remove_all_bridge_domains\n remove_all_svis\n Vlan.vlans.each do |vlan, obj|\n # skip reserved vlan\n next if vlan == '1'\n next if node.product_id[/N5K|N6K|N7K/] && (1002..1005).include?(vlan.to_i)\n obj.destroy\n end\n end", "def cleanup_armies(battle)\n battle.armies.each do |army|\n if army.empty? && !army.garrison?\n if GAME_SERVER_CONFIG['military_only_flag_destroyed_armies']\n army.removed = true\n raise InternalServerError.new('Failed to flag an army as removed') unless army.save\n else\n army.destroy\n end\n else\n #remove battle id !!! battle_id must be set to nil for removing army from battle\n army.battle = nil\n raise InternalServerError.new('Failed to set the battle id in the army to null') unless army.save\n end\n end\n\n if GAME_SERVER_CONFIG['military_only_flag_destroyed_armies']\n runloop.say \"Flaged destroyed armies as 'removed'\"\n else\n runloop.say \"Deleted destroyed armies from the database\"\n end\n\n end", "def reap\n vms = vbox_vm_names(false)\n vms_not_running = vms - vbox_vm_names(true)\n\n # Unregister and delete vms that match but aren't running.\n vms_not_running.each do |vm|\n next unless vm.end_with?(@suffix)\n vbox(\"unregistervm\", vm, \"--delete\")\n vms.delete(vm)\n end\n\n # Delete unused host-only interfaces\n vbox_find_hostonlyifs(:not_used_by => vms).each do |iface|\n vbox(\"hostonlyif\", \"remove\", iface['Name'])\n end\n end", "def unequip_all\n @properties[:equipped].clear\n end", "def clear_dead_pokemon\n dead_condition = proc { |pokemon| pokemon.hp <= 0 }\n # List all the items from dead Pokemon\n item_ids = $actors.select(&dead_condition).map(&:item_hold)\n # Add items back to the bag\n item_ids.each { |item_id| $bag.add_item(item_id, 1) if item_id >= 0 }\n # Storing Pokemon that are dead\n graveyard.concat($actors.select(&dead_condition))\n # Remove Pokemon from the party\n $actors.delete_if(&dead_condition)\n end", "def clean_air_zones_data\n ComplianceCheckerApi.clean_air_zones\n end", "def remove_all_ospfs\n require_relative '../lib/cisco_node_utils/router_ospf'\n RouterOspf.routers.each do |_, obj|\n obj.destroy\n end\n end", "def remove_all_vrfs\n require_relative '../lib/cisco_node_utils/vrf'\n Vrf.vrfs.each do |vrf, obj|\n next if vrf[/management/]\n # TBD: Remove vrf workaround below after CSCuz56697 is resolved\n config 'vrf context ' + vrf if node.product_id[/N8/]\n obj.destroy\n end\n end", "def remove_indicator_resources\r\n @indicator1_comm_dumm.destroy\r\n @indicator2_pub_speak.destroy\r\n @indicator3_pub_speak.destroy\r\n @indicator4_busi_success.destroy\r\n @indicator4_busi_failure.destroy\r\n @indicator5_busi_success.destroy\r\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /android_profiles/new GET /android_profiles/new.json
def new @android_profile = @user.build_android_profile respond_to do |format| format.html # new.html.erb format.json { render json: @android_profile } end end
[ "def new\n @profile = current_user.profiles.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profile }\n end\n end", "def new\n @user = User.find(params[:user_id])\n @profile = @user.profile == nil ? Profile.new : @user.profile\n @from_profiles_new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profile }\n end\n end", "def new\n @profile = current_user.profiles.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @profile }\n format.json { render :json => @profile }\n\n end\n end", "def create\n @android_profile = @user.build_android_profile(params[:android_profile])\n\n respond_to do |format|\n if @android_profile.save\n format.html { redirect_to user_android_profile_url, :flash => { success: 'Successfully saved.' } }\n format.json { render json: @android_profile, status: :created, location: @android_profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @android_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def newprofile\n result = {}\n result[:status] = \"failed\"\n if params[\"auth_key\"] != nil and params[\"device_id\"] != nil and params[\"profile_url\"] != nil and device = Device.where(:id => params[\"device_id\"], :auth_key => params[\"auth_key\"]).take\n device.profile_url = params[\"profile_url\"]\n if device.save\n result[:status] = \"success\"\n result[:data] = device\n else\n result[:status] = \"save error\"\n end\n else\n result[:status] = \"device not valid\"\n end\n\n render :json => result\n end", "def newprofile\n if params[\"auth_key\"] == nil or params[\"device_id\"] == nil or params[\"profile_url\"] == nil\n render :json => '{\"status\": \"failed\", \"reason\": \"incorrect parameters\"}'\n else\n device = Device.find(params[\"device_id\"])\n if device.auth_key == params[\"auth_key\"]\n device.profile_url = params[\"profile_url\"]\n if device.save\n render :json => '{\"status\": \"success\"}'\n else\n render :json => '{\"status\": \"failed\", \"reason\": \"save error\"}'\n end\n else\n render :json => '{\"status\": \"failed\", \"reason\": \"not authorized\"}'\n end\n end\n end", "def new\n @profile = Profile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profile }\n end\n end", "def new\n @profile_attribute = current_user.profile_attributes.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @profile_attribute }\n format.json { render :json => @profile_attribute }\n end\n end", "def new\n @webprofile = Webprofile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @webprofile }\n end\n end", "def new\n @profile_type = ProfileType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profile_type }\n end\n end", "def create\n @profile = current_user.profiles.new(params[:profile])\n\n respond_to do |format|\n if @profile.save\n format.html { redirect_to @profile, notice: 'Profile was successfully created.' }\n format.json { render json: @profile, status: 201, location: @profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @profile.errors, status: 422 }\n end\n end\n end", "def new\n @official_profile = OfficialProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @official_profile }\n end\n end", "def new\n @provisioning_profile = current_user.provisioning_profiles.new\n end", "def create\n @profile = current_user.profiles.build(profile_params)\n\n respond_to do |format|\n if @profile.save\n format.html { redirect_to @profile, notice: 'Profile was successfully created.' }\n format.json { render action: 'show', status: :created, location: @profile }\n else\n format.html { render action: 'new' }\n format.json { render json: @profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @profilepage = Profilepage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profilepage }\n end\n end", "def new\n @user_profile = UserProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_profile }\n end\n end", "def create\n @profile = Profile.new(profile_params)\n\n if @profile.save\n render json: @profile, status: :created, location: [:web, @profile]\n else\n render json: @profile.errors, status: :unprocessable_entity\n end\n end", "def new\n @private_profile = PrivateProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @private_profile }\n end\n end", "def new\n @profile_account = ProfileAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profile_account }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /android_profiles POST /android_profiles.json
def create @android_profile = @user.build_android_profile(params[:android_profile]) respond_to do |format| if @android_profile.save format.html { redirect_to user_android_profile_url, :flash => { success: 'Successfully saved.' } } format.json { render json: @android_profile, status: :created, location: @android_profile } else format.html { render action: "new" } format.json { render json: @android_profile.errors, status: :unprocessable_entity } end end end
[ "def new\n @android_profile = @user.build_android_profile\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @android_profile }\n end\n end", "def newprofile\n result = {}\n result[:status] = \"failed\"\n if params[\"auth_key\"] != nil and params[\"device_id\"] != nil and params[\"profile_url\"] != nil and device = Device.where(:id => params[\"device_id\"], :auth_key => params[\"auth_key\"]).take\n device.profile_url = params[\"profile_url\"]\n if device.save\n result[:status] = \"success\"\n result[:data] = device\n else\n result[:status] = \"save error\"\n end\n else\n result[:status] = \"device not valid\"\n end\n\n render :json => result\n end", "def create\n @profile = Profile.new(profile_params)\n\n if @profile.save\n render json: @profile, status: :created, location: [:web, @profile]\n else\n render json: @profile.errors, status: :unprocessable_entity\n end\n end", "def newprofile\n if params[\"auth_key\"] == nil or params[\"device_id\"] == nil or params[\"profile_url\"] == nil\n render :json => '{\"status\": \"failed\", \"reason\": \"incorrect parameters\"}'\n else\n device = Device.find(params[\"device_id\"])\n if device.auth_key == params[\"auth_key\"]\n device.profile_url = params[\"profile_url\"]\n if device.save\n render :json => '{\"status\": \"success\"}'\n else\n render :json => '{\"status\": \"failed\", \"reason\": \"save error\"}'\n end\n else\n render :json => '{\"status\": \"failed\", \"reason\": \"not authorized\"}'\n end\n end\n end", "def create\n @profile = current_user.profiles.new(params[:profile])\n\n respond_to do |format|\n if @profile.save\n format.html { redirect_to @profile, notice: 'Profile was successfully created.' }\n format.json { render json: @profile, status: 201, location: @profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @profile.errors, status: 422 }\n end\n end\n end", "def create\n @profile = current_user.profiles.build(profile_params)\n\n respond_to do |format|\n if @profile.save\n format.html { redirect_to @profile, notice: 'Profile was successfully created.' }\n format.json { render action: 'show', status: :created, location: @profile }\n else\n format.html { render action: 'new' }\n format.json { render json: @profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_profile!\n bundle_id = Sigh.config[:app_identifier]\n name = Sigh.config[:provisioning_name]\n if !name\n name = Sigh.config[:app_identifier].gsub '.' ,''\n end\n\n UI.important \"Creating new provisioning profile for '#{Sigh.config[:app_identifier]}' with name '#{name}'\"\n profile = profile_type.create!(name: name,\n bundle_id: bundle_id)\n profile\n end", "def create\n @profile = Profile.new(profile_params)\n\n if @profile.save\n render json: @profile, status: :created\n else\n render json: @profile.errors, status: :unprocessable_entity\n end\n end", "def set_profile(profile_contents)\n path = self.api_root + '/register/profile'\n process_firecloud_request(:post, path, profile_contents.to_json)\n end", "def save_profile(profile, file)\n result = load_profiles(file)\n data = profile.profile_data\n result[profile.username] = data\n wFile = File.open(\"profiles.json\", 'w')\n wFile.write(JSON.pretty_generate(result))\n wFile.close\nend", "def create\n @provisioning_profile = current_user.provisioning_profiles.new(params[:provisioning_profile])\n\n if @provisioning_profile.save\n redirect_to provisioning_profiles_url, notice: 'Provisioning profile was successfully created.'\n else\n render action: \"new\"\n end\n end", "def update_profile(options = {}) \n # query profile info\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(URI_PROFILES, :params => { 'filter[name]' => options[:name] })\n if response.status.success?\n responseObj = JSON.parse(response.body)\n queried_profile_list = responseObj[\"data\"]\n if queried_profile_list.length() > 0\n profile = queried_profile_list[0]\n end\n else\n Asca::Tools::Log.error(response.body)\n return\n end\n \n if !profile\n Asca::Tools::Log.error(\"No profile named #{options[:name]} found\")\n return\n end\n # create new profile\n profile_type = profile[\"attributes\"][\"profileType\"]\n \n # get bundle id\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(profile[\"relationships\"][\"bundleId\"][\"links\"][\"self\"])\n bundle_id = JSON.parse(response.body)[\"data\"][\"id\"]\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(profile[\"relationships\"][\"certificates\"][\"links\"][\"self\"])\n certificate_ids = JSON.parse(response.body)[\"data\"].map { |cer| cer[\"id\"] }\n \n # get all device ids\n device_ids = Asca::REST::Provisioning::Devices.list_devices.map { |device|\n device[\"id\"]\n }\n \n # delete old prifile\n delete_profile :name => options[:name]\n \n if profile_type.include? 'APP_STORE'\n create_new_profile :name => options[:name], :type => profile_type, :bundle_id => bundle_id, :certificate_ids => certificate_ids\n else\n create_new_profile :name => options[:name], :type => profile_type, :bundle_id => bundle_id, :device_ids => device_ids, :certificate_ids => certificate_ids\n end\n \n return true\n end", "def create\n @user = current_user()\n @profile = @user.profiles.new(params[:profile])\n\n respond_to do |format|\n if @profile.save\n flash[:notice] = 'Profile was successfully created.'\n format.html { redirect_to(@profile) }\n format.xml { render :xml => @profile, :status => :created, :location => @profile }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n end\n end\n end", "def assign_default_profile(args = {}) \n put(\"/profiles.json/#{args[:profileId]}/default\", args)\nend", "def create\n @profile = current_user.profiles.create(params[:profile])\n @profile.add_properties(params[:property])\n\n if @profile.save\n flash[:notice] = 'Profile was successfully created.'\n redirect_to :action => 'list'\n else\n render :action => 'new' \n end\n end", "def create_DB_profile\n \n @profile = ProfileId.new\n @profile.user_name = params[:user_name]\n @profile.profile_id = @parsed[\"profileId\"]\n @profile.save\n end", "def create\n @account = AndroidAccount.new(params[:android_account])\n current_user.person.android_accounts << @account\n\n respond_to do |format|\n if @account.save\n format.html { redirect_to( accounts_path, :notice => 'Account was successfully created.') }\n format.json { render :json => @account, :status => :created, :location => @account }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @webprofile = Webprofile.new(params[:webprofile])\n\n respond_to do |format|\n if @webprofile.save\n format.html { redirect_to @webprofile, notice: 'Webprofile was successfully created.' }\n format.json { render json: @webprofile, status: :created, location: @webprofile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @webprofile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_profile\n new_profile = Profile.new\n new_profile.user_id = self.id\n new_profile.save!\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /android_profiles/1 PUT /android_profiles/1.json
def update @android_profile = @user.android_profile respond_to do |format| if @android_profile.update_attributes(params[:android_profile]) format.html { redirect_to user_android_profile_url, :flash => { success: 'Successfully updated.' } } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @android_profile.errors, status: :unprocessable_entity } end end end
[ "def assign_default_profile(args = {}) \n put(\"/profiles.json/#{args[:profileId]}/default\", args)\nend", "def update_profile(options = {}) \n # query profile info\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(URI_PROFILES, :params => { 'filter[name]' => options[:name] })\n if response.status.success?\n responseObj = JSON.parse(response.body)\n queried_profile_list = responseObj[\"data\"]\n if queried_profile_list.length() > 0\n profile = queried_profile_list[0]\n end\n else\n Asca::Tools::Log.error(response.body)\n return\n end\n \n if !profile\n Asca::Tools::Log.error(\"No profile named #{options[:name]} found\")\n return\n end\n # create new profile\n profile_type = profile[\"attributes\"][\"profileType\"]\n \n # get bundle id\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(profile[\"relationships\"][\"bundleId\"][\"links\"][\"self\"])\n bundle_id = JSON.parse(response.body)[\"data\"][\"id\"]\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(profile[\"relationships\"][\"certificates\"][\"links\"][\"self\"])\n certificate_ids = JSON.parse(response.body)[\"data\"].map { |cer| cer[\"id\"] }\n \n # get all device ids\n device_ids = Asca::REST::Provisioning::Devices.list_devices.map { |device|\n device[\"id\"]\n }\n \n # delete old prifile\n delete_profile :name => options[:name]\n \n if profile_type.include? 'APP_STORE'\n create_new_profile :name => options[:name], :type => profile_type, :bundle_id => bundle_id, :certificate_ids => certificate_ids\n else\n create_new_profile :name => options[:name], :type => profile_type, :bundle_id => bundle_id, :device_ids => device_ids, :certificate_ids => certificate_ids\n end\n \n return true\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 save\n overwrite @api.put('/profile.json',\n 'name' => name,\n 'timezone' => timezone,\n 'email' => email\n )\n end", "def create\n @android_profile = @user.build_android_profile(params[:android_profile])\n\n respond_to do |format|\n if @android_profile.save\n format.html { redirect_to user_android_profile_url, :flash => { success: 'Successfully saved.' } }\n format.json { render json: @android_profile, status: :created, location: @android_profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @android_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_current_user_profile_data(user_profile_data)\n # PUT /d2l/api/lp/(version)/profile/myProfile\nend", "def update\n @profiles = current_user.profiles.find(params[:id])\n\n respond_to do |format|\n if @profiles.update(profile_params)\n format.html { redirect_to profiles_path, notice: 'Profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @profiles }\n else\n format.html { render :edit }\n format.json { render json: @profiles.errors, status: :unprocessable_entity }\n end\n end\n end", "def clear_default_profile \n put(\"/profiles.json/default/clear\")\nend", "def update\n @profile = current_user.profiles.find(params[:id])\n\n respond_to do |format|\n if @profile.update_attributes(params[:profile])\n format.html { redirect_to(@profile, :notice => 'Profile was successfully updated.') }\n format.xml { head :ok }\n format.json { render :json => @profile }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n format.json { render :json => {:error => @profile.errors.full_messages} }\n end\n end\n end", "def update\n @profile = current_user.profiles\n\n respond_to do |format|\n if @profile.update_attributes(params[:profile])\n flash[:notice] = 'Profile was successfully updated.'\n format.html { redirect_to(@profile) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_profile(profile_contents)\n path = self.api_root + '/register/profile'\n process_firecloud_request(:post, path, profile_contents.to_json)\n end", "def update_sdk_profile\n if saved_change_to_attribute?(:fullname) || saved_change_to_attribute(:avatar_url)\n # begin\n Rails.logger.debug \"Update SDK profile\"\n password = SecureRandom.hex # generate random password for security reason\n qiscus_sdk = QiscusSdk.new(application.app_id, application.qiscus_sdk_secret)\n qiscus_sdk.login_or_register_rest(qiscus_email, password, fullname, avatar_url) # get qiscus token\n # rescue => e\n # message = \"Fail when call SDK in update user profile\"\n # Raven.capture_message(message,\n # level: \"error\",\n # extra: {\n # message: e.message\n # }\n # )\n # end\n end\n end", "def newprofile\n if params[\"auth_key\"] == nil or params[\"device_id\"] == nil or params[\"profile_url\"] == nil\n render :json => '{\"status\": \"failed\", \"reason\": \"incorrect parameters\"}'\n else\n device = Device.find(params[\"device_id\"])\n if device.auth_key == params[\"auth_key\"]\n device.profile_url = params[\"profile_url\"]\n if device.save\n render :json => '{\"status\": \"success\"}'\n else\n render :json => '{\"status\": \"failed\", \"reason\": \"save error\"}'\n end\n else\n render :json => '{\"status\": \"failed\", \"reason\": \"not authorized\"}'\n end\n end\n end", "def update\n @profile = @user.profile \n respond_to do |format|\n if @profile.update_attributes(params[:profile])\n flash[:notice] = t('profiles.new.success')\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_profile\n mpi_service.update_profile(user_identity)\n end", "def update\n @official_profile = OfficialProfile.find(params[:id])\n\n respond_to do |format|\n if @official_profile.update_attributes(params[:official_profile])\n format.html { redirect_to @official_profile, notice: 'Official profile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @official_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @account = current_user.person.android_accounts.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:android_account])\n format.html { redirect_to( accounts_path, :notice => 'Account was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @account.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_profile_image_by_profile_id\n # POST /d2l/api/lp/(version)/profile/(profileId)/image\n # RETURNS: ?\nend", "def update_profile(profile)\n @type = Type::CIM_UPDATE_PROFILE\n @fields.merge!(profile.to_hash)\n make_request\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /android_profiles/1 DELETE /android_profiles/1.json
def destroy @android_profile = @user.android_profile @android_profile.destroy respond_to do |format| format.html { redirect_to new_user_android_profile_url, :flash => { success: 'Successfully deleted.' } } format.json { head :no_content } end end
[ "def destroy\n @profile.destroy\n respond_to do |format|\n format.html { redirect_to phone_profiles_url, notice: 'Profile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def clear_default_profile \n put(\"/profiles.json/default/clear\")\nend", "def destroy\n @profile = Profile.find(params[:id])\n @profile.user.destroy\n @profile.destroy\n\n\n respond_to do |format|\n format.html { redirect_to profiles_url }\n format.json { head :ok }\n end\n end", "def destroy\n @profile = @user.profile\n @profile.destroy\n\n respond_to do |format|\n format.html { redirect_to profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @provisioning_profile = current_user.provisioning_profiles.find(params[:id])\n @provisioning_profile.destroy\n redirect_to provisioning_profiles_url\n end", "def destroy\n @official_profile = OfficialProfile.find(params[:id])\n @official_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to official_profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @saved_profile = SavedProfile.find(params[:id])\n @saved_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to saved_profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @profile = Profile.find(params[:id])\n @profile.destroy\n\n respond_to do |format|\n format.html { redirect_to profiles_url }\n format.json { head :ok }\n end\n end", "def destroy\n @profile.destroy\n redirect_to admin_cert_profiles_path, notice: 'Profile was successfully destroyed.'\n end", "def destroy\n @app_profile = AppProfile.find(params[:id])\n @app_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to(app_profiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @profile1 = Profile1.find(params[:id])\n @profile1.destroy\n\n respond_to do |format|\n format.html { redirect_to profile1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @profile.destroy\n\n respond_to do |format|\n format.html { redirect_to(profiles_url) }\n format.xml { head :ok }\n end\n end", "def delete_all_profiles\n super\n end", "def destroy\n @profile.destroy\n\n respond_to do |format|\n format.html { redirect_to(profiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @personal_profile.destroy\n respond_to do |format|\n format.html { redirect_to resume_path, notice: 'Personal profile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hmm_profile = HmmProfile.find(params[:id])\n @hmm_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to hmm_profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_profile = UserProfile.find(params[:id])\n @user_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to user_profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @userprofile = Userprofile.find(params[:id])\n @userprofile.destroy\n\n respond_to do |format|\n format.html { redirect_to userprofiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # Delete profile\n @profil.destroy\n respond_to do |format|\n format.html { redirect_to profils_url, notice: 'Profil was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We strip the segments before code analysis begins
def pre_code_analyze # grab the section names we will strip return if not options[ '/strip' ] # split the string into an array of section names names = options[ '/strip' ].split( ';' ) # don't bother to continue if we have no sections to strip return if names.empty? # we must hold the write lock while we delete segments... cm.synchronize_write do # grab the current auto_analyze value so we can restore it when we are done orig_auto_analyze = cm.auto_analyze # disable auto analysis so every time we call cm.delete_segment() we don't trigger # cm.analyze() not only would this incur an unnecessary performance hit, but as # we are running pre_code_analyze we do not want to invoke the analyze at this # stage in the pipeline. cm.auto_analyze = false # keep an array of the segments we will delete del = [] # iterate over every segment to see if we want to delete it cm.segments do | segment | if( names.include?( segment.name ) ) del << segment end end # delete every segment in our list del.each do | segment | cm.delete_segment( segment ) end # restore the original auto_analyze value cm.auto_analyze = orig_auto_analyze end end
[ "def remove_segments()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_remove_segments(@handle.ptr)\n end", "def strip_comments!\n\t\t@code = strip_comments\n\tend", "def trim_code_prefix!\n substr!(4) if @line.length > 4\n end", "def visit_segment(segment)\n return unless enabled? && segment\n\n trace = strip_newrelic_frames(caller)\n trace = trace.first(40) if trace.length > 40\n segment[:backtrace] = trace\n end", "def clean_code\n block = self\n\n # if it's a fenced code block, just discard the fence and everything\n # outside it\n if block.fenced?\n return block.gsub(/(?:^|.*?\\n)(`{3,})(\\w+)?(.*?)\\n\\1.*/m) {|m| $3.strip }\n end\n\n # assume it's indented code, discard non-indented lines and outdent\n # the rest\n indent = nil\n inblock = false\n code = []\n block.split(/\\n/).each {|line|\n if line =~ /^\\s*$/ && inblock\n code.push(line)\n elsif line =~ /^( {4,}|\\t+)/\n inblock = true\n indent ||= Regexp.new(\"^#{$1}\")\n code.push(line.sub(indent,''))\n else\n inblock = false\n end\n }\n code.join(\"\\n\")\n end", "def strip!() end", "def omit_segments_with(regex)\n regex = Regexp.new(regex)\n\n sample = TransactionSample.new(@start_time, sample_id)\n\n sample.params = params.dup\n sample.params[:segment_count] = 0\n\n delta = build_segment_with_omissions(sample, 0.0, @root_segment, sample.root_segment, regex)\n sample.root_segment.end_trace(@root_segment.exit_timestamp - delta)\n sample.profile = self.profile\n sample\n end", "def clean_stack(stack)\n open_stack,keep=[],{}\n stack.each do |elt|\n if elt[1]==1\n open_stack << elt\n else\n if open_stack.empty?\n ##too many closed delimiters\n else\n keep[elt]=true\n keep[open_stack.pop]=true\n end\n end\n end\n=begin\n if Dyndoc.cfg_dir[:debug]\n tmp=stack.select{|elt| !keep[elt]}.select{|e| @tag_type==:call and e[2] and e[1]==1 and e[2]!='{'}\n begin p @txt;p tmp end unless tmp.empty?\n end\n=end\n stack.select{|elt| keep[elt]}\n end", "def stripped_sample(sample = @sample)\n sample.omit_segments_with('(Rails/Application Code Loading)|(Database/.*/.+ Columns)')\n end", "def _strip seq\n seq.shift while (tok = seq.first) && tok.type == :endline\n end", "def clean_code\n block = dup\n\n # if it's a fenced code block, just discard the fence and everything\n # outside it\n if block.fenced?\n code_blocks = block.scan(/(`{3,})(\\S+)?\\s*\\n(.*?)\\n\\1/m)\n code_blocks.map! { |b| b[2].strip }\n return code_blocks.join(\"\\n\\n\")\n end\n\n # assume it's indented code, discard non-indented lines and outdent\n # the rest\n block = block.outdent if block.indented?\n\n block\n end", "def backtrace_remove; end", "def untrace()\n #This is a stub, used for indexing\n end", "def strip_comments\n\t\t# removes whole lines only, doesn't remove inline comments\n\t\tcode_to_be_obfu = ''\n\t\t@code.each_line do |line|\n\t\t\tif (not line =~ /^\\s*\\/\\// and not line =~ /^\\s+$/)\n\t\t\t\tcode_to_be_obfu << line \n\t\t\tend\n\t\tend\n\t\treturn code_to_be_obfu\n\tend", "def remove_code_or_whole_line(source, line)\n newline_at_end_of_line = source[-1] == \"\\n\"\n source_arr = source.split(\"\\n\")\n if source_arr[line - 1] && source_arr[line - 1].strip.empty?\n source_arr.delete_at(line - 1)\n if source_arr[line - 2] && source_arr[line - 2].strip.empty? && source_arr[line - 1] && source_arr[line - 1].strip.empty?\n source_arr.delete_at(line - 1)\n end\n source_arr.join(\"\\n\") + (newline_at_end_of_line ? \"\\n\" : '')\n else\n source\n end\n end", "def strip_listing(code)\n code = code.dup\n code.gsub!(/\\t/, \" \")\n lines = code.split(\"\\n\")\n first_code_line = lines.index{|l| l =~ /\\S/}\n last_code_line = lines.rindex{|l| l =~ /\\S/}\n code_lines = lines[first_code_line..last_code_line]\n line_indents = code_lines.map{|l| l.index(/\\S/) || 0}\n min_indent = line_indents.min\n unindented_code = code_lines.map{|l| l[min_indent..-1]}.join(\"\\n\")\n unindented_code.strip\n end", "def remove_all_cost_segments\n super\n end", "def snarf_prologue\r\n i = 0\r\n (buf = @dpoint.read(20)).distorm.each do |insn|\r\n i += insn.size\r\n break if i >= 5\r\n end\r\n buf[0...i] \r\n end", "def remove_whitespace_before(index, buffer, rewriter, remove_preceding_newline)\n end_pos = index\n begin_pos = end_pos - 1\n begin_pos -= 1 while 0 <= begin_pos && raw_code[begin_pos] =~ /\\s/ && raw_code[begin_pos] != \"\\n\"\n begin_pos -= 1 if 0 <= begin_pos && raw_code[begin_pos] == \"\\n\"\n begin_pos -= 1 if remove_preceding_newline && 0 <= begin_pos && raw_code[begin_pos] == \"\\n\"\n return if begin_pos.next == end_pos\n rewriter.remove code.range_for(begin_pos.next, end_pos)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /forum_comentarios POST /forum_comentarios.json
def create @forum_comentario = ForumComentario.new(forum_comentario_params) @forum_comentario.usuario_curso_id = @perfil.id if @forum_comentario.save ApplicationMailer.nova_postagem_forum(@forum_comentario).deliver @forum_comentario = ForumComentario.where(forum_id: @forum_comentario.forum_id) else respond_to do |format| format.js { render :new } format.json { render json: @forum_comentario.errors, status: :unprocessable_entity } end end end
[ "def CreateForum params = {}\n \n APICall(path: 'forums.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @comentarios_admin = ComentariosAdmin.new(params[:comentarios_admin])\n\n respond_to do |format|\n if @comentarios_admin.save\n format.html { redirect_to @comentarios_admin, notice: 'Comentarios admin was successfully created.' }\n format.json { render json: @comentarios_admin, status: :created, location: @comentarios_admin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comentarios_admin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @condominios = Condominio.new(params[:condominio])\n\n respond_to do |format|\n if @condominios.save\n format.html { redirect_to @condominios, notice: 'Condominio was successfully created.' }\n format.json { render json: @condominios, status: :created, location: @condominios }\n else\n format.html { render action: \"new\" }\n format.json { render json: @condominios.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @forum_comentario.update(forum_comentario_params)\n @forum_comentario = ForumComentario.where(forum_id: @forum_comentario.forum_id)\n else\n respond_to do |format|\n format.js { render :edit }\n format.json { render json: @forum_comentario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cate_forum = CateForum.new(cate_forum_params)\n\n respond_to do |format|\n if @cate_forum.save\n format.html { redirect_to @cate_forum, notice: \"Cate forum was successfully created.\" }\n format.json { render :show, status: :created, location: @cate_forum }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @cate_forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_forum payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post FORUMS, payload )\n\t\t\t\tend", "def post_to_forum\n begin\n response = RestClient::Request.execute(\n method: :post,\n url: EBU::API_URL + \"/ebuio/forum/\",\n timeout: EBU::NETWORK_TIMEOUT,\n open_timeout: EBU::NETWORK_TIMEOUT,\n headers: { 'Accept-Charset' => 'utf-8' },\n payload: {\n subject: \"New encoding: #{self.description}\",\n author: self.user_id.to_s,\n message: forum_message_template,\n tags: combined_tags.blank? ? \"encoding\" : combined_tags.join(',')\n }\n )\n if response.code == 200 && obj = JSON.parse(response.to_str)\n self.update_attribute(:forum_url, obj[\"url\"])\n end\n rescue Timeout::Error => e\n nil\n rescue => e\n nil\n end\n end", "def create\n @fornecedor = Fornecedor.new(fornecedor_params)\n\n respond_to do |format|\n if @fornecedor.save\n format.html { redirect_to @fornecedor, notice: 'Fornecedor cadastrao com sucesso.' }\n format.json { render :show, status: :created, location: @fornecedor }\n else\n format.html { render :new }\n format.json { render json: @fornecedor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fornecedor_contato = FornecedorContato.new(fornecedor_contato_params)\n\n respond_to do |format|\n if @fornecedor_contato.save\n format.html { redirect_to @fornecedor_contato, notice: 'Fornecedor contato was successfully created.' }\n format.json { render :show, status: :created, location: @fornecedor_contato }\n else\n format.html { render :new }\n format.json { render json: @fornecedor_contato.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @comentario = @comentavel.comentarios.create(comentario_params)\n @comentario.usuario = current_user\n respond_to do |format|\n if @comentario.save\n response_successfully(format, produto, 'Comentario was successfully created.', :show, :created)\n else\n response_unsuccessfully(format, :new, @comentario, :unprocessable_entity)\n end\n end\n end", "def create\n @intranet_contribuicao = Intranet::Contribuicao.new(intranet_contribuicao_params)\n\n respond_to do |format|\n if @intranet_contribuicao.save\n format.html { redirect_to @intranet_contribuicao, notice: \"Contribuicao was successfully created.\" }\n format.json { render :show, status: :created, location: @intranet_contribuicao }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @intranet_contribuicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @consorcio = Consorcio.new(consorcio_params)\n\n respond_to do |format|\n if @consorcio.save\n format.html { redirect_to @consorcio, notice: 'Consorcio was successfully created.' }\n format.json { render :show, status: :created, location: @consorcio }\n else\n format.html { render :new }\n format.json { render json: @consorcio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @conta = Conta.new(conta_params)\n\n # @conta.correntista = Correntista.find(params[:id])\n respond_to do |format|\n if @conta.save\n format.html { redirect_to correntista_conta_index_path, notice: 'Conta was successfully created.' }\n format.json { render :show, status: :created, location: @conta }\n else\n format.html { render :new }\n format.json { render json: @conta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @condominio = Condominio.new(condominio_params)\n\n respond_to do |format|\n if @condominio.save\n format.html { redirect_to @condominio, notice: 'Condominio was successfully created.' }\n format.json { render :show, status: :created, location: @condominio }\n else\n format.html { render :new }\n format.json { render json: @condominio.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @comentarios_admin = ComentariosAdmin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comentarios_admin }\n end\n end", "def create\n @conteo = Conteo.new(conteo_params)\n\n respond_to do |format|\n if @conteo.save\n format.html { redirect_to @conteo, notice: 'Conteo was successfully created.' }\n format.json { render :show, status: :created, location: @conteo }\n else\n format.html { render :new }\n format.json { render json: @conteo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categoriafinaceiro = Categoriafinaceiro.new(categoriafinaceiro_params)\n\n respond_to do |format|\n if @categoriafinaceiro.save\n format.html { redirect_to @categoriafinaceiro, notice: 'Categoria cadastrada com sucesso.' }\n format.json { render :show, status: :created, location: @categoriafinaceiro }\n else\n format.html { render :new }\n format.json { render json: @categoriafinaceiro.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @colaborador = Colaborador.new(params[:colaborador])\n\n respond_to do |format|\n if @colaborador.save\n format.html { redirect_to @colaborador, notice: 'Colaborador was successfully created.' }\n format.json { render json: @colaborador, status: :created, location: @colaborador }\n else\n format.html { render action: \"new\" }\n format.json { render json: @colaborador.errors, status: :unprocessable_entity }\n end\n end\n end", "def comentaris\n idUser = 0\n if @usersController.isValidApiToken(getApiKey)\n idUser = @usersController.getUserByApiToken(getApiKey).id\n end\n idContribucio = params[:id]\n @comments = @contribucionsController.getComentarisContribucioApi(idContribucio,idUser)\n resultListFind(@comments)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /forum_comentarios/1 PATCH/PUT /forum_comentarios/1.json
def update if @forum_comentario.update(forum_comentario_params) @forum_comentario = ForumComentario.where(forum_id: @forum_comentario.forum_id) else respond_to do |format| format.js { render :edit } format.json { render json: @forum_comentario.errors, status: :unprocessable_entity } end end end
[ "def UpdateForum id,params = {}\n \n APICall(path: \"forums/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end", "def update\n @comentarios_admin = ComentariosAdmin.find(params[:id])\n\n respond_to do |format|\n if @comentarios_admin.update_attributes(params[:comentarios_admin])\n format.html { redirect_to @comentarios_admin, notice: 'Comentarios admin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comentarios_admin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @company_forum = CompanyForum.find(params[:id])\n\n respond_to do |format|\n if @company_forum.update_attributes(company_forum_params)\n format.html { redirect_to @company_forum, notice: 'Company forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company_forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @forum = Forum.find(params[:id])\r\n respond_to do |format|\r\n if @forum.update(forum_params)\r\n\r\n format.json { render :show, status: :ok, location: @forum }\r\n else\r\n\r\n format.json { render json: @forum.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to forums_path, notice: t('.success') }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to forums_path, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @colaborador = Colaborador.find(params[:id])\n\n respond_to do |format|\n if @colaborador.update_attributes(params[:colaborador])\n format.html { redirect_to @colaborador, notice: 'Colaborador was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @colaborador.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: I18n.t(\"forums.updated_success\") }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @forum_section = ForumSection.find(params[:id])\n\n respond_to do |format|\n if @forum_section.update_attributes(params[:forum_section])\n format.html { redirect_to @forum_section, :notice => 'Forum section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @forum_section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @condominios = Condominio.find(params[:id])\n\n respond_to do |format|\n if @condominios.update_attributes(params[:condominio])\n format.html { redirect_to @condominios, notice: 'Condominio was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @condominios.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forumm.update(forumm_params)\n format.html { redirect_to @forumm, notice: 'Forumm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forumm.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @company_forum_topic = CompanyForumTopic.find(params[:id])\n\n respond_to do |format|\n if @company_forum_topic.update_attributes(company_forum_topic_params)\n format.html { redirect_to @company_forum_topic, notice: 'Company forum topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company_forum_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @consumo = Consumo.find(params[:id])\n\n respond_to do |format|\n if @consumo.update_attributes(params[:consumo])\n format.html { redirect_to @consumo.cliente, :notice => 'Consumo alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @consumo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cate_forum.update(cate_forum_params)\n format.html { redirect_to @cate_forum, notice: \"Cate forum was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cate_forum }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @cate_forum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fornecedor_contato.update(fornecedor_contato_params)\n format.html { redirect_to @fornecedor_contato, notice: 'Fornecedor contato was successfully updated.' }\n format.json { render :show, status: :ok, location: @fornecedor_contato }\n else\n format.html { render :edit }\n format.json { render json: @fornecedor_contato.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contribuicao.update(contribuicao_params)\n format.html { redirect_to @contribuicao, notice: 'Contribuicao alterada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contribuicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @frequenciaaluno.update(frequenciaaluno_params)\n format.html { redirect_to @frequenciaaluno, notice: 'Frequenciaaluno was successfully updated.' }\n format.json { render :show, status: :ok, location: @frequenciaaluno }\n else\n format.html { render :edit }\n format.json { render json: @frequenciaaluno.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @comentario = current_user.comentarios.find(params[:comentario])\n\n respond_to do |format|\n if @comentario.update_attributes(params[:id])\n format.html { redirect_to @comentario, notice: 'Comentario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comentario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @cfo.update_attributes(params[:cfo])\n format.html { redirect_to cfos_url, notice: 'ЦФО обновлён.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cfo.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /forum_comentarios/1 DELETE /forum_comentarios/1.json
def destroy authorize! :destroy, ForumComentario @forum = @forum_comentario.forum_id @forum_comentario.destroy if @forum_comentario.destroy @forum_comentario = ForumComentario.where(forum_id: @forum) end end
[ "def DeleteForum id\n \n APICall(path: \"forums/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @forumm.destroy\n respond_to do |format|\n format.html { redirect_to forumms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @company_forum = CompanyForum.find(params[:id])\n @company_forum.destroy\n\n respond_to do |format|\n format.html { redirect_to company_forums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cate_forum.destroy\n respond_to do |format|\n format.html { redirect_to cate_forums_url, notice: \"Cate forum was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @comentarios_admin = ComentariosAdmin.find(params[:id])\n @comentarios_admin.destroy\n\n respond_to do |format|\n format.html { redirect_to comentarios_admins_url }\n format.json { head :no_content }\n end\n end", "def delete_forum id\n\t\t\t\t\tFreshdesk::Api::Client.delete_status_wrapper do\n\t\t\t\t\t\t( @connection.delete FORUMS, id ).code\n\t\t\t\t\tend\n\t\t\t\tend", "def destroy\n @forum_category.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_categories_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @company_forum_topic = CompanyForumTopic.find(params[:id])\n @company_forum_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to company_forum_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @condominios = Condominio.find(params[:id])\n @condominios.destroy\n\n respond_to do |format|\n format.html { redirect_to condominia_url }\n format.json { head :ok }\n end\n end", "def destroy\n @forum_category.destroy\n respond_to do |format|\n format.html { redirect_to forum_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concedente = Concedente.find(params[:id])\n @concedente.destroy\n\n respond_to do |format|\n format.html { redirect_to concedentes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @thread_forum = ThreadForum.find(params[:id])\n @thread_forum.destroy\n\n respond_to do |format|\n format.html { redirect_to thread_forums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @comunidad.destroy\n respond_to do |format|\n format.html { redirect_to comunidades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum_section = ForumSection.find(params[:id])\n @forum_section.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forum_message.destroy\n respond_to do |format|\n format.html { redirect_to forum_messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @colaborador = Colaborador.find(params[:id])\n @colaborador.destroy\n\n respond_to do |format|\n format.html { redirect_to colaboradores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forums_forum = Forums::Forum.find(params[:id])\n @forums_forum.destroy\n\n respond_to do |format|\n format.html { redirect_to(forums_root_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @concedente.destroy\n respond_to do |format|\n format.html { redirect_to concedentes_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Get the number of lines of context padding. This may be overridden with the environment variable DEPRECATABLE_CALLER_CONTEXT_PADDING. Returns the Integer number of context padding lines.
def caller_context_padding p = ENV['DEPRECATABLE_CALLER_CONTEXT_PADDING'] if p then p = Float(p).to_i raise ArgumentError, "DEPRECATABLE_CALLER_CONTEXT_APDDING must have a value > 0, it is currently #{p}" unless p > 0 return p end return @caller_context_padding end
[ "def formatted_context_lines\n if @formatted_context_lines.empty? then\n number_width = (\"%d\" % @context_line_numbers.last).length\n @context_lines.each_with_index do |line, idx|\n prefix = (idx == @context_index) ? CallSiteContext.pointer : CallSiteContext.not_pointer\n number = (\"%d\" % @context_line_numbers[idx]).rjust( number_width )\n @formatted_context_lines << \"#{prefix} #{number}: #{line}\"\n end\n end\n return @formatted_context_lines\n end", "def padding_width\n @example_count.to_s.length * 2 + 6\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 num_ctx_switches\n @proc.num_ctx_switches\n end", "def indented_spaces\n # Find out how many spaces exist at the beginning of the line\n spaces = self.scan(/^\\x20+/).first\n\n unless spaces.nil?\n return spaces.length\n end\n\n 0\n end", "def padding_size\n padding = renderer.padding\n (padding.left + padding.right) * table.columns_count\n end", "def indentation_size\n # TODO marker\n pos = @code_editor.script.rindex(\"\\n\", @code_para.cursor-1)\n return 0 if pos.nil?\n\n pos += 1\n ind_size = 0\n while @code_editor.script[pos, 1] == ' '\n ind_size += 1\n pos += 1\n end\n ind_size\n end", "def formatted_context_lines\n context.formatted_context_lines\n end", "def maatsf_total_line_width(y = 0)\n contents_width\n end", "def len_padding\n return @len_padding unless @len_padding.nil?\n @len_padding = (has_padding ? len_padding_if_exists : 0)\n @len_padding\n end", "def maatsf_total_line_width(y = 0)\n contents_width - new_line_x\n end", "def line_count\n prog_order.length\n end", "def line_depth(line)\n whitespace = line.scan(/^([\\s]+)/).flatten.first\n if whitespace\n whitespace.length\n else\n 0\n end\n end", "def list_indent_level\n @list_indent_stack.length\n end", "def get_indent(context_lines)\r\n cl = context_lines.dup\r\n while true\r\n return ' ' if cl.size < 2 # default indentation is 2 spaces\r\n indent = get_line_indent(cl.last)[get_line_indent(cl.delete_at(-2)).size..-1]\r\n return indent unless indent.nil? || indent.empty?\r\n end\r\n end", "def line_count\n entries.inject(0) do |count, entry|\n count + (entry.dir? ? 0 : entry.lines.size)\n end\n end", "def count\n line_count\n end", "def default_line_number\n return current_layout.line_count\n end", "def _total_padding(sections1, sections2)\n sections1 ||= []\n sections2 ||= []\n [sections1, sections1].map(&:length).max.times.sum do |i|\n # Add 2 lines to each additional section: 1 for the extra padding, and 1\n # for the extra margin.\n [\n (sections1[i] || \"\").lines.count,\n (sections2[i] || \"\").lines.count\n ].max + 2\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Set the maximum number of times an alert for a unqiue CallSite of a DeprecatedMethod will be emitted. (default: :once) That is, when a deprecated method is called from a particular CallSite, normally an 'alert' is sent. This setting controls the maximum number of times that the 'alert' for a particular CallSite is emitted. freq The alert frequency. This may be set to any number, or to one of the special token values: :never Never send any alerts :once Send an alert for a given CallSite only once. :always Send an alert for every invocation of the DeprecatedMethod. Returns the alert_frequency.
def alert_frequency=( freq ) @alert_frequency = frequency_of( freq ) end
[ "def alert_frequency\n p = ENV['DEPRECATABLE_ALERT_FREQUENCY']\n return frequency_of(p) if p\n return @alert_frequency\n end", "def freq=(freq_value)\n reset_errors\n @freq = freq_value\n end", "def frequency\n Morrow.config.update_interval\n end", "def alert( call_site )\n if call_site.invocation_count <= ::Deprecatable.options.alert_frequency then\n ::Deprecatable.alerter.alert( self, call_site )\n end\n end", "def freq(f=false)\n if f\n @dial_freq=f-@carrier\n else\n # If the last time we checked the dial frequency is more than\n # @fexpire seconds ago, re-read the frequency and update the\n # timestamp.\n if Time.now().to_i-@ftime>@fexpire\n @dial_freq=(self.radio_freq()+self.get_carrier()).to_i\n @ftime=Time.now().to_i\n end\n return (@dial_freq+self.get_carrier()).to_i\n end\n end", "def malware_detected_device_count=(value)\n @malware_detected_device_count = value\n end", "def set_frequency(frequency)\r\n update(frequency: frequency)\r\n end", "def max_freq\n\t\t\t\t@@max_freqs ||= Dir[\"/sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_max_freq\"]\n\t\t\t\t@@max_freqs_readable ||= @@max_freqs.all?(&File.method(:readable?))\n\n\t\t\t\tif @@max_freqs_readable\n\t\t\t\t\t@@max_freqs.map { |x| IO.read(x).to_i }\n\t\t\t\telse\n\t\t\t\t\t[]\n\t\t\t\tend\n\t\t\tend", "def setup_frequency(frequency = DEFAULT_FREQUENCY)\n @frequency = Integer(frequency)\n end", "def deprecated_method_report( dm, call_site = nil )\n m = \"`#{dm.klass}##{dm.method}`\"\n lines = [ m ]\n lines << \"-\" * m.length\n lines << \"\"\n lines << \"* Originally defined at #{dm.file}:#{dm.line_number}\"\n\n if msg = dm.message then\n lines << \"* #{msg}\"\n end\n if rd = dm.removal_date then\n lines << \"* Will be removed after #{rd}\"\n end\n\n if rv = dm.removal_version then\n lines << \"* Will be removed in version #{rv}\"\n end\n lines << \"\"\n\n if call_site then\n lines += call_site_report( call_site )\n else\n dm.call_sites.each do |cs|\n lines += call_site_report( cs, true )\n end\n end\n return lines\n end", "def frequency_interval=(value)\n @frequency_interval = value\n end", "def frequency=(freq)\n @rrule.setFreq(freq)\n self\n end", "def changefreq\n return self.defaults[:changefreq]\n end", "def frequency\n FREQUENCY\n end", "def frequency_supports_frequency_modifier?\n # these are the only ones that don't\n !%w{once on_logon onstart on_idle}.include?(new_resource.frequency)\n end", "def get_alert_frequency(hostname, service = nil, options = {})\n duration = options[:duration] ? options[:duration] : 7\n\n max_results = options[:max_results] ? options[:max_results] : 10000\n\n latest_time = options[:latest_time] ? options[:latest_time] :\"now\"\n\n params = {\n 'exec_mode' => 'oneshot',\n 'earliest_time' => \"-#{duration}d\",\n 'latest_time' => latest_time,\n 'output_mode' => 'json',\n 'count' => max_results\n }\n\n params['search'] = get_splunk_alert_query(hostname, service)\n\n json_response = query_splunk(params)\n\n return if json_response.nil?\n\n events_count = aggregate_splunk_events(json_response)\n\n duration.to_i > 1 ? period = \"days\" : period = \"day\"\n return {\n :period => \"#{duration} #{period}\",\n :service => service,\n :hostname => hostname,\n :events_count => events_count\n }\n end", "def frequency=( freq )\n @frequency = freq.to_i\n @frequency_data = FREQUENCY[ @frequency ]\n end", "def frequency=( freq )\n @frequency = freq.to_i\n @frequency_data = FREQUENCY[ @frequency ].dup\n end", "def user_reaccept_required_frequency\n return @user_reaccept_required_frequency\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Get the current value of the alert_frequency. This may be overridden with the environment variable DEPRECATABLE_ALERT_FREQUENCY. Returns the Integer value representing the alert_frequency.
def alert_frequency p = ENV['DEPRECATABLE_ALERT_FREQUENCY'] return frequency_of(p) if p return @alert_frequency end
[ "def alert_frequency=( freq )\n @alert_frequency = frequency_of( freq )\n end", "def frequency\n temp = 0.chr * 4\n @fmod.invoke('Channel_GetFrequency', @handle, temp)\n return @fmod.unpackFloat(temp)\n end", "def get_alert_frequency(hostname, service = nil, options = {})\n duration = options[:duration] ? options[:duration] : 7\n\n max_results = options[:max_results] ? options[:max_results] : 10000\n\n latest_time = options[:latest_time] ? options[:latest_time] :\"now\"\n\n params = {\n 'exec_mode' => 'oneshot',\n 'earliest_time' => \"-#{duration}d\",\n 'latest_time' => latest_time,\n 'output_mode' => 'json',\n 'count' => max_results\n }\n\n params['search'] = get_splunk_alert_query(hostname, service)\n\n json_response = query_splunk(params)\n\n return if json_response.nil?\n\n events_count = aggregate_splunk_events(json_response)\n\n duration.to_i > 1 ? period = \"days\" : period = \"day\"\n return {\n :period => \"#{duration} #{period}\",\n :service => service,\n :hostname => hostname,\n :events_count => events_count\n }\n end", "def frequency_interval\n return @frequency_interval\n end", "def frequency\n FREQUENCY\n end", "def changefreq\n return self.defaults[:changefreq]\n end", "def alert_threshold\n return @alert_threshold\n end", "def freq(f=false)\n if f\n @dial_freq=f-@carrier\n else\n # If the last time we checked the dial frequency is more than\n # @fexpire seconds ago, re-read the frequency and update the\n # timestamp.\n if Time.now().to_i-@ftime>@fexpire\n @dial_freq=(self.radio_freq()+self.get_carrier()).to_i\n @ftime=Time.now().to_i\n end\n return (@dial_freq+self.get_carrier()).to_i\n end\n end", "def get_ambient_temperature_callback_period\n send_request(FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD, [], '', 4, 'L')\n end", "def frequency\n Morrow.config.update_interval\n end", "def frequency\n growth_rate = 2 ** (1.0 / 12)\n frequency = 440 * (growth_rate ** semitones_from_A4)\n frequency.round(3)\n end", "def get_preferences_frequency_list\n perform(:get, 'preferences/notification/list', nil, token_headers).body\n end", "def frequency_name\n FREQUENCY_NAMES[frequency]\n end", "def alert_type\n return @alert_type\n end", "def installment_frequency_in_days\n case installment_frequency\n when :weekly\n 7\n when :daily\n 1\n when :monthly\n 30\n when :bi_weekly\n 15\n end\n end", "def frequency_interval=(value)\n @frequency_interval = value\n end", "def freq_peaks\n return frequency_domain.peaks\n end", "def get_mfa_frequency(setting)\n setting[:mfa_type] == 0 ? 0 : setting[:mfa_frequency].to_i.days.to_i\n end", "def audio_input_frequency\n @audio_input_freq\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Say whether or not the final at exit report shall be emitted. This may be overridden by the environment variable DEPRECATABLE_HAS_AT_EXIT_REPORT. Setting the environment variable to 'true' will override the existing setting. Returns the boolean of whether or not the exti report should be done.
def has_at_exit_report? return true if ENV['DEPRECATABLE_HAS_AT_EXIT_REPORT'] == "true" return @has_at_exit_report end
[ "def should_run_on_exit?\n return false if ENV[\"KINTAMA_EXPLICITLY_DONT_RUN\"]\n return test_file_was_run? || run_via_rake?\n end", "def is_entry_exit_announced\n return @is_entry_exit_announced\n end", "def reporting?\n @reporting\n end", "def exitable?\n @exitable\n end", "def early_exit?\n component.exit_type == :EARLY_EXIT\n end", "def is_entry_exit_announced=(value)\n @is_entry_exit_announced = value\n end", "def report_only?\n !!@report_only\n end", "def generated?\n !report_file.nil?\n end", "def exit?\n @exit\n end", "def should_report?\n !@reporter.report_currency or !@external or (@original_currency||currency) == @reporter.report_currency\n end", "def exit?\n @exit\n end", "def exit_on_help? #:nodoc:\n @@exit rescue false\n end", "def exit_on_error?\n @on_error == :exit\n end", "def at_exit_handler_installed?\n @exit_handler_added ||= false\n end", "def should_print?\n !@suppress_output\n end", "def reports?\n !reports.empty?\n end", "def shutdown_when_done?\n !!runopts(:shutdown_when_done)\n end", "def done?\n !!@exitstatus\n end", "def have_quiet_prototype?\n ! @have_quiet_prototype.nil?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /customersessions GET /customersessions.json
def index @customersessions = Customersession.all end
[ "def show\n @session = @client.sessions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @session }\n end\n end", "def show\n # /checkout_sessions/<id>\n checkout_session = Stripe::Checkout::Session.retrieve(params[:id])\n render json: checkout_session\n end", "def index\n @user_sessions = UserSession.all\n\n render json: @user_sessions, root: false\n end", "def get_customer_profile\n authenticate_request!\n json_response(current_customer)\n end", "def index\n @session_resources = SessionResource.all\n\n render json: @session_resources\n end", "def index\n @user_session_tokens = UserSessionToken.all\n\n render json: @user_session_tokens\n end", "def export_customer_sessions_with_http_info(application_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementApi.export_customer_sessions ...'\n end\n # verify the required parameter 'application_id' is set\n if @api_client.config.client_side_validation && application_id.nil?\n fail ArgumentError, \"Missing the required parameter 'application_id' when calling ManagementApi.export_customer_sessions\"\n end\n allowable_values = [\"excel\", \"ISO8601\"]\n if @api_client.config.client_side_validation && opts[:'date_format'] && !allowable_values.include?(opts[:'date_format'])\n fail ArgumentError, \"invalid value for \\\"date_format\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"open\", \"closed\", \"partially_returned\", \"cancelled\"]\n if @api_client.config.client_side_validation && opts[:'customer_session_state'] && !allowable_values.include?(opts[:'customer_session_state'])\n fail ArgumentError, \"invalid value for \\\"customer_session_state\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/v1/applications/{applicationId}/export_customer_sessions'.sub('{' + 'applicationId' + '}', CGI.escape(application_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'createdBefore'] = opts[:'created_before'] if !opts[:'created_before'].nil?\n query_params[:'createdAfter'] = opts[:'created_after'] if !opts[:'created_after'].nil?\n query_params[:'profileIntegrationId'] = opts[:'profile_integration_id'] if !opts[:'profile_integration_id'].nil?\n query_params[:'dateFormat'] = opts[:'date_format'] if !opts[:'date_format'].nil?\n query_params[:'customerSessionState'] = opts[:'customer_session_state'] if !opts[:'customer_session_state'].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/csv'])\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] || 'String' \n\n # auth_names\n auth_names = opts[:auth_names] || ['management_key', 'manager_auth']\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: ManagementApi#export_customer_sessions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @csessions = Csession.all\n end", "def customer_list\n perform_get_request('/customer/list')\n end", "def index\n sessions = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/sessions\"\n ).body\n end\n styled_header(\"OAuth Sessions\")\n styled_array(sessions.map { |session|\n [session[\"description\"], session[\"id\"]]\n })\n end", "def show\n render json: @session_resource\n end", "def list_sessions\n response = send(op:\"ls-sessions\").first\n response[\"sessions\"]\n end", "def get_customer_session_with_http_info(customer_session_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: IntegrationApi.get_customer_session ...'\n end\n # verify the required parameter 'customer_session_id' is set\n if @api_client.config.client_side_validation && customer_session_id.nil?\n fail ArgumentError, \"Missing the required parameter 'customer_session_id' when calling IntegrationApi.get_customer_session\"\n end\n # resource path\n local_var_path = '/v2/customer_sessions/{customerSessionId}'.sub('{' + 'customerSessionId' + '}', CGI.escape(customer_session_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\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] || 'IntegrationCustomerSessionResponse' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key_v1']\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: IntegrationApi#get_customer_session\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def export_customer_sessions(application_id, opts = {})\n data, _status_code, _headers = export_customer_sessions_with_http_info(application_id, opts)\n data\n end", "def index\n @canning_sessions = CanningSession.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @canning_sessions }\n end\n end", "def list_sessions(user_id:)\n path = '/users/{userId}/sessions'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::SessionList\n )\n end", "def index\n @api_v1_mentorship_sessions = Api::V1::MentorshipSession.all\n end", "def index\n @tsessions = Tsession.all\n session[:return_to] = request.fullpath\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tsessions }\n end\n end", "def active_sessions\n render json: Session.where(\"active = ?\", true)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /customersessions POST /customersessions.json
def create @customersession = Customersession.new(customersession_params) respond_to do |format| if @customersession.save format.html { redirect_to @customersession, notice: 'Customersession was successfully created.' } format.json { render :show, status: :created, location: @customersession } else format.html { render :new } format.json { render json: @customersession.errors, status: :unprocessable_entity } end end end
[ "def create\n @user_session = UserSession.new(user_session_params)\n\n if @user_session.save\n render json: @user_session, status: :created, location: @user_session\n else\n render json: @user_session.errors, status: :unprocessable_entity\n end\n end", "def create\n @session = Session.new(session_params)\n\n if @session.save\n render json: @session, status: :created, location: @session\n else\n render json: @session.errors, status: :unprocessable_entity\n end\n end", "def create\n @session = Session.new(params[:session])\n\n if @session.save\n render json: @session, status: :created, location: @session\n else\n render json: @session.errors, status: :unprocessable_entity\n end\n end", "def index\n @customersessions = Customersession.all\n end", "def export_customer_sessions_with_http_info(application_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementApi.export_customer_sessions ...'\n end\n # verify the required parameter 'application_id' is set\n if @api_client.config.client_side_validation && application_id.nil?\n fail ArgumentError, \"Missing the required parameter 'application_id' when calling ManagementApi.export_customer_sessions\"\n end\n allowable_values = [\"excel\", \"ISO8601\"]\n if @api_client.config.client_side_validation && opts[:'date_format'] && !allowable_values.include?(opts[:'date_format'])\n fail ArgumentError, \"invalid value for \\\"date_format\\\", must be one of #{allowable_values}\"\n end\n allowable_values = [\"open\", \"closed\", \"partially_returned\", \"cancelled\"]\n if @api_client.config.client_side_validation && opts[:'customer_session_state'] && !allowable_values.include?(opts[:'customer_session_state'])\n fail ArgumentError, \"invalid value for \\\"customer_session_state\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/v1/applications/{applicationId}/export_customer_sessions'.sub('{' + 'applicationId' + '}', CGI.escape(application_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'createdBefore'] = opts[:'created_before'] if !opts[:'created_before'].nil?\n query_params[:'createdAfter'] = opts[:'created_after'] if !opts[:'created_after'].nil?\n query_params[:'profileIntegrationId'] = opts[:'profile_integration_id'] if !opts[:'profile_integration_id'].nil?\n query_params[:'dateFormat'] = opts[:'date_format'] if !opts[:'date_format'].nil?\n query_params[:'customerSessionState'] = opts[:'customer_session_state'] if !opts[:'customer_session_state'].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/csv'])\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] || 'String' \n\n # auth_names\n auth_names = opts[:auth_names] || ['management_key', 'manager_auth']\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: ManagementApi#export_customer_sessions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @session_resource = SessionResource.new(session_resource_params)\n\n if @session_resource.save\n render json: @session_resource, status: :created, location: @session_resource\n else\n render json: @session_resource.errors, status: :unprocessable_entity\n end\n end", "def create\n @csession = Csession.new(csession_params)\n\n respond_to do |format|\n if @csession.save\n format.html { redirect_to @csession, notice: 'Csession was successfully created.' }\n format.json { render :show, status: :created, location: @csession }\n else\n format.html { render :new }\n format.json { render json: @csession.errors, status: :unprocessable_entity }\n end\n end\n end", "def fresh_customer\n Billingly::Customer.create!.tap do |customer|\n session[:customer_id] = customer.id\n end\n end", "def create\n @session = SessionService.new(current_user).create_from_web! session_params\n\n respond_to do |format|\n format.html { redirect_to @session, notice: 'Session was successfully created.' }\n format.json { render json: @session, status: :created }\n end\n end", "def create\n @user_session_token = UserSessionToken.new(user_session_token_params)\n\n if @user_session_token.save\n render json: @user_session_token, status: :created, location: @user_session_token\n else\n render json: @user_session_token.errors, status: :unprocessable_entity\n end\n end", "def create\n @session_accedian = SessionAccedian.create(SessionAccedian.all_sessions_endpoint)\n end", "def create\n @current_session = CurrentSession.new(params[:current_session])\n\n if @current_session.save\n render json: @current_session, status: :created, location: @current_session\n else\n render json: @current_session.errors, status: :unprocessable_entity\n end\n end", "def create\n @cashier_session = CashierSession.new(params[:cashier_session])\n\n respond_to do |format|\n if @cashier_session.save\n format.html { redirect_to(:home, :notice => 'Cashier session was successfully created.') }\n format.json { render json: @cashier_session, status: :created, location: @cashier_session }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cashier_session.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ykt_session = YktSession.new(params[:ykt_session])\n\n respond_to do |format|\n if @ykt_session.save\n format.html { redirect_to @ykt_session, notice: 'Ykt session was successfully created.' }\n format.json { render json: @ykt_session, status: :created, location: @ykt_session }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ykt_session.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_session = UserSession.new(params[:user_session])\n\n respond_to do |format|\n if @user_session.save\n format.html { redirect_to root_path, notice: 'User session was successfully created.' }\n format.json { render json: @user_session, status: :created, location: @user_session }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_session.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client_session = ClientSession.new(params[:client_session])\n\n respond_to do |format|\n if @client_session.save\n format.html { redirect_to(@client_session, :notice => 'Client session was successfully created.') }\n format.xml { render :xml => @client_session, :status => :created, :location => @client_session }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client_session.errors, :status => :unprocessable_entity }\n end\n end\n end", "def customer_signup\n customer = Customer.new(customer_params)\n if customer.save\n # The following methods belong to Knock::AuthTokenController\n # See https://github.com/nsarno/knock/blob/master/app/controllers/knock/auth_token_controller.rb\n authenticate\n create\n else\n render json: customer.errors.full_messages, status: :unprocessable_entity\n end\n end", "def customer_log_in_as(customer)\n session[:customer_id] = customer.id\n end", "def update\n respond_to do |format|\n if @customersession.update(customersession_params)\n format.html { redirect_to @customersession, notice: 'Customersession was successfully updated.' }\n format.json { render :show, status: :ok, location: @customersession }\n else\n format.html { render :edit }\n format.json { render json: @customersession.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /customersessions/1 PATCH/PUT /customersessions/1.json
def update respond_to do |format| if @customersession.update(customersession_params) format.html { redirect_to @customersession, notice: 'Customersession was successfully updated.' } format.json { render :show, status: :ok, location: @customersession } else format.html { render :edit } format.json { render json: @customersession.errors, status: :unprocessable_entity } end end end
[ "def update\n #@session = @client.sessions.update!(session_params)\n\n respond_to do |format|\n if @session.update(session_params)\n format.html { redirect_to client_url(@client), notice: 'Session was successfully updated.' }\n format.json { render :show, status: :ok, location: @session }\n else\n format.html { render :edit }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sequoia_customer.update(sequoia_customer_params)\n format.html { redirect_to @sequoia_customer, notice: 'Sequoia customer was successfully updated.' }\n format.json { render :show, status: :ok, location: @sequoia_customer }\n else\n format.html { render :edit }\n format.json { render json: @sequoia_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @self_customer.customer = @self_customer.update_attributes_customer(customer_params)\n respond_to do |format|\n # success = @self_customer.transaction do\n # @self_customer.customer.update_attributes(customer_params)\n # @self_customer.update_attributes(self_customer_params)\n # end\n if @self_customer.update(self_params)\n format.html { redirect_to @self_customer }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @self_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_customer_profile\n authenticate_request!\n current_customer.assign_attributes(customer_update_params)\n\n if current_customer.save!\n json_response(current_customer)\n else\n json_response({ errors: customer.errors.full_messages }, status: :bad_request)\n end\n end", "def update_customer(id, data)\n put(\"customers/#{id}\", { body: data })\n end", "def update\n @instant_customer = InstantCustomer.find(params[:id])\n\n respond_to do |format|\n if @instant_customer.update_attributes(params[:instant_customer])\n format.html { redirect_to action: :index}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instant_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client_session = ClientSession.find(params[:id])\n\n respond_to do |format|\n if @client_session.update_attributes(params[:client_session])\n format.html { redirect_to(@client_session, :notice => 'Client session was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client_session.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @csession.update(csession_params)\n format.html { redirect_to @csession, notice: 'Csession was successfully updated.' }\n format.json { render :show, status: :ok, location: @csession }\n else\n format.html { render :edit }\n format.json { render json: @csession.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer_view_control.update(customer_view_control_params)\n @customer_view_control.update(:updated_by=>session[:kitchen_user_id])\n format.html { redirect_to action: \"index\", notice: 'Customer view control was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer_view_control }\n else\n format.html { render :edit }\n format.json { render json: @customer_view_control.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customersp.update(customersp_params)\n format.html { redirect_to @customersp, notice: 'Customersp was successfully updated.' }\n format.json { render :show, status: :ok, location: @customersp }\n else\n format.html { render :edit }\n format.json { render json: @customersp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customer_request.update(customer_request_params)\n format.html { redirect_to @customer_request, notice: 'Customer request was successfully updated.' }\n format.json { render :show, status: :ok, location: @customer_request }\n else\n format.html { render :edit }\n format.json { render json: @customer_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @self_service_customer = SelfService::Customer.find(params[:id])\n\n respond_to do |format|\n if @self_service_customer.update_attributes(params[:self_service_customer])\n format.html { redirect_to(@self_service_customer, :notice => 'Customer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @self_service_customer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @session_resource = SessionResource.find(params[:id])\n\n if @session_resource.update(session_resource_params)\n head :no_content\n else\n render json: @session_resource.errors, status: :unprocessable_entity\n end\n end", "def update_rest\n @instrument_session = InstrumentSession.find(params[:id])\n\n respond_to do |format|\n if @instrument_session.update_attributes(params[:instrument_session])\n flash[:notice] = 'InstrumentSession was successfully updated.'\n format.html { redirect_to(@instrument_session) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_session.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_customer_session_v2_with_http_info(customer_session_id, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: IntegrationApi.update_customer_session_v2 ...'\n end\n # verify the required parameter 'customer_session_id' is set\n if @api_client.config.client_side_validation && customer_session_id.nil?\n fail ArgumentError, \"Missing the required parameter 'customer_session_id' when calling IntegrationApi.update_customer_session_v2\"\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling IntegrationApi.update_customer_session_v2\"\n end\n # resource path\n local_var_path = '/v2/customer_sessions/{customerSessionId}'.sub('{' + 'customerSessionId' + '}', CGI.escape(customer_session_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'dry'] = opts[:'dry'] if !opts[:'dry'].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 # 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(body) \n\n # return_type\n return_type = opts[:return_type] || 'IntegrationStateV2' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key_v1']\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(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: IntegrationApi#update_customer_session_v2\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n @ykt_session = YktSession.find(params[:id])\n\n respond_to do |format|\n if @ykt_session.update_attributes(params[:ykt_session])\n format.html { redirect_to @ykt_session, notice: 'Ykt session was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ykt_session.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @session = @event.sessions.find(params[:id])\n\n respond_to do |format|\n if @session.update_attributes(params[:session])\n format.html { redirect_to [@event, @session], notice: 'Session was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n respond_to do |format|\n if @rcadmin_customer.update(rcadmin_customer_params)\n flash[:notice] = 'Customer was successfully updated.'\n format.html { redirect_to rcadmin_customers_url, notice: 'Customer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rcadmin_customer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_session = UserSession.find(params[:id])\n\n if @user_session.update(user_session_params)\n head :no_content\n else\n render json: @user_session.errors, status: :unprocessable_entity\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /customersessions/1 DELETE /customersessions/1.json
def destroy @customersession.destroy respond_to do |format| format.html { redirect_to customersessions_url, notice: 'Customersession was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @session = @client.sessions.find(params[:id])\n @session.destroy\n respond_to do |format|\n format.html { redirect_to client_url(@client), notice: 'Session was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_session = ClientSession.find(params[:id])\n @client_session.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_sessions_url) }\n format.xml { head :ok }\n end\n end", "def destroy_rest\n @instrument_session = InstrumentSession.find(params[:id])\n @instrument_session.destroy\n\n respond_to do |format|\n format.html { redirect_to(instrument_sessions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @csession.destroy\n respond_to do |format|\n format.html { redirect_to csessions_url, notice: 'Csession was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ste_customer_history = SteCustomerHistory.find(params[:id])\n @ste_customer_history.destroy\n\n respond_to do |format|\n format.html { redirect_to ste_customer_histories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ykt_session = YktSession.find(params[:id])\n @ykt_session.destroy\n\n respond_to do |format|\n format.html { redirect_to ykt_sessions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sequoia_customer.destroy\n respond_to do |format|\n format.html { redirect_to sequoia_customers_url, notice: 'Sequoia customer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :ok }\n end\n end", "def destroy\n set_session\n\n if @session.destroy\n respond_to do |format|\n format.html { redirect_to batch_connect_sessions_url, notice: t('dashboard.batch_connect_sessions_status_blurb_delete_success') }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to batch_connect_sessions_url, alert: t('dashboard.batch_connect_sessions_status_blurb_delete_failure') }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @s_customer.destroy\n respond_to do |format|\n format.html { redirect_to s_customers_url, notice: 'S customer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tsession.destroy\n respond_to do |format|\n format.html { redirect_to tsessions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer_request.destroy\n respond_to do |format|\n format.html { redirect_to customer_requests_url, notice: 'Customer request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @session = Session.find(params[:id])\n @session.destroy\n\n respond_to do |format|\n format.html { redirect_to sessions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @cashier_session = CashierSession.find\n @cashier_session.destroy\n\n respond_to do |format|\n format.html { redirect_to(:login , :notice => 'Goodbye!') }\n format.json { head :ok }\n end\n end", "def destroy\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to farm_customers_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @instant_customer = InstantCustomer.find(params[:id])\n @instant_customer.destroy\n\n respond_to do |format|\n format.html { redirect_to instant_customers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cust = Cust.find(params[:id])\n @cust.destroy\n\n respond_to do |format|\n format.html { redirect_to custs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_session = UserSession.find(params[:id])\n @user_session.destroy\n\n respond_to do |format|\n format.html { redirect_to user_sessions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to(customers_url) }\n format.json { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
function to update the session and add in cart
def add_in_cart product_id=params[:id].to_i @product=Product.find(product_id) total_request=1 update_through_cart=0 if params.has_key?(:quant) total_request=params[:quant][:total_request].to_i update_through_cart=1 end if(check_availabilty(product_id,total_request,update_through_cart)) update_session(product_id,total_request,update_through_cart) else flash[:notice] = "#{Product.find(product_id).name} is not available in this quantity" end end
[ "def add_to_cart\n \tif session[\"cart\"].nil?\n \t\tsession[\"cart\"] = []\n \tend\n \t#So luong cua san pham add vao gio hang\n \tquantity_ = 1\n \tsession[\"item\"] = {:id => params[:id].to_i, :name => params[:name], :quantity => quantity_.to_i, :price => params[:price].to_i, :total => quantity_.to_i * params[:price].to_i}\n \tcheck_cart session[\"item\"]\n \tredirect_to :back\n end", "def update_session_content\n return\n # Check shopping carts\n guest_cart = ShoppingCart.find_by_id(session[:shopping_cart_id])\n user_cart = current_user.shopping_cart\n if guest_cart.total_items != 0 || user_cart.nil?\n user_cart.destroy if !user_cart.nil?\n guest_cart.update_attribute :user_id, current_user.id\n end\n session[:shopping_cart_id] = nil\n end", "def save\n @session[:cart] = @cart\n end", "def update_quantity_to_cart\n \t\n\n \tproduct_id_ = params[:product_id].to_i\n\n \tsession[\"cart\"].each do |h|\n \t\tif h['id'] == product_id_\n \t\t\th['quantity'] = params[:quantity_update].to_i\n \t\t\th['total'] = h['price'] * h['quantity']\n \t\t\t\n \t\tend\n \tend\n\n \tredirect_to :back\n end", "def add_to_cart\n id = params[:id].to_i\n\n is_in_cart = false\n\n session[:cart].delete(1)\n session[:cart].each do |ct|\n if defined?(ct['id'])\n Product.find(ct['id'].to_i)\n if ct['id'].to_i == id\n\n is_in_cart = true\n ct['quantity'] = ct['quantity'].to_i + 1\n end\n end\n end\n\n if !is_in_cart\n cart_item = {\n id: id,\n quantity: 1\n }\n session[:cart] << cart_item\n end\n redirect_to request.referrer\n end", "def save\n @session[\"store_#{@store.id}\"][:cart_items] = [] # Clear the session\n @cart_items.each_value do |cart_item|\n @session[\"store_#{@store.id}\"][:cart_items] << cart_item.to_s unless cart_item.none?\n end\n end", "def add\n @removewishlistitem\n @hi\n #get product id\n id = params[:id]\n \n #is there a cart already\n if session[:cart] then\n cart = session[:cart]\n else\n session[:cart] = {}\n cart = session[:cart]\n end\n \n #put item in cart\n if cart[id]\n cart[id] = cart[id] + 1\n else\n cart[id] = 1\n end\n \n redirect_to :action => :index\n \n end", "def update_cart(new_cart)\n cookies[:cart] ={value: JSON.generate(new_cart), expires_in: 7.days}\n cookies[:cart]\n end", "def add_to_shopping_cart\n id = params[:id].to_i\n unless session[:product_id].include?(id)\n session[:product_id] << id\n #session[:quantity] << Product.find(params[:id]).price\n end\n\n redirect_to action: 'show', id: params[:id]\n end", "def cart_session_param\n :cart\n end", "def add_order_item_to_cart(order_item)\n # validates :cart exists on session.\n session[:cart] << order_item\n end", "def update_basket_details\n basket.update_details(session)\n end", "def cart_op\n session[:cart] = yield(get_cart)\n end", "def add_by_quantity\n #get product id\n id = params[:id]\n \n #is there a cart already\n if session[:cart] then\n cart = session[:cart]\n else\n session[:cart] = {}\n cart = session[:cart]\n end\n \n #put item in cart\n qty = \"#{params[:qty]}\".to_i\n item = Item.find(params[:id])\n qty_instock = item.quantity_instock\n \n if qty_instock >= qty\n \n if cart[id]\n cart[id] = cart[id] + qty\n else\n cart[id] = qty\n end\n redirect_to :action => :index\n else\n redirect_to @item, notice: 'There are not enough items in stock!'\n \n \n end\n end", "def update\n @carti = Cart.find_by(user_id: current_user.id)\n @itemi = Item.find(params[:id])\n\n\n if current_user\n @carti.items << @itemi\n\n else\n redirect_to new_user_session_path\n end\n\n end", "def create_shopping_cart_with_future_release_date\n @request.session[:shopping_cart] = []\n @request.session[:shopping_cart] << { product_id: products(:future).id, quantity: 1 }\n @request.session[:shopping_cart] << { product_id: products(:whiskey).id, quantity: 2 }\n end", "def setCart(id)\n session[:cart_id] = id\n end", "def cart\n session[:cart]\n end", "def log_in_cart(cart)\n session[:cart_id] = cart.id\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
To view or fill out the form
def form end
[ "def fill_form\n visit \"/\"\n fill_in 'first_name', with: 'Bob'\n fill_in 'last_name', with: 'Smith'\n fill_in 'street', with: '123 Anywhere St.'\n fill_in 'city', with: 'San Diego'\n fill_in 'state', with: 'CA'\n fill_in 'zip', with: '92101'\n fill_in 'country', with: 'USA'\n fill_in 'phone1', with: '555-555-5555'\n fill_in 'email', with: 'bob@home.com'\n fill_in 'username', with: 'BobSmith1'\n fill_in 'password', with: 'pass123word'\n click_button 'Submit'\n end", "def new\n @filled_form = @filled_forms.create\n redirect_to [:edit, :admin, @form, @filled_form] and return\n end", "def the_form( options={}, &proc)\n self.expects(:ubiquo_user_path).returns(\"/ubiquo/users/1\")\n options[:builder] = Ubiquo::Helpers::UbiquoFormBuilder\n user = User.new\n form_for([:ubiquo,user], options, &proc)\n @rendered = \"\"\n end", "def form_setup\n\tend", "def ask_form\n AskForm.new(view_context)\n end", "def preenche_formulario\n\t@name = Faker::Name.name\n \t@email = Faker::Internet.email\n \t@person = Faker::StarWars.character\n\n \tname_field.set(@name)\n \temail_field.set(@email)\t\n \tyes_rdbutton.click\n \tnameMovie_field.set(@person)\n \tpersonFav_field.set(@person)\n \tfavMovie.click\n no_field.click\n sleep 1\nend", "def complete_info_form(data)\n enter_reference_number data\n enter_normal_location data\n enter_current_location data\n enter_location_date data\n end", "def emailform\n end", "def form_view\n todo_implementation(\"Format: form_view/:id?rel_type=RouteMaster&rel_id=10\")\n end", "def project_setup_form\n\t\tproject_id = params[:project_id]\n\t\t@project = Project.find(project_id)\n\t\t@template_id = params[:bank_id]\n\n\t\t# get information about the key questions in the project\n\t\t@key_questions = KeyQuestion.where(:project_id=>project_id).all\n\t\tavailable_question_info = ExtractionForm.get_available_questions(project_id,nil)\n\t\t@available_questions = available_question_info[0]\n\t\t@assigned_questions = available_question_info[1]\t\n\t\t@no_more_extraction_forms = @project.all_key_questions_accounted_for\n\n\t\t# in the view, change the modal html to be a form to update the title and assign \n\t\t# key questions to the form after it is copied over.\n\tend", "def injection_form\n # Nothing to do here\n end", "def uhook_ubiquo_setting_form form\n ''\n end", "def form\n @form ||= Form.new(get(\"form/#{all['form_id']}\")).use_api(@api)\n end", "def details\n render :layout => 'pubform'\n end", "def new\n @person = Person.new #will create a blank person in memory but it will not have an id nor will it save it in memory\n @term = 'Add Person'\n render partial: 'form' #this will send it to the form page\n end", "def display_form\n @fields.each do |name, validations|\n puts \"Veuillez renseigner votre #{name}\"\n @values[name] = gets.chomp\n end\n end", "def fast_input_form(options = {}, value = nil)\n options[:disabled] = false\n options[:show_all] = false\n options[:number] ||= self.question.number.to_s\n self.create_form(options)\n end", "def get_form\n page = @agent.get SEARCH_PAGE\n page.form_with :action => 'results.cfm'\n end", "def form(name)\n if found_form = @view.form(name)\n presenter_for(found_form, type: FormPresenter)\n else\n nil\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /code_samples POST /code_samples.json
def create @code_sample = current_user.code_samples.new(code_sample_params) respond_to do |format| if @code_sample.save format.html { redirect_to @code_sample, notice: 'Code sample was successfully created.' } format.json { render :show, status: :created, location: @code_sample } else format.html { render :new } format.json { render json: @code_sample.errors, status: :unprocessable_entity } end end end
[ "def create\n @api_v1_sample = Sample.new(sample_params)\n if @api_v1_sample.save\n render :show, status: :created, location: api_v1_sample_path(@api_v1_sample)\n else\n render json: @api_v1_sample.errors, status: :unprocessable_entity\n end\n end", "def create\n @sampleapp = Sampleapp.new(sampleapp_params)\n\n respond_to do |format|\n if @sampleapp.save\n format.html { redirect_to @sampleapp, notice: 'Sampleapp was successfully created.' }\n format.json { render :show, status: :created, location: @sampleapp }\n else\n format.html { render :new }\n format.json { render json: @sampleapp.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @oauth_sample = OauthSample.new(params[:oauth_sample])\n\n respond_to do |format|\n if @oauth_sample.save\n format.html { redirect_to @oauth_sample, notice: 'Oauth sample was successfully created.' }\n format.json { render json: @oauth_sample, status: :created, location: @oauth_sample }\n else\n format.html { render action: \"new\" }\n format.json { render json: @oauth_sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sample = Sample.new(params[:sample])\n\n respond_to do |format|\n if @sample.save\n format.html { redirect_to samples_path, notice: 'Sample was successfully created.' }\n format.json { render json: @sample, status: :created, location: @sample }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sample = Sample.new(sample_params)\n\n if @sample.save\n render json: @sample, status: :created\n else\n render json: @sample.errors, status: :unprocessable_entity\n end\n end", "def create\n @scaffold_sample = ScaffoldSample.new(scaffold_sample_params)\n\n respond_to do |format|\n if @scaffold_sample.save\n format.html { redirect_to @scaffold_sample, notice: 'Scaffold sample was successfully created.' }\n format.json { render :show, status: :created, location: @scaffold_sample }\n else\n format.html { render :new }\n format.json { render json: @scaffold_sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @example_code = ExampleCode.new(example_code_params)\n\n respond_to do |format|\n if @example_code.save\n format.html { redirect_to @example_code, notice: 'Example code was successfully created.' }\n format.json { render action: 'show', status: :created, location: @example_code }\n else\n format.html { render action: 'new' }\n format.json { render json: @example_code.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sample = @ogsong.samples.new(sample_params)\n\n respond_to do |format|\n #if sample created successfully, show notice\n if @sample.save\n format.html { redirect_to @sample, notice: 'Sample was successfully created.' }\n format.json { render :show, status: :created, location: @sample }\n else\n format.html { render :new }\n format.json { render json: @sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @specimen_sample = SpecimenSample.new(specimen_sample_params)\n\n respond_to do |format|\n if @specimen_sample.save\n format.html { redirect_to @specimen_sample, notice: 'Specimen sample was successfully created.' }\n format.json { render :show, status: :created, location: @specimen_sample }\n else\n format.html { render :new }\n format.json { render json: @specimen_sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @test_example = TestExample.new(test_example_params)\n\n respond_to do |format|\n if @test_example.save\n format.html { redirect_to @test_example, notice: 'Test example was successfully created.' }\n format.json { render :show, status: :created, location: @test_example }\n else\n format.html { render :new }\n format.json { render json: @test_example.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sample_resource = SampleResource.new(sample_resource_params)\n\n respond_to do |format|\n if @sample_resource.save\n format.html { redirect_to @sample_resource, notice: 'Sample resource was successfully created.' }\n format.json { render :show, status: :created, location: @sample_resource }\n else\n format.html { render :new }\n format.json { render json: @sample_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tissue_sample = TissueSample.new(params[:tissue_sample])\n\n respond_to do |format|\n if @tissue_sample.save\n format.html { redirect_to @tissue_sample, notice: 'Tissue sample was successfully created.' }\n format.json { render json: @tissue_sample, status: :created, location: @tissue_sample }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tissue_sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @mike_hudick_sample = MikeHudickSample.new(mike_hudick_sample_params)\n\n respond_to do |format|\n if @mike_hudick_sample.save\n format.html { redirect_to @mike_hudick_sample, notice: 'Mike hudick sample was successfully created.' }\n format.json { render :show, status: :created, location: @mike_hudick_sample }\n else\n format.html { render :new }\n format.json { render json: @mike_hudick_sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def site_samples\n @samples = Hash.new\n parent.managed_repository do\n site = Voeis::Site.get(params[:site_id])\n @samples ={\"samples\" => site.samples.all(:order => [:lab_sample_code.asc])}\n end\n respond_to do |format|\n format.json do\n format.html\n render :json => @samples.as_json, :callback => params[:jsoncallback]\n end\n end\n end", "def create\n @sample = Sample.new(params[:sample])\n get_statuses(@sample)\n \n respond_to do |format|\n if @sample.save\n flash[:notice] = 'Sample was successfully created.'\n format.html { redirect_to sample_url(@sample) }\n format.xml { head :created, :location => sample_url(@sample) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sample.errors.to_xml }\n end\n end\n end", "def create\n @product_sample = ProductSample.new(params[:product_sample])\n\n respond_to do |format|\n if @product_sample.save\n format.html { redirect_to sample_url(@product_sample.product, @product_sample), notice: 'Product sample was successfully created.' }\n format.json { render json: @product_sample, status: :created, location: @product_sample }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product_sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @code_sample.destroy\n respond_to do |format|\n format.html { redirect_to code_samples_url, notice: 'Code sample was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n respond_to do |format|\n format.html do\n @json_sample = JsonSample.new(params[:json_sample])\n if @json_sample.save\n redirect_to @json_sample, notice: 'Json sample was successfully created.'\n else\n render action: \"new\"\n end\n end\n format.json do\n @json_sample = JsonSample.new(JSON.parse(params[\"json\"]))\n if @json_sample.save\n json = {msg: \"complete\", status: \"OK\"}\n else\n json = {msg: \"failed\", status: \"NG\"}\n end\n return render json: json\n end\n end\n end", "def create\n @example = Example.new(example_params)\n\n respond_to do |format|\n if @example.save\n format.html { redirect_to @example, notice: 'Example was successfully created.' }\n format.json { render :show, status: :created, location: @example }\n else\n format.html { render :new }\n format.json { render json: @example.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /code_samples/1 DELETE /code_samples/1.json
def destroy @code_sample.destroy respond_to do |format| format.html { redirect_to code_samples_url, notice: 'Code sample was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @api_v1_sample.destroy\n head :no_content\n end", "def destroy\n @json_sample = JsonSample.find(params[:id])\n @json_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to json_samples_url }\n format.json { render json: {msg: \"complete\", status: \"OK\"} }\n end\n end", "def destroy\n @sample = Sample.find(params[:id])\n @sample.destroy\n\n respond_to do |format|\n format.html { redirect_to samples_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @scaffold_sample.destroy\n respond_to do |format|\n format.html { redirect_to scaffold_samples_url, notice: 'Scaffold sample was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @oauth_sample = OauthSample.find(params[:id])\n @oauth_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to oauth_samples_url }\n format.json { head :ok }\n end\n end", "def destroy\n @mike_hudick_sample.destroy\n respond_to do |format|\n format.html { redirect_to mike_hudick_samples_url, notice: 'Mike hudick sample was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mycometer_coc_sample.destroy\n respond_to do |format|\n format.html { redirect_to mycometer_coc_samples_url, notice: 'Mycometer coc sample was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sample.destroy\n\n respond_to do |format|\n format.html { redirect_to(samples_url) }\n format.xml { head :ok }\n end\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def destroy\n @test_example.destroy\n respond_to do |format|\n format.html { redirect_to test_examples_url, notice: 'Test example was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sample = Sample.find(params[:id])\n @sample.destroy\n\n respond_to do |format|\n format.html { redirect_to(samples_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @example = Example.find(params[:id])\n @example.destroy\n\n respond_to do |format|\n format.html { redirect_to examples_url }\n format.json { head :ok }\n end\n end", "def destroy\n @example = Example.find(params[:id])\n @example.destroy\n\n respond_to do |format|\n format.html { redirect_to examples_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @xrf_coc_sample.destroy\n respond_to do |format|\n format.html { redirect_to xrf_coc_samples_url, notice: 'Xrf coc sample was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @specimen_sample.destroy\n respond_to do |format|\n format.html { redirect_to specimen_samples_url, notice: 'Specimen sample was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cocoon_example.destroy\n respond_to do |format|\n format.html { redirect_to cocoon_examples_url, notice: 'Cocoon example was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def delete_sample\n @sample = Sample.find(params[:sample_id])\n logger.debug \"Sample is #{@sample.to_yaml}\"\n @manifestation = Manifestation.find(params[:id])\n @dom_id = generate_id(@sample)\n # @manifestation.samples.delete(@sample)\n # @manifestation.save\n logger.debug \"**** DELETING SAMPLE #{@dom_id} ****\"\n @sample.destroy\n logger.debug \"**** /DELETING SAMPLE ****\"\n end", "def destroy\n @patient_sample = PatientSample.find(params[:id])\n @patient_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to patient_samples_url }\n format.json { head :no_content }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
I haven't written a test for it but the implemenation seems incorrect to me. It doesn't take into account the colour of the area you're filling. Your test passes only because you're limiting the area you're filling with the colour used to fill but if you change the colour, it fails. Also, it fails with a stack level too deep error, which shouldn't be happening on a small grid (10x10 in your test). A better approach would be to read the colour of the very first pixel that's being filled and pass it on every recursive call, so that only the adjacent pixels of that colour were filled.
def floodfill(x, y, color) if @pixels[y-1][x-1] != color @pixels[y-1][x-1] = color floodfill(x+1, y, color) floodfill(x-1, y, color) floodfill(x, y + 1, color) floodfill(x, y - 1, color) end end
[ "def recursive_fill(x, y, colour, original_colour)\n # puts \"Setting #{x},#{y} to #{colour}\"\n @grid.set_value_at_point(x, y, colour)\n\n points = @grid.all_touching_points(x, y)\n points.each do |p|\n col = @grid.get_value_at_point(p[0], p[1])\n recursive_fill(p[0], p[1], colour, original_colour) if (col == original_colour)\n end\n end", "def fill_area(x,y,fill_color, ori_color)\n\tpoints = []\n\t# nearest up point\n\tpoints[0] = [x, y-1]\n\t# nearest down point\n\tpoints[1] = [x, y+1]\n\t# nearest left point\n\tpoints[2] = [x-1, y]\n\t# nearest right point\n\tpoints[3] = [x+1, y]\n\n\tfor i in 0..points.length-1\n\t\t# get coordinate of the surrounding point\n\t\tsurround_x = points[i][0]\n\t\tsurround_y = points[i][1]\n\n\t\t# get the color of the surrounding point with color(x,y) method\n\t\tsurround_color = color(surround_x, surround_y)\n\t\t# get the color of the current point\n\t\tcurrent_color = color(x,y)\n\n\t\t# compare if color of the surrounding point is different form that of current point\n\t\t# if true, the surrounding point is a boundary point\n\t\t# if false, call the recursive method\n\t\tif surround_color != current_color\n\t\t\t# check to fill current point\n\t\t\tif current_color == fill_color\n\t\t\t\t# do nothing\n\t\t\telse\n\t\t\t\t# fill the current's cell with the set_color(x,y,fill_color) method\n\t\t\t\tset_color(x,y,fill_color)\n\t\t\tend\n\t\telse\n\t\t\tfill_area(surround_x,surround_y,fill_color,ori_color)\n\t\tend\n\tend\nend", "def floodFill(col, row)\r\n (col > @columns-1 || col < 0 || row > @rows-1 || row < 0) && return #Returns if the tile index is outside of the grid bounds.\r\n @tile[col][row].revealed && return #Returns if the tile is already revealed.\r\n\r\n @tile[col][row].revealed = true #Marks the tile as revealed.\r\n @hiddenCount -= 1\r\n adjacent = @tile[col][row].adjacent #Gets the adjacent count for the tile.\r\n\r\n #Reveal the adjacent count of the tile.\r\n old = @tile[col][row].btn\r\n newStyle = old.style.dup\r\n old.parent.before(old) do\r\n @btn = button(adjacent.to_s, newStyle)\r\n end\r\n old.remove\r\n\r\n #Recursively calls flood fill for the surrounding tiles.\r\n if (@tile[col][row].adjacent == 0)\r\n floodFill(col+1,row+1)\r\n floodFill(col+1,row)\r\n floodFill(col+1,row-1)\r\n floodFill(col,row+1)\r\n floodFill(col,row-1)\r\n floodFill(col-1,row+1)\r\n floodFill(col-1,row)\r\n floodFill(col-1,row-1)\r\n end\r\n\r\nend", "def fill_area (x, y, color, original_color=nil)\n raise \"X value is out of range.\" if x > @width or x <= 0\n raise \"Y value is out of range.\" if y > @height or y <= 0\n raise \"Color not recognized.\" unless is_valid_color?(color)\n\n original_color = @matrix[y-1][x-1].color unless original_color\n \n adjacents_with_same_color = adjacents(x, y).select {|square| square.color == original_color}\n fill_point(x, y, color)\n adjacents_with_same_color.each {|square| fill_area square.x, square.y, color, original_color}\n end", "def paint_fill(screen, point, new_color, old_color = nil)\n x = point[0]\n y = point[1]\n\n old_color ||= screen[y][x]\n if screen[y][x] != old_color\n return\n else\n screen[y][x] = new_color\n paint_fill(screen, [x, y + 1], new_color, old_color) if y + 1 < screen.length\n paint_fill(screen, [x, y - 1], new_color, old_color) if y - 1 >= 0\n paint_fill(screen, [x + 1, y], new_color, old_color) if x + 1 < screen[0].length\n paint_fill(screen, [x - 1, y], new_color, old_color) if x - 1 >= 0\n end\n screen\nend", "def flood_fill(image, sr, sc, new_color)\r\n queue = [[sr, sc]]\r\n old_color = image[sr][sc]\r\n until queue.empty? do \r\n start = queue.pop\r\n x, y = start\r\n image[x][y] = new_color\r\n queue << [x, y+1] if y+1 < image[x].length && image[x][y+1] == old_color\r\n queue << [x, y-1] if y-1 >= 0 && image[x][y-1] == old_color\r\n queue << [x+1, y] if x+1 < image.length && image[x+1][y] == old_color\r\n queue << [x-1, y] if x-1 >= 0 && image[x-1][y] == old_color\r\n end\r\n image\r\nend", "def fill_region(x, y, colour)\n return if invalid?(x,y)\n x = xform(x)\n y = xform(y)\n target_colour = @matrix.element(y, x)\n @matrix.flood_fill(x, y, target_colour, colour)\n end", "def flood_fill(x, y)\n flood_fill_util(x, y)\n end", "def check_cell_for_filling #:doc:\n return true if @next_cell[0] < 0 || @next_cell[0] >= @image.length\n return true if @next_cell[1] < 0 || @next_cell[1] >= @image[@next_cell[0]].length\n return true if @image[@next_cell[0]][@next_cell[1]] != @old_color\n return true if @visited_cells.include?(@next_cell)\n end", "def selected_area_to_fill(x, y, color)\n coordinates = check_area_parameters(x, y, color)\n full_array = prepare_area_to_fill(coordinates[0], coordinates[1], color)\n colored_pixels_groups(full_array, color) if !full_array.empty?\n end", "def fill_with_color(start_i, start_j, to_replace, color, neighbors=nil)\n # $log.debug(\"fill #{start_i} #{start_j}; replace #{to_replace} with #{color}\") if $debug\n return 0 if @yx[start_j][start_i] != to_replace\n vcount = 0\n @to_replace = to_replace\n @groups = neighbors\n gaps = [[start_i, start_j, start_j]]\n while (gap = gaps.pop)\n # $log.debug(\"About to do gap: #{gap} (left #{gaps.size})\") if $debug\n i,j0,j1 = gap\n next if @yx[j0][i] != to_replace # gap already done by another path\n while _check(i,j0-1) do j0 -= 1 end\n while _check(i,j1+1) do j1 += 1 end\n vcount += j1-j0+1\n # $log.debug(\"Doing column #{i} from #{j0}-#{j1}\") if $debug\n (i-1).step(i+1,2) do |ix|\n curgap = nil\n j0.upto(j1) do |j|\n # $log.debug(\"=>coloring #{i},#{j}\") if $debug and ix<i\n @yx[j][i] = color if ix<i\n # $log.debug(\"checking neighbor #{ix},#{j}\") if $debug\n if _check(ix,j)\n if ! curgap\n # $log.debug(\"New gap in #{ix} starts at #{j}\") if $debug\n curgap = j # gap start\n end\n else\n if curgap\n # $log.debug(\"--- pushing gap [#{ix},#{curgap},#{j-1}]\") if $debug\n gaps.push([ix,curgap,j-1])\n curgap = nil\n end\n end\n end # upto j\n # $log.debug(\"--- pushing gap [#{ix},#{curgap},#{j1}]\") if $debug and curgap\n gaps.push([ix,curgap,j1]) if curgap # last gap\n end # each ix\n end # while gap\n return vcount\n end", "def replace_color #:doc:\n until @adjacent_cells.empty?\n cell = @adjacent_cells.pop\n @image[cell[0]][cell[1]] = @replace_color\n @visited_cells.push(cell)\n\n # Add cells to the fill stack\n BORDERCELLS.each do |border_cell|\n @next_cell = [cell[0] + border_cell[0], cell[1] + border_cell[1]]\n next if check_cell_for_filling\n @adjacent_cells.push(@next_cell)\n end\n end\n end", "def fill_region_with_color(x, y, c, old_color=nil)\n x_index = x - 1\n y_index = y - 1\n\n old_color ||= @canvas[x_index][y_index]\n current_color = @canvas[x_index][y_index]\n\n if old_color == current_color\n @canvas[x_index][y_index] = c\n\n fill_region_with_color(x-1, y, c, old_color) if x > 0\n fill_region_with_color(x+1, y, c, old_color) if x <= @canvas[0].length\n fill_region_with_color(x, y-1, c, old_color) if y > 0\n fill_region_with_color(x, y+1, c, old_color) if y <= @canvas.length\n end\n end", "def full_fill(color)\r\n fill_rect(rect, color)\r\n end", "def gradient_fill_region(x, y, a, b, c)\n return if invalid?(x, y)\n fill_region(x, y, c)\n colour(x, y, a)\n x = x.to_i\n y = y.to_i\n conditional_colour(x-1, y, b, c)\n conditional_colour(x+1, y, b, c)\n conditional_colour(x, y-1, b, c)\n conditional_colour(x, y+1, b, c)\n conditional_colour(x-1, y-1, b, c)\n conditional_colour(x+1, y-1, b, c)\n conditional_colour(x-1, y+1, b, c)\n conditional_colour(x+1, y+1, b, c) \n end", "def increment_fill\n begin\n # increment the fill value. reset value to a certain minimum if it goes over the max gray value.\n @ball_fill = ((@ball_fill += @@INCREMENT_FILL_VAL) > 255 ) ? @@MIN_FILL : @ball_fill += @@INCREMENT_FILL_VAL\n @@GRAYS_USED << @ball_fill unless @@GRAYS_USED.include?(@ball_fill)\n rescue => e\n puts \"error in increment_fill: #{e.message}\"\n end\n end", "def connect_flood_fill\n current_flood_fill = connect.flood_fill.clone\n connect.flood_fill = []\n\n current_flood_fill.each do |x, y|\n connect.main_region << [x, y]\n adjacent_points(x, y).each do |a_x, a_y|\n if connect_flood_fillable?(a_x, a_y)\n connect.flood_fill << [a_x, a_y]\n end\n end\n end\n\n connect.flood_fill.uniq!\n end", "def fill_region(x, y, new_colour, old_colour=nil, border_colour=nil)\n # The recursive algorithm. Starting at x and y, changes any adjacent\n # characters that match old_colour to new_colour.\n # This algorithm was taken from:\n # http://inventwithpython.com/blog/2011/08/11/recursion-explained-with-the-flood-fill-algorithm-and-zombies-and-cats/\n\n # Adjust algorithm coordinates because the image first pixel is (1,1)\n # but the algorith requires (0,0).\n if old_colour.nil?\n x -= 1; y -= 1\n old_colour = @image.content[x][y]\n end\n\n # Base case. If the current x, y character is not the old_colour,\n # then do nothing. However, the current character may be a border\n # so check it.\n if @image.content[x][y] != old_colour\n colour_border(x, y, new_colour, border_colour) if border_colour\n return\n end\n\n @image.content[x][y] = new_colour\n\n # Recursive calls. Make a recursive call as long as we are not on the\n # boundary (which would cause an Error).\n fill_region(x-1, y, new_colour, old_colour, border_colour) if x > 0\n fill_region(x, y-1, new_colour, old_colour, border_colour) if y > 0\n fill_region(x+1, y, new_colour, old_colour, border_colour) if x < @image.width - 1\n fill_region(x, y+1, new_colour, old_colour, border_colour) if y < @image.height - 1\n @image\n end", "def bucket_fill_area(x, y, c)\n @rows = []\n if (x >= 1 && x <= @width) && (y >= 1 && y <= @height)\n process_position(x, y, c)\n\n @rows.each do |row|\n process_position(row[:x], row[:y] - 1, c) if (row[:y] - 1) >= 1\n process_position(row[:x] + 1, row[:y], c) if (row[:x] + 1) <= @width\n process_position(row[:x], row[:y] + 1, c) if (row[:y] + 1) <= @height\n process_position(row[:x] - 1, row[:y], c) if (row[:x] - 1) >= 1\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /contests/new GET /contests/new.json
def new @contest = Contest.new respond_to do |format| format.html # new.html.erb format.json { render json: @contest } end end
[ "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contestant }\n end\n end", "def new\n @contest_entry = ContestEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest_entry }\n end\n end", "def new\n @contest_task = ContestTask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest_task }\n end\n end", "def new\n @contest3rd = Contest3rd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest3rd }\n end\n end", "def new\n\n @contestant = Contestant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contestant }\n end\n end", "def create\n @contest = Contest.new(params[:contest])\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, notice: 'Contest was successfully created.' }\n format.json { render json: @contest, status: :created, location: @contest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @contest = Contest.new\n end", "def new\n @contest_winner = ContestWinner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest_winner }\n end\n end", "def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contest }\n end\n end", "def new\n @optin_contestant = OptinContestant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @optin_contestant }\n end\n end", "def new\n @contest_prize = ContestPrize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest_prize }\n end\n end", "def create\n @contest = Contest.new(contest_params)\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, notice: 'Contest was successfully created.' }\n format.json { render :show, status: :created, location: @contest }\n else\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @competition = Competition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competition }\n end\n end", "def new\n @test_case = TestCase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_case }\n end\n end", "def new\n @exercice = Exercice.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercice }\n end\n end", "def create\n @manage_contest = Manage::Contest.new(manage_contest_params)\n\n respond_to do |format|\n if @manage_contest.save\n format.html { redirect_to @manage_contest, notice: 'Contest was successfully created.' }\n format.json { render :show, status: :created, location: @manage_contest }\n else\n format.html { render :new }\n format.json { render json: @manage_contest.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n respond_to do |format|\n if @contestant.save\n format.html { redirect_to @contestant, notice: 'Contestant was successfully created.' }\n format.json { render json: @contestant, status: :created, location: @contestant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contestant.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @problem = @idea.problems.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end", "def new\n @casestudy = Casestudy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @casestudy }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /vanos/1 GET /vanos/1.json
def show @vano = Vano.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @vano } end end
[ "def index\n @vinos = Vino.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vinos }\n end\n end", "def show\n @vocero = Vocero.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vocero }\n end\n end", "def index\n @viajes = Viaje.all\n render json: @viajes\n end", "def index\n @vanos = Vano.all\n end", "def show\n @votos_urna = VotosUrna.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @votos_urna }\n end\n end", "def show\n @volantino = Volantino.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volantino }\n end\n end", "def index\n @votos = Voto.all\n\n render json: @votos\n end", "def call_vista_novo(url)\n string = HTTParty.get(url, \n basic_auth: { username: \"andy@mitre.org\", password: \"splatter\" })\n JSON.parse(string)\n end", "def show\n @vodka = Vodka.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vodka }\n end\n end", "def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend", "def show\n @zveno = Zveno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @zveno }\n end\n end", "def show\n @vereador = Vereador.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vereador }\n end\n end", "def show\n @nova = Nova.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nova }\n end\n end", "def show\n @observacao_vocacionado = ObservacaoVocacionado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observacao_vocacionado }\n end\n end", "def show\n @lop_mon_hoc_sinh_vien = LopMonHocSinhVien.find(params[:id])\n\n respond_to do |format| \n format.json { render json: @lop_mon_hoc_sinh_vien }\n end\n end", "def show\n @voc = Voc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voc }\n end\n end", "def show\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observacao_vocacionada }\n end\n end", "def show\n @voprosy = Voprosy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voprosy }\n end\n end", "def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /vanos/new GET /vanos/new.json
def new @vano = Vano.new respond_to do |format| format.html # new.html.erb format.json { render json: @vano } end end
[ "def new\n @nova = Nova.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nova }\n end\n end", "def new\n @volantino = Volantino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volantino }\n end\n end", "def new\n @noto = Noto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @noto }\n end\n end", "def new\n @objeto = Objeto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @objeto }\n end\n end", "def new\n @venta = Venta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venta }\n end\n end", "def new\n @vodka = Vodka.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vodka }\n end\n end", "def new\n @vocacionado = Vocacionado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vocacionado }\n end\n end", "def new\n @newse = Newse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newse }\n end\n end", "def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end", "def new\n @vocacionada = Vocacionada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vocacionada }\n end\n end", "def new\n @verbo = Verbo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verbo }\n end\n end", "def new\n @voc = Voc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @voc }\n end\n end", "def new\n @ping = Ping.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ping }\n end\n end", "def new\n @trnodo = Trnodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trnodo }\n end\n end", "def new\n @punto_de_ventum = PuntoDeVentum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @punto_de_ventum }\n end\n end", "def new\n @serv = Serv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serv }\n end\n end", "def new\n @torneo = Torneo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @torneo }\n end\n end", "def new\n @servico = Servico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @servico }\n end\n end", "def new\n @pinglun = Pinglun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pinglun }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /vanos POST /vanos.json
def create @vano = Vano.new(params[:vano]) respond_to do |format| if @vano.save format.html { redirect_to @vano, notice: 'Vano was successfully created.' } format.json { render json: @vano, status: :created, location: @vano } else format.html { render action: "new" } format.json { render json: @vano.errors, status: :unprocessable_entity } end end end
[ "def create\n @vano = Vano.new(vano_params)\n\n respond_to do |format|\n if @vano.save\n format.html { redirect_to @vano, notice: 'Vano was successfully created.' }\n format.json { render :show, status: :created, location: @vano }\n else\n format.html { render :new }\n format.json { render json: @vano.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def create\n @vino = Vino.new(vino_params)\n\n respond_to do |format|\n if @vino.save\n format.html { redirect_to @vino, notice: 'Vino was successfully created.' }\n format.json { render :show, status: :created, location: @vino }\n else\n format.html { render :new }\n format.json { render json: @vino.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vodka = Vodka.new(params[:vodka])\n\n respond_to do |format|\n if @vodka.save\n format.html { redirect_to @vodka, notice: 'Vodka was successfully created.' }\n format.json { render json: @vodka, status: :created, location: @vodka }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vodka.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vino = Vino.new(vino_params)\n\n respond_to do |format|\n if @vino.save\n format.html { redirect_to @vino, notice: \"Vino was successfully created.\" }\n format.json { render :show, status: :created, location: @vino }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @vino.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vozgorany = Vozgoranie.new(vozgorany_params)\n\n respond_to do |format|\n if @vozgorany.save\n format.html { redirect_to vozgoranies_path, notice: 'Запись успешно добавлена.' }\n format.json { render :show, status: :created, location: vozgoranies_path }\n else\n format.html { render :new }\n format.json { render json: @vozgorany.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vinho = Vinho.new(vinho_params)\n\n respond_to do |format|\n if @vinho.save\n format.html { redirect_to @vinho, notice: 'Vinho was successfully created.' }\n format.json { render :show, status: :created, location: @vinho }\n else\n format.html { render :new }\n format.json { render json: @vinho.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @votos_urna = VotosUrna.new(params[:votos_urna])\n\n respond_to do |format|\n if @votos_urna.save\n format.html { redirect_to @votos_urna, notice: 'Votos urna was successfully created.' }\n format.json { render json: @votos_urna, status: :created, location: @votos_urna }\n else\n format.html { render action: \"new\" }\n format.json { render json: @votos_urna.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @voto = Voto.new(voto_params)\n\n if @voto.save\n render json: @voto, status: :created, location: @voto\n else\n render json: @voto.errors, status: :unprocessable_entity\n end\n end", "def create\n @zveno = Zveno.new(params[:zveno])\n\n respond_to do |format|\n if @zveno.save\n format.html { redirect_to zvenos_path, notice: 'Zveno was successfully created.' }\n format.json { render json: @zveno, status: :created, location: @zveno }\n else\n format.html { render action: \"new\" }\n format.json { render json: @zveno.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vanue = Vanue.new(vanue_params)\n\n respond_to do |format|\n if @vanue.save\n format.html { redirect_to @vanue, notice: 'Vanue was successfully created.' }\n format.json { render :show, status: :created, location: @vanue }\n else\n format.html { render :new }\n format.json { render json: @vanue.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @visto = Visto.new(visto_params)\n\n\n respond_to do |format|\n if @visto.save\n format.html { redirect_to @visto, notice: 'Visto was successfully created.' }\n format.json { render :show, status: :created, location: @visto }\n else\n format.html { render :new }\n format.json { render json: @visto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lop_mon_hoc_sinh_vien = LopMonHocSinhVien.new(params[:lop_mon_hoc_sinh_vien])\n\n respond_to do |format|\n if @lop_mon_hoc_sinh_vien.save \n format.json { render json: @lop_mon_hoc_sinh_vien, status: :created, location: @lop_mon_hoc_sinh_vien }\n else \n format.json { render json: @lop_mon_hoc_sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend", "def create\n @vongdau = Vongdau.new(vongdau_params)\n\n respond_to do |format|\n if @vongdau.save\n format.html { redirect_to @vongdau, notice: 'Vongdau was successfully created.' }\n format.json { render :show, status: :created, location: @vongdau }\n else\n format.html { render :new }\n format.json { render json: @vongdau.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plano_de_voo = PlanoDeVoo.new(plano_de_voo_params)\n\n respond_to do |format|\n if @plano_de_voo.save\n format.html { redirect_to @plano_de_voo, notice: 'Plano de voo was successfully created.' }\n format.json { render :show, status: :created, location: @plano_de_voo }\n else\n format.html { render :new }\n format.json { render json: @plano_de_voo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vypujcka = Vypujcka.new(params[:vypujcka])\n\n if @vypujcka.save\n render json: @vypujcka, status: :created, location: @vypujcka\n else\n render json: @vypujcka.errors, status: :unprocessable_entity\n end\n end", "def create\n @volantino = Volantino.new(params[:volantino])\n\n respond_to do |format|\n if @volantino.save\n format.html { redirect_to @volantino, notice: 'Volantino was successfully created.' }\n format.json { render json: @volantino, status: :created, location: @volantino }\n else\n format.html { render action: \"new\" }\n format.json { render json: @volantino.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @venta = Venta.new(params[:venta])\n\n respond_to do |format|\n if @venta.save\n format.html { redirect_to @venta, notice: 'Venta was successfully created.' }\n format.json { render json: @venta, status: :created, location: @venta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /positioncoefficients GET /positioncoefficients.xml
def index @positioncoefficients = Positioncoefficient.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @positioncoefficients } end end
[ "def show\n @positioncoefficient = Positioncoefficient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @positioncoefficient }\n end\n end", "def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @positioncoefficient }\n end\n end", "def index\n @coefficients = Coefficient.all\n end", "def create\n @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])\n\n respond_to do |format|\n if @positioncoefficient.save\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') }\n format.xml { render :xml => @positioncoefficient, :status => :created, :location => @positioncoefficient }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @positioncoefficient = Positioncoefficient.find(params[:id])\n\n respond_to do |format|\n if @positioncoefficient.update_attributes(params[:positioncoefficient])\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @positioncoefficient = Positioncoefficient.find(params[:id])\n @positioncoefficient.destroy\n\n respond_to do |format|\n format.html { redirect_to(positioncoefficients_url) }\n format.xml { head :ok }\n end\n end", "def list_country_coefficients(country, options={}) path = \"/api/v2/#{country}/CountryCoefficients\"\n get(path, options, AvaTax::VERSION) end", "def stops_by_position\n get '/gtfs/stops/geosearch/'\n end", "def index\n @positions = Position.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positions }\n end\n end", "def index\n @proximities = Proximity.all\n end", "def index\n @positions = @template.positions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positions }\n end\n end", "def langrage_coefficients\n # TODO\n end", "def polynomial_coefficients(p, i)\n [p[3][i] - 3 * p[2][i] + 3 * p[1][i] - p[0][i],\n 3 * p[2][i] - 6 * p[1][i] + 3 * p[0][i],\n 3 * p[1][i] - 3 * p[0][i],\n p[0][i]]\n end", "def index\n @quantities = @component.quantities\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quantities }\n end\n end", "def get_possible_patterns_at_position(position, coefficients)\n x, y = position\n possible_patterns = coefficients[x][y]\nend", "def get_coins\n get(\"/getcoins\")\n end", "def index\n @positions = Position.all(:order=>'name')\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positions }\n end\n end", "def coefficients(type=:array)\n if type==:array\n #originally returned as vector; so pass it\n @coefficients\n elsif type==:hash\n h={}\n @fields.size.times {|i|\n h[@fields[i]]=@coefficients[i]\n }\n h\n end\n end", "def index\n @pclevels = Pclevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pclevels }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /positioncoefficients/1 GET /positioncoefficients/1.xml
def show @positioncoefficient = Positioncoefficient.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @positioncoefficient } end end
[ "def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end", "def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @positioncoefficient }\n end\n end", "def index\n @coefficients = Coefficient.all\n end", "def create\n @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])\n\n respond_to do |format|\n if @positioncoefficient.save\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') }\n format.xml { render :xml => @positioncoefficient, :status => :created, :location => @positioncoefficient }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @positioncoefficient = Positioncoefficient.find(params[:id])\n\n respond_to do |format|\n if @positioncoefficient.update_attributes(params[:positioncoefficient])\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @positioncoefficient = Positioncoefficient.find(params[:id])\n @positioncoefficient.destroy\n\n respond_to do |format|\n format.html { redirect_to(positioncoefficients_url) }\n format.xml { head :ok }\n end\n end", "def index\n @positions = Position.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positions }\n end\n end", "def index\n @positions = @template.positions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positions }\n end\n end", "def show\n @position_dependant = PositionDependant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @position_dependant }\n end\n end", "def index\n @quantities = @component.quantities\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quantities }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @formula }\n end\n end", "def show\r\n @position_hist = PositionHist.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.rhtml\r\n format.xml { render :xml => @position_hist.to_xml }\r\n end\r\n end", "def index\n @pos = Po.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pos }\n end\n end", "def show\n @position_threshold = PositionThreshold.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @position_threshold }\n end\n end", "def index\n @proximities = Proximity.all\n end", "def index\n @positions = Position.all(:order=>'name')\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positions }\n end\n end", "def get(idx=0) \n extra = \"\"\n @extra_args.each do | key, val | \n extra << \"&#{key}=#{val}\"\n end \n self.parse_response(@client.get(\"#{@uri.path}?#{@context_objects[idx].kev}#{extra}\")) \n end", "def new\n @position_dependant = PositionDependant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @position_dependant }\n end\n end", "def show\n @cash_position = CashPosition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cash_position }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /positioncoefficients/new GET /positioncoefficients/new.xml
def new @positioncoefficient = Positioncoefficient.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @positioncoefficient } end end
[ "def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end", "def create\n @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])\n\n respond_to do |format|\n if @positioncoefficient.save\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') }\n format.xml { render :xml => @positioncoefficient, :status => :created, :location => @positioncoefficient }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @position_dependant = PositionDependant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @position_dependant }\n end\n end", "def new\n @position = Position.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @position }\n end\n end", "def new\n @position = Position.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @position }\n end\n end", "def new\n @position_threshold = PositionThreshold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @position_threshold }\n end\n end", "def new\n @position = Position.new\n @position.template = @template\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @position }\n end\n end", "def show\n @positioncoefficient = Positioncoefficient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @positioncoefficient }\n end\n end", "def new\n @financial_position = FinancialPosition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @financial_position }\n end\n end", "def new\n @position = Position.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @position }\n end\n end", "def new\n @ecnposition = Ecnposition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ecnposition }\n end\n end", "def new\n @geo_position = GeoPosition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @geo_position }\n end\n end", "def new\n @cash_position = CashPosition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cash_position }\n end\n end", "def new\n @old_point = OldPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_point }\n end\n end", "def new\n @executive_position = ExecutivePosition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @executive_position }\n end\n end", "def new\n @position_number = PositionNumber.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @position_number }\n end\n end", "def new\n @position_history = PositionHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @position_history }\n end\n end", "def new\n @order_position = OrderPosition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order_position }\n end\n end", "def new\n @old_point_tag = OldPointTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_point_tag }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /positioncoefficients POST /positioncoefficients.xml
def create @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient]) respond_to do |format| if @positioncoefficient.save format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') } format.xml { render :xml => @positioncoefficient, :status => :created, :location => @positioncoefficient } else format.html { render :action => "new" } format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity } end end end
[ "def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end", "def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @positioncoefficient }\n end\n end", "def update\n @positioncoefficient = Positioncoefficient.find(params[:id])\n\n respond_to do |format|\n if @positioncoefficient.update_attributes(params[:positioncoefficient])\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @positioncoefficient = Positioncoefficient.find(params[:id])\n @positioncoefficient.destroy\n\n respond_to do |format|\n format.html { redirect_to(positioncoefficients_url) }\n format.xml { head :ok }\n end\n end", "def create\n @coefficient = Coefficient.new(coefficient_params)\n\n respond_to do |format|\n if @coefficient.save\n format.html { redirect_to @coefficient, notice: 'Coefficient was successfully created.' }\n format.json { render :show, status: :created, location: @coefficient }\n else\n format.html { render :new }\n format.json { render json: @coefficient.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @order_position = OrderPosition.new(order_position_params)\n\n respond_to do |format|\n if @order_position.save\n format.html { redirect_to @order_position, notice: 'Order position was successfully created.' }\n format.json { render :show, status: :created, location: @order_position }\n else\n format.html { render :new }\n format.json { render json: @order_position.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ecnposition = Ecnposition.new(params[:ecnposition])\n\n respond_to do |format|\n if @ecnposition.save\n format.html { redirect_to(ecnpositions_url, :notice => 'Ecnposition was successfully created.') }\n format.xml { render :xml => @ecnposition, :status => :created, :location => @ecnposition }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ecnposition.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @order_position = OrderPosition.new(params[:order_position])\n\n respond_to do |format|\n if @order_position.save\n format.html { redirect_to @order_position, notice: 'Order position was successfully created.' }\n format.json { render json: @order_position, status: :created, location: @order_position }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order_position.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @position_dependant = PositionDependant.new(params[:position_dependant])\n\n respond_to do |format|\n if @position_dependant.save\n format.html { redirect_to(@position_dependant, :notice => 'Position dependant was successfully created.') }\n format.xml { render :xml => @position_dependant, :status => :created, :location => @position_dependant }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @position_dependant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @position = Position.new(params[:position])\n \n respond_to do |format|\n if @position.save\n format.html { redirect_to(@position, :notice => 'Position was successfully created.') }\n format.xml { render :xml => @position, :status => :created, :location => @position }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @position.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @position = Position.new(params[:position])\n\n respond_to do |format|\n if @position.save\n format.html { redirect_to(admin_position_path(@position), :notice => 'Position was successfully created.') }\n format.xml { render :xml => @position, :status => :created, :location => @position }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @position.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @financial_position = FinancialPosition.new(params[:financial_position])\n\n respond_to do |format|\n if @financial_position.save\n format.html { redirect_to(@financial_position, :notice => 'Financial position was successfully created.') }\n format.xml { render :xml => @financial_position, :status => :created, :location => @financial_position }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @financial_position.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @part_position = PartPosition.new(part_position_params)\n\n respond_to do |format|\n if @part_position.save\n format.html { redirect_to @part_position, notice: 'Part position was successfully created.' }\n format.json { render :show, status: :created, location: @part_position }\n else\n format.html { render :new }\n format.json { render json: @part_position.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fundamental_character_position = Fundamental::CharacterPosition.new(params[:fundamental_character_position])\n\n respond_to do |format|\n if @fundamental_character_position.save\n format.html { redirect_to @fundamental_character_position, notice: 'Character position was successfully created.' }\n format.json { render json: @fundamental_character_position, status: :created, location: @fundamental_character_position }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fundamental_character_position.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @position = Position.new(params[:position])\n respond_to do |format|\n if @position.save\n format.html { redirect_to @position, notice: 'Position was successfully created.' }\n format.json { render json: @position, status: :created, location: @position }\n else\n format.html { render action: \"new\" }\n format.json { render json: @position.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @position = Position.new(params[:position])\n\n respond_to do |format|\n if @position.save\n format.html { redirect_to @position, notice: 'Position was successfully created.' }\n format.json { render json: @position, status: :created, location: @position }\n else\n format.html { render action: \"new\" }\n format.json { render json: @position.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @position = Position.new(params[:position])\n\n respond_to do |format|\n if @position.save\n format.html { redirect_to positions_path, notice: 'Position was successfully created.' }\n format.json { render json: positions_path, status: :created, location: @position }\n else\n format.html { render action: \"new\" }\n format.json { render json: @position.errors, status: :unprocessable_entity }\n end\n end\n end", "def offertposition_params\n params.require(:offertposition).permit!\n end", "def create\n @executive_position = ExecutivePosition.new(params[:executive_position])\n\n respond_to do |format|\n if @executive_position.save\n flash[:notice] = 'ExecutivePosition was successfully created.'\n format.html { redirect_to(@executive_position) }\n format.xml { render :xml => @executive_position, :status => :created, :location => @executive_position }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @executive_position.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /positioncoefficients/1 PUT /positioncoefficients/1.xml
def update @positioncoefficient = Positioncoefficient.find(params[:id]) respond_to do |format| if @positioncoefficient.update_attributes(params[:positioncoefficient]) format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity } end end end
[ "def create\n @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])\n\n respond_to do |format|\n if @positioncoefficient.save\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') }\n format.xml { render :xml => @positioncoefficient, :status => :created, :location => @positioncoefficient }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end", "def destroy\n @positioncoefficient = Positioncoefficient.find(params[:id])\n @positioncoefficient.destroy\n\n respond_to do |format|\n format.html { redirect_to(positioncoefficients_url) }\n format.xml { head :ok }\n end\n end", "def update\n @position = Position.find(params[:id])\n \n respond_to do |format|\n if @position.update_attributes(params[:position])\n format.html { redirect_to(@position, :notice => 'Position was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @position.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @position_dependant = PositionDependant.find(params[:id])\n\n respond_to do |format|\n if @position_dependant.update_attributes(params[:position_dependant])\n format.html { redirect_to(@position_dependant, :notice => 'Position dependant was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @position_dependant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @position = Position.find(params[:id])\n\n respond_to do |format|\n if @position.update_attributes(params[:position])\n format.html { redirect_to([@template, @position], :notice => t(:position_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @position.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @position.update_attributes(params[:position])\n format.html { redirect_to @position, notice: 'Position was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @position.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @positioncoefficient }\n end\n end", "def update\n respond_to do |format|\n if @coefficient.update(coefficient_params)\n format.html { redirect_to @coefficient, notice: 'Coefficient was successfully updated.' }\n format.json { render :show, status: :ok, location: @coefficient }\n else\n format.html { render :edit }\n format.json { render json: @coefficient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @position = Position.find(params[:id])\n\n respond_to do |format|\n if @position.update_attributes(params[:position])\n flash[:notice] = t('positions.title')+\" \"+t('updated')\n format.html { redirect_to(@position) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @position.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @position = Position.find(params[:id])\n\n respond_to do |format|\n if @position.update_attributes(params[:position].permit(:equipe_type_id, :name))\n format.html { redirect_to positions_path, notice: I18n.t(:general_update_success) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @position.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @position = Position.find(params[:id])\n\n respond_to do |format|\n if @position.update_attributes(params[:position])\n format.html { redirect_to(admin_position_path, :notice => 'Position was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @position.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_price\n @kit = Kit.find(params[:id])\n @kit.update_attribute(\"price\", params[:value])\n respond_to do |format|\n format.xml { render :xml => @kit }\n end\n end", "def update\n @position = Position.find(params[:id])\n respond_to do |format|\n if @position.update_attributes(params[:position])\n format.html { redirect_to @position, notice: 'Position was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @position.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @position = Position.find(params[:id])\n\n respond_to do |format|\n if @position.update_attributes(params[:position])\n format.html { redirect_to @position, notice: 'Position was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @position.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cash_position = CashPosition.find(params[:id])\n\n respond_to do |format|\n if @cash_position.update_attributes(params[:cash_position])\n format.html { redirect_to(@cash_position, :notice => 'Cash position was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cash_position.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n respond_to do |format|\n if position.save\n format.html { redirect_to( position, flash: { success: 'Position updated.' } ) }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: position.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ecnposition = Ecnposition.find(params[:id])\n\n respond_to do |format|\n if @ecnposition.update_attributes(params[:ecnposition])\n format.html { redirect_to(ecnpositions_url, :notice => 'Ecnposition was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ecnposition.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /positioncoefficients/1 DELETE /positioncoefficients/1.xml
def destroy @positioncoefficient = Positioncoefficient.find(params[:id]) @positioncoefficient.destroy respond_to do |format| format.html { redirect_to(positioncoefficients_url) } format.xml { head :ok } end end
[ "def destroy\n @position_dependant = PositionDependant.find(params[:id])\n @position_dependant.destroy\n\n respond_to do |format|\n format.html { redirect_to(position_dependants_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @position_threshold = PositionThreshold.find(params[:id])\n @position_threshold.destroy\n\n respond_to do |format|\n format.html { redirect_to(position_thresholds_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ecnposition = Ecnposition.find(params[:id])\n @ecnposition.destroy\n\n respond_to do |format|\n format.html { redirect_to(ecnpositions_url) }\n format.xml { head :ok }\n end\n end", "def delete_position\n @part_position = PartPosition.find_by_id(params[:id])\n @part_position.destroy\n\n render :json => {result:true}\n end", "def destroy\n @position = Position.find(params[:id])\n @position.destroy\n \n respond_to do |format|\n format.html { redirect_to(positions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cash_position = CashPosition.find(params[:id])\n @cash_position.destroy\n\n respond_to do |format|\n format.html { redirect_to(cash_positions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n \r\n @position = Position.find(params[:id])\r\n\r\n @position.destroy\r\n \r\n respond_to do |format|\r\n format.html { redirect_to positions_url }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @primary_expr = PrimaryExpr.find(params[:id])\n @primary_expr.destroy\n\n respond_to do |format|\n format.html { redirect_to(primary_exprs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cad_position = CadPosition.find(params[:id])\n @cad_position.destroy\n\n respond_to do |format|\n format.html { redirect_to(cad_positions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @position = Position.find(params[:id])\n @position.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_positions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(scrap_xmls_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @position = Position.find(params[:id])\n @position.destroy\n\n respond_to do |format|\n format.html { redirect_to(positions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @executive_position = ExecutivePosition.find(params[:id])\n @executive_position.destroy\n\n respond_to do |format|\n format.html { redirect_to(executive_positions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @survey_position = SurveyPosition.find(params[:id])\n @survey_position.destroy\n\n respond_to do |format|\n format.html { redirect_to(survey_positions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @formula.destroy\n\n respond_to do |format|\n format.html { redirect_to(formulas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @v1_data_element = V1DataElement.find(params[:id])\n @v1_data_element.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_data_elements_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @position = Position.find(params[:id])\n @position.destroy\n\n respond_to do |format|\n format.html { redirect_to(template_positions_url(@template)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expression = Expression.find(params[:id])\n @expression.destroy\n\n respond_to do |format|\n format.html { redirect_to(expressions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ppos = Ppos.find(params[:id])\n @ppos.destroy\n\n respond_to do |format|\n format.html { redirect_to(ppos_url) }\n format.xml { head :ok }\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
takes a code returned by wepay oauth2 authorization and makes an api call to generate oauth2 token for this farmer.
def request_wepay_access_token(code, redirect_uri) response = GemsUsage::Application::WEPAY.oauth2_token(code, redirect_uri) if response['error'] raise "Error - "+ response['error_description'] elsif !response['access_token'] raise "Error requesting access from WePay" else self.wepay_access_token = response['access_token'] self.save self.create_wepay_account end end
[ "def request_wepay_access_token(code, redirect_uri)\n response = WEPAY.oauth2_token(code, redirect_uri)\n if response['error']\n raise \"Error - \"+ response['error_description']\n elsif !response['access_token']\n raise \"Error requesting access from WePay\"\n else\n self.wepay_access_token = response['access_token']\n self.save\n\n\t#create WePay account\n self.create_wepay_account\n end\nend", "def request_wepay_access_token(code, redirect_uri)\n response = TradeArtCollective::Application::WEPAY.oauth2_token(code, redirect_uri)\n if response['error']\n raise \"Error - \"+ response['error_description']\n elsif !response['access_token']\n raise \"Error requesting access from WePay\"\n else\n self.wepay_access_token = response['access_token']\n self.save\n\n #create WePay account\n self.create_wepay_account\n end\n end", "def exchange_code(code)\n oidc_response = faraday_connection.post(\n token_endpoint,\n grant_type: 'authorization_code',\n client_id: client_id,\n client_secret: client_secret,\n code: code,\n redirect_uri: Rails.application.routes.url_helpers.launch_callback_url\n )\n\n JWT.decode(oidc_response.body.id_token, nil, false, algorithm: 'RS256').first\n end", "def exchange_code_for_token(api, client, auth_code)\n client.auth_code.get_token(auth_code, redirect_uri: api.oauth_redirect)\n rescue OAuth2::Error => e\n fail_with_oauth_error(\n \"Failed to exchange auth_code for token (code=#{e.response.status})\",\n e.response\n )\n end", "def get_access_token\n unless params[:code].blank?\n auth_obj = ZendeskAuth.new(session[:subdomain],session[:identifier],session[:secret],authorizations_get_access_token_url)\n auth_obj.code = params[:code]\n response = auth_obj.get_access_token\n save_access_token(response)\n else\n redirect_to return_message(\"error\",\"auth_code_not_found\") and return\n end\n end", "def token_call(options={})\n c = Curl::Easy.new(options[:token_endpoint])\n c.resolve_mode = :ipv4\n qs = URI.decode({\n grant_type: \"authorization_code\",\n client_id: options[:client_id],\n client_secret: options[:client_secret],\n code: options[:code],\n redirect_uri: options[:redirect_uri]\n }.to_query)\n logger.debug \"token call query string: #{qs}\"\n c.http_post(qs)\n if c.response_code != 200\n logger.error \"token call Response code from #{options[:token_endpoint]} is #{c.response_code}\"\n logger.error \"body: #{c.body_str}\"\n return nil\n end\n if c.body_str\n obj = JSON.parse(c.body_str)\n obj.symbolize_keys!\n return obj\n end\n end", "def exchange_code(code)\n return nil unless token_account\n return nil unless token_account['token_endpoint']\n\n response = request(\n http_method: token_account['token_method'].downcase.to_sym,\n path: token_account['token_endpoint'],\n headers: { CONTENT_TYPE => token_account['token_post_content_type'] },\n body: {\n 'grant_type' => 'authorization_code',\n 'code' => code,\n 'client_id' => Kontena::Client::CLIENT_ID,\n 'client_secret' => Kontena::Client::CLIENT_SECRET\n },\n expects: [200,201],\n auth: false\n )\n response['expires_at'] ||= in_to_at(response['expires_in'])\n response\n end", "def authenticate_token(code)\n parameters = {\n :grant_type => @grant_type,\n :code => code.to_s\n }\n\n @oauth_token = getNewToken(parameters)\n end", "def exchange!\n raise Vidibus::Oauth2Server::InvalidCodeError unless code\n raise Vidibus::Oauth2Server::ExpiredCodeError unless code_expires_at >= Time.now\n self.code = nil\n self.code_expires_at = nil\n self.token = SecureRandom.hex(60)\n self.token_expires_at = Time.now + TOKEN_EXPIRY if TOKEN_EXPIRY > 0\n save!\n return code\n end", "def request_token( code )\n _request _token_params( code )\n end", "def access_token(code)\n\n response = connection.post do |req|\n req.url \"/app-center/oauth/access_token\"\n req.headers['Content-Type'] = 'application/json'\n req.body = {:client_id => client_id, :client_secret => client_secret, :authorization_code => code}.to_json\n end\n\n if response.success?\n OpenStruct.new(response.body)\n else\n response = connection.post do |req|\n req.url \"/app-center/oauth/access_token\"\n req.headers['Content-Type'] = 'application/json'\n req.body = {:client_id => client_id, :client_secret => client_secret, :authorization_code => code}.to_json\n end\n if response.success?\n OpenStruct.new(response.body)\n else\n response = connection.post do |req|\n req.url \"/app-center/oauth/access_token\"\n req.headers['Content-Type'] = 'application/json'\n req.body = {:client_id => client_id, :client_secret => client_secret, :authorization_code => code}.to_json\n end\n \n if response.success?\n OpenStruct.new(response.body)\n else\n raise Error.new(response.body[\"error_description\"])\n end\n end\n end\n end", "def get_authorization_code_with_http_info(selling_partner_id, developer_id, mws_auth_token, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AuthorizationApi.get_authorization_code ...'\n end\n # verify the required parameter 'selling_partner_id' is set\n if @api_client.config.client_side_validation && selling_partner_id.nil?\n fail ArgumentError, \"Missing the required parameter 'selling_partner_id' when calling AuthorizationApi.get_authorization_code\"\n end\n # verify the required parameter 'developer_id' is set\n if @api_client.config.client_side_validation && developer_id.nil?\n fail ArgumentError, \"Missing the required parameter 'developer_id' when calling AuthorizationApi.get_authorization_code\"\n end\n # verify the required parameter 'mws_auth_token' is set\n if @api_client.config.client_side_validation && mws_auth_token.nil?\n fail ArgumentError, \"Missing the required parameter 'mws_auth_token' when calling AuthorizationApi.get_authorization_code\"\n end\n # resource path\n local_var_path = '/authorization/v1/authorizationCode'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'sellingPartnerId'] = selling_partner_id\n query_params[:'developerId'] = developer_id\n query_params[:'mwsAuthToken'] = mws_auth_token\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', 'payload', 'errors'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n return_type = opts[:return_type] || 'GetAuthorizationCodeResponse' \n\n auth_names = opts[:auth_names] || []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AuthorizationApi#get_authorization_code\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_token(auth_code)\n resp = connection.post(config.base_path) do |req|\n req.headers = headers\n req.body = \"client_id=#{Settings.dhp.fitbit.client_id}\" \\\n \"&code=#{auth_code}\" \\\n \"&code_verifier=#{CODE_VERIFIER}\" \\\n '&grant_type=authorization_code' \\\n \"&redirect_uri=#{Settings.dhp.fitbit.redirect_uri}\"\n end\n\n raise \"response code: #{resp.status}, response body: #{resp.body}\" unless resp.status == 200\n\n JSON.parse(resp.body, symbolize_names: true)\n rescue => e\n raise TokenExchangeError, e.message.to_s\n end", "def oauth_complete(code)\n # Let's compile the API URL we're calling.\n url = PUTIO_BASE_URL + \"/oauth2/access_token?client_id=%i&client_secret=%s&grant_type=authorization_code&redirect_uri=%s&code=%s\" % [@client_id, @application_secret, @redirect_uri, code]\n \n # And call it.\n response = Curl::Easy.perform(url) do |req|\n req.headers['Accept'] = 'application/json'\n end\n\n # Use Crack to parse the JSON\n response = JSON.parse(response.body_str)\n\n # And use Hashie to present it.\n response = Hashie::Mash.new(response)\n\n # Save it locally.\n @access_token = response.access_token\n\n # Return it\n response\n end", "def do_token(params, clientId, clientSecret)\n # Call Authlete's /auth/token API.\n response = call_token_api(params, clientId, clientSecret)\n\n # The content of the response to the client.\n content = response[\"responseContent\"]\n\n # \"action\" denotes the next action.\n case response[\"action\"]\n when \"INVALID_CLIENT\"\n # 401 Unauthorized\n # Client authentication failed.\n return WebResponse.new(401, content).json\\\n .wwwAuthenticate(\"Basic realm=\\\"/token\\\"\").to_response\n\n when \"INTERNAL_SERVER_ERROR\"\n # 500 Internal Server Error\n # The API request from this implementation was wrong\n # or an error occurred in Authlete.\n return WebResponse.new(500, content).json.to_response\n\n when \"BAD_REQUEST\"\n # 400 Bad Request\n # The token request from the client was wrong.\n return WebResponse.new(400, content).json.to_response\n\n when \"PASSWORD\"\n # Process the token request whose flow is\n # \"Resource Owner Password Credentials\".\n return handle_password(response)\n\n when \"OK\"\n # 200 OK\n # The token request from the client was valid. An access\n # token is issued to the client application.\n return WebResponse.new(200, content).json.to_response\n\n else\n # This never happens.\n return WebResponse.new(500, \"Unknown action\").plain.to_response\n end\nend", "def get_fitbit_token(code)\n @fitbit_oauth_client.site = \"https://api.fitbit.com\" \n @fitbit_token = @fitbit_oauth_client.auth_code.get_token(code,:redirect_uri => ENV['FITBIT_REDIRECT_URL'] ,:headers =>{'Authorization' => \"Basic #{@base64_id_secret}\",'Body' => \"client_id=#{@fitbit_oauth_client.id}\"})\n end", "def fetch_access_token code\n access_token_from_response https_post(auth_host, auth_token_path, token_req_params(code))\n end", "def get_token(code)\n uri = URI.parse(\"https://api.dropboxapi.com/oauth2/token\")\n\n payload = URI.encode_www_form(\n client_id: DROPBOX_APP_KEY,\n client_secret: DROPBOX_APP_SECRET,\n code: code,\n grant_type: \"authorization_code\",\n redirect_uri: SHOTTY_CALLBACK_URL,\n )\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n\n response = http.post(uri.path, payload, {})\n\n body = JSON.parse(response.body)\n\n body[\"access_token\"]\nend", "def _finish(code, original_redirect_uri)\n if not code.is_a?(String)\n raise ArgumentError, \"code must be a String\"\n end\n\n uri = URI.parse(\"https://#{Dropbox::API_SERVER}/1/oauth2/token\")\n request = Net::HTTP::Post.new(uri.request_uri)\n client_credentials = @consumer_key + ':' + @consumer_secret\n request.add_field('Authorization', 'Basic ' + Base64.encode64(client_credentials).chomp(\"\\n\"))\n\n params = {\n \"grant_type\" => \"authorization_code\",\n \"code\" => code,\n \"redirect_uri\" => original_redirect_uri,\n \"locale\" => @locale,\n }\n\n request.set_form_data(Dropbox::clean_params(params))\n\n response = Dropbox::do_http(uri, request)\n\n j = Dropbox::parse_response(response)\n [\"token_type\", \"access_token\", \"uid\"].each { |k|\n if not j.has_key?(k)\n raise DropboxError.new(\"Bad response from /token: missing \\\"#{k}\\\".\")\n end\n if not j[k].is_a?(String)\n raise DropboxError.new(\"Bad response from /token: field \\\"#{k}\\\" is not a string.\")\n end\n }\n if j[\"token_type\"] != \"bearer\" and j[\"token_type\"] != \"Bearer\"\n raise DropboxError.new(\"Bad response from /token: \\\"token_type\\\" is \\\"#{token_type}\\\".\")\n end\n\n return j['access_token'], j['uid']\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve all template information. Build an array of template ids here over which to iterate
def retrieve_all_template_info puts "Retrieving all template ids and names for #{@primary_username} ..." puts uri = URI(@config['endpoint']) # Retrieve templates http = Net::HTTP.new( uri.host,uri.port ) http.use_ssl = true request = Net::HTTP::Get.new( uri.request_uri ) request.basic_auth(@primary_username, @primary_password) response = http.request( request ) templates = JSON.parse( response.body ) # Create template_id array @template_array = Array.new # Create a template hash w/ name and id for each template found templates['templates'].each do |t| @template_array.push({:id => t['id'], :name => t['name']}) end # Return constructed temmplate array return template_array end
[ "def child_templates\n\t\tif template_ids == \"all\" then\n\t\t\treturn Template.all\n\t\telse\n\t\t\tTemplate.where(:id => template_ids.split(\",\")).all\n\t\tend\n\tend", "def find_many(options = {})\n client.find_many(Spire::Production::Template, \"/production/templates/\", options)\n end", "def getScanTemplatesbyId()\r\n templateinfo = {}\r\n self.list_scan_templates.each { |template|\r\n templateinfo[template.id] = template.name\r\n }\r\n return templateinfo\r\n end", "def list\n @client.make_request :get, templates_path\n end", "def get_ids_by_host(data)\n result = []\n @client.api_request(:method => \"template.get\", :params => data).each do |tmpl|\n result << tmpl['templateid']\n end\n result\n end", "def details\n response = get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def index\n @template = Template.find(params[:template_id])\n @template_parameters = TemplateParameter.where(template_id: params[:template_id])\n end", "def templates\n extracted_templates = []\n\n unless self.templates_list.nil? \n self.templates_list.each do |template|\n extracted_templates.push(Template.new(template))\n end\n end\n\n return extracted_templates \n end", "def details\n response = CreateSend.get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def getScanTemplatesbyName()\r\n templateinfo = {}\r\n self.list_scan_templates.each { |template|\r\n templateinfo[template.name] = template.id\r\n }\r\n return templateinfo\r\n end", "def vm_template_ids\n rc = info\n\n return rc if OpenNebula.is_error?(rc)\n\n ret = []\n\n @body['roles'].each do |role|\n t_id = Integer(role['vm_template'])\n ret << t_id unless ret.include?(t_id)\n end\n\n ret\n end", "def report_template_listing\n r = execute(make_xml('ReportTemplateListingRequest', {}))\n templates = []\n if (r.success)\n r.res.elements.each('//ReportTemplateSummary') do |template|\n desc = ''\n template.elements.each('description') do |ent|\n desc = ent.text\n end\n\n templates << {\n :template_id => template.attributes['id'],\n :name => template.attributes['name'],\n :description => desc,\n :scope => template.attributes['scope'],\n :type => template.attributes['type']\n # :builtin => template.attributes['builtin']\n }\n end\n end\n templates\n end", "def find_many(options = {})\n client.find_many(Spire::Production::TemplateItem, \"/production/template_items/\", options)\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def index\n @request_templates = RequestTemplate.all\n end", "def retrieve_email_templates()\n start.uri('/api/email/template')\n .get()\n .go()\n end", "def retrieve_email_templates()\n start.uri('/api/email/template')\n .get()\n .go()\n end", "def index\n authorize Template\n templates = Template.latest_version.where(customization_of: nil)\n published = templates.count { |t| t.published? || t.draft? }\n\n @orgs = Org.includes(identifiers: :identifier_scheme).managed\n @title = _('All Templates')\n @templates = templates.includes(:org).page(1)\n @query_params = { sort_field: 'templates.title', sort_direction: 'asc' }\n @all_count = templates.length\n @published_count = (published.presence || 0)\n @unpublished_count = if published.present?\n (templates.length - published)\n else\n templates.length\n end\n render :index\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve single template. This method will be iterative over the result of retrieve_all_template_info
def retrieve_single_template( template_id ) puts "Retrieving template id #{template_id}." uri = URI(@config['endpoint'] + '/' + template_id) # Retrieve templates http = Net::HTTP.new( uri.host,uri.port ) http.use_ssl = true request = Net::HTTP::Get.new( uri.request_uri ) request.basic_auth(@primary_username, @primary_password) response = http.request( request ) template = JSON.parse( response.body ) end
[ "def get(template_id)\n # TODO: Implement retrieve of a single template\n end", "def details\n response = get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def details\n response = CreateSend.get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def get_template(template_name)\n self.api_get(:template, {:template => template_name})\n end", "def get_template(template_name)\n api_get(:template, {:template => template_name})\n end", "def get_template(template, type)\n templates[template][type]\n end", "def template(name)\n @conn.templates.get(name)\n end", "def get_template(template_id, params = nil, headers = nil)\n get(\"/api/v2/templates/#{template_id}\", params, headers)\n end", "def get_template\n if self.template\n return self.template\n end\n Template.find_by(default: true)\n end", "def find_template(id:)\n response = get(\"templates/#{id}\")\n\n PhysitrackApi::Response.from(response)\n end", "def get_template(recurrent_template_id)\n send_request('GetTemplate', recurrent_template_id: recurrent_template_id)\n end", "def get(params = {})\n response = client.get \"/_template/{template}\", update_params(params, action: \"template.get\", rest_api: \"indices.get_template\")\n response.body\n end", "def template_details(guid)\n get \"/api/templates/#{guid}.xml\", {}\n end", "def get_template(template); end", "def fetch_template(name, return_container=false)\n result = bucket.files.get(generate_template_path(name))\n return_container ? result : result.body\n end", "def template\n if self.template_id\n Page.templates.find(self.template_id)\n else\n nil\n end\n end", "def template\n find_template(@template || conf['template'], @opts[:t])\n end", "def retrieve_template(opts)\n unless opts[:cache_key] && opts[:cache] != false\n found_template_opts = opts = find_template(opts)\n end\n cached_template(opts) do\n opts = found_template_opts || find_template(opts)\n template_opts = render_opts[:template_opts]\n if engine_opts = render_opts[:engine_opts][opts[:engine]]\n template_opts = Hash[template_opts].merge!(engine_opts)\n end\n if current_template_opts = opts[:template_opts]\n template_opts = Hash[template_opts].merge!(current_template_opts)\n end\n opts[:template_class].new(opts[:path], 1, template_opts, &opts[:template_block])\n end\n end", "def template(name)\n templates.get(name)\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a string or an IO object, this will attempt a parse of its contents and return a result. If the parse fails, a Parslet::ParseFailed exception will be thrown.
def parse(io) if io.respond_to? :to_str io = StringIO.new(io) end result = apply(io) # If we haven't consumed the input, then the pattern doesn't match. Try # to provide a good error message (even asking down below) unless io.eof? # Do we know why we stopped matching input? If yes, that's a good # error to fail with. Otherwise just report that we cannot consume the # input. if cause raise Parslet::ParseFailed, "Unconsumed input, maybe because of this: #{cause}" else error(io, "Don't know what to do with #{io.string[io.pos,100]}") end end return flatten(result) end
[ "def parse(io)\n source = Parslet::Source.new(io)\n context = Parslet::Atoms::Context.new\n \n result = nil\n value = apply(source, context)\n \n # If we didn't succeed the parse, raise an exception for the user. \n # Stack trace will be off, but the error tree should explain the reason\n # it failed.\n if value.error?\n parse_failed(value.message)\n end\n \n # assert: value is a success answer\n \n # If we haven't consumed the input, then the pattern doesn't match. Try\n # to provide a good error message (even asking down below)\n unless source.eof?\n # Do we know why we stopped matching input? If yes, that's a good\n # error to fail with. Otherwise just report that we cannot consume the\n # input.\n if cause \n # We're not using #parse_failed here, since it assigns to @last_cause.\n # Still: We'll raise this differently, since the real cause is different.\n raise Parslet::UnconsumedInput, \n \"Unconsumed input, maybe because of this: #{cause}\"\n else\n old_pos = source.pos\n parse_failed(\n format_cause(source, \n \"Don't know what to do with #{source.read(100)}\", old_pos), \n Parslet::UnconsumedInput)\n end\n end\n \n return flatten(value.result)\n end", "def parse(io_or_string, options = {})\n case io_or_string\n when String\n parse_string(io_or_string, options)\n when IO\n parse_io(io_or_string, options)\n end\n end", "def parse (io, &block)\n close_stream = false\n if io.is_a?(String)\n if io.include?('<') and io.include?('>')\n io = StringIO.new(io)\n else\n io = open(io)\n end\n close_stream = true\n elsif io.is_a?(Pathname)\n io = io.open\n close_stream = true\n elsif io.is_a?(URI)\n io = io.open\n close_stream = true\n end\n\n begin\n parser = parser_class(parser_name).new(&block)\n parser.parse_stream(io)\n return parser.root\n ensure\n io.close if close_stream\n end\n end", "def parse(string_or_io, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil)); end", "def parse(str)\n parse!(str)\n rescue\n nil\n end", "def pr str='', &blk\n err=nil\n begin\n if block_given?\n result = yield\n else\n result = interpret str\n end\n rescue Parslet::ParseFailed => err\n end\n [result, err]\nend", "def parse(options = {})\n options[:file] || options[:string] || (raise ParsleyError.new(\"must specify what to parse\"))\n \n options[:sgwrap] = !!options[:sgwrap]\n options[:is_file] = !!options[:file]\n options[:has_base] = !!options[:base]\n \n options[:base] = options[:base].to_s\n options[:file] = options[:file].to_s\n options[:string] = options[:string].to_s\n \n options[:input] ||= :html\n options[:output] ||= :ruby\n \n options[:collate] = true unless options.has_key?(:collate)\n options[:prune] = true unless options.has_key?(:prune)\n options[:allow_net] = true unless options.has_key?(:allow_net)\n options[:allow_local] = true unless options.has_key?(:allow_local)\n \n options[:collate] = !!options[:collate]\n options[:prune] = !!options[:prune]\n options[:allow_net] = !!options[:allow_net]\n options[:allow_local] = !!options[:allow_local]\n \n @parsley.parse(options)\n end", "def load(io_or_string, options = {})\n encoding_opt = options.delete :encoding\n encoding =\n encoding_opt ? Encoding.find(encoding_opt) : Encoding.default_external\n\n case io_or_string\n when String\n File.open(io_or_string, \"r:#{encoding}\"){|f|parse_io(f, options)}\n when IO\n parse_io(io_or_string, options)\n end\n end", "def parse_string(string, options = {}, &block)\n parse_io(StringIO.new(string), options, &block)\n end", "def parse(string, options = {}, &block)\n if string.length < 260 && File.exist?(string)\n Bibliography.open(string, options, &block)\n elsif string =~ %r{\\A[a-z]+://}i\n Bibliography.open(string, options)\n else\n Bibliography.parse(string, options)\n end\n end", "def parse text\n raise \"No parse defined for #{self.class}\"\n end", "def parse\n fail StandardError.new('parse has not been implemented.')\n end", "def parse(string_or_io, options = nil)\n ##\n # When the current node is unparented and not an element node, use the\n # document as the parsing context instead. Otherwise, the in-context\n # parser cannot find an element or a document node.\n # Document Fragments are also not usable by the in-context parser.\n if !element? && !document? && (!parent || parent.fragment?)\n return document.parse(string_or_io, options)\n end\n\n options ||= (document.html? ? ParseOptions::DEFAULT_HTML : ParseOptions::DEFAULT_XML)\n if Integer === options\n options = Nokogiri::XML::ParseOptions.new(options)\n end\n # Give the options to the user\n yield options if block_given?\n\n contents = string_or_io.respond_to?(:read) ?\n string_or_io.read :\n string_or_io\n\n return Nokogiri::XML::NodeSet.new(document) if contents.empty?\n\n # libxml2 does not obey the `recover` option after encountering errors during `in_context`\n # parsing, and so this horrible hack is here to try to emulate recovery behavior.\n #\n # Unfortunately, this means we're no longer parsing \"in context\" and so namespaces that\n # would have been inherited from the context node won't be handled correctly. This hack was\n # written in 2010, and I regret it, because it's silently degrading functionality in a way\n # that's not easily prevented (or even detected).\n #\n # I think preferable behavior would be to either:\n #\n # a. add an error noting that we \"fell back\" and pointing the user to turning off the `recover` option\n # b. don't recover, but raise a sensible exception\n #\n # For context and background: https://github.com/sparklemotion/nokogiri/issues/313\n # FIXME bug report: https://github.com/sparklemotion/nokogiri/issues/2092\n error_count = document.errors.length\n node_set = in_context(contents, options.to_i)\n if (node_set.empty? && (document.errors.length > error_count))\n if options.recover?\n fragment = Nokogiri::HTML4::DocumentFragment.parse contents\n node_set = fragment.children\n else\n raise document.errors[error_count]\n end\n end\n node_set\n end", "def parse thing\n if thing.respond_to?(:read) && thing.respond_to?(:close)\n parse_io(thing)\n else\n parse_memory(thing)\n end\n end", "def parse(io_or_string)\n io = io_or_string\n if io.is_a?(String)\n io = ProtocolBuffers.bin_sio(io)\n end\n Decoder.decode(io, self)\n return self\n end", "def wrap_io_or_string(io_or_str)\n return io_or_str if io_or_str.respond_to?(:read_one_char) # Bychar or R\n return R.new(io_or_str) if io_or_str.respond_to?(:read)\n R.new(StringIO.new(io_or_str))\n end", "def parse(string_or_io, options = nil)\n ##\n # When the current node is unparented and not an element node, use the\n # document as the parsing context instead. Otherwise, the in-context\n # parser cannot find an element or a document node.\n # Document Fragments are also not usable by the in-context parser.\n if !element? && !document? && (!parent || parent.fragment?)\n return document.parse(string_or_io, options)\n end\n\n options ||= (document.html? ? ParseOptions::DEFAULT_HTML : ParseOptions::DEFAULT_XML)\n options = Nokogiri::XML::ParseOptions.new(options) if Integer === options\n yield options if block_given?\n\n contents = if string_or_io.respond_to?(:read)\n string_or_io.read\n else\n string_or_io\n end\n\n return Nokogiri::XML::NodeSet.new(document) if contents.empty?\n\n # libxml2 does not obey the +recover+ option after encountering errors during +in_context+\n # parsing, and so this horrible hack is here to try to emulate recovery behavior.\n #\n # Unfortunately, this means we're no longer parsing \"in context\" and so namespaces that\n # would have been inherited from the context node won't be handled correctly. This hack was\n # written in 2010, and I regret it, because it's silently degrading functionality in a way\n # that's not easily prevented (or even detected).\n #\n # I think preferable behavior would be to either:\n #\n # a. add an error noting that we \"fell back\" and pointing the user to turning off the +recover+ option\n # b. don't recover, but raise a sensible exception\n #\n # For context and background: https://github.com/sparklemotion/nokogiri/issues/313\n # FIXME bug report: https://github.com/sparklemotion/nokogiri/issues/2092\n error_count = document.errors.length\n node_set = in_context(contents, options.to_i)\n if node_set.empty? && (document.errors.length > error_count)\n if options.recover?\n fragment = document.related_class(\"DocumentFragment\").parse(contents)\n node_set = fragment.children\n else\n raise document.errors[error_count]\n end\n end\n node_set\n end", "def read_string(error = nil)\n question.evaluate_response(String(read_input).strip)\n end", "def initialize(io_or_string)\n parser = GiftParser.new()\n case io_or_string\n when String\n # Add blank line to make sure we can parse.\n @root = parser.parse(io_or_string + \"\\n\\n\")\n when IO\n @root = parser.parse(io_or_string.read + \"\\n\\n\")\n end\n \n raise ArgumentError, \"Cannot parse GIFT input.\\nReason:\\n#{parser.failure_reason.inspect}\" if @root.nil?\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Construct a new atom that repeats the current atom min times at least and at most max times. max can be nil to indicate that no maximum is present. Example: match any number of 'a's str('a').repeat match between 1 and 3 'a's str('a').repeat(1,3)
def repeat(min=0, max=nil) Parslet::Atoms::Repetition.new(self, min, max) end
[ "def repeat(min, max=nil)\n if min && max\n Rexp.new(parenthesized_encoding(POSTFIX) + apply_greedy(\"{#{min},#{max}}\"), POSTFIX, capture_keys)\n else\n Rexp.new(parenthesized_encoding(POSTFIX) + \"{#{min}}\", POSTFIX, capture_keys)\n end\n end", "def rep(rule, min=1, max=Infinity, &block)\n ext(Repeat.new(rule, min, max), block)\n end", "def rep(rule, min=1, max=Infinity, &block)\n ext(Repeat.new(min, max, rule), block)\n end", "def rep(rule, min=1, max=Infinity, &block)\n ext(Repeat.new(rule, min, max), block)\n end", "def repeat min = nil, max = nil\n ParsletRepetition.new self.to_parseable, min, max\n end", "def at_most(max)\n Rexp.new(parenthesized_encoding(POSTFIX) + apply_greedy(\"{0,#{max}}\"), POSTFIX, capture_keys)\n end", "def genWord(max, min = 3)\n\t\tlen = rand(max-min) + min\n\t\t#if len == 0 then puts \"zero\" end\n\t\t[*('a'..'z')].sample(len).join\n\tend", "def at_least(min)\n Rexp.new(parenthesized_encoding(POSTFIX) + apply_greedy(\"{#{min},}\"), POSTFIX, capture_keys)\n end", "def limit!(max_size: nil, min_occurence: nil)\n # @todo raise if frozen\n if min_occurence\n @tokens.delete_if {|name, data| data[1] < min_occurence }\n end\n if max_size\n @tokens = Hash[@tokens.to_a.sort_by {|a| -a[1][1] }[0..(max_size-1)]]\n end\n @tokens.length\n end", "def *(at_most = nil)\n return Repetition.new(\"#{self.name}*#{at_most}\", self, 0, at_most)\n end", "def max_rep; end", "def shortest_repetition(str)\nend", "def max_matches\n @max_matches || 1000\n end", "def shorten( gen, max )\n return gen.clone if gen.size <= max\n point = @stochastic ? (@random.rand( gen.size+1-max ) + max) : max\n gen.clone[0...point]\n end", "def circular_primes(max)\n primes = primes(max)\n results = []\n \n primes.each do |prime|\n results << prime\n length = prime.to_s.length\n shift = 0\n while shift < length\n unless primes.include?(prime.to_s.split(\"\").rotate(shift).join.to_i)\n results.pop\n break\n end\n shift += 1\n end\n end\n \n results \nend", "def build_with_hash_and_max(hash = nil, max = nil)\n hash ||= Hash.new(false)\n set = new\n set.instance_variable_set(:@hash, hash)\n\n max = yield(hash) if block_given?\n raise ArgumentError, 'pass a comparable max' unless max.respond_to?(:<=>)\n\n hash.freeze\n set.instance_variable_set(:@max, max)\n set\n end", "def prune( str, max )\n out = str.dup\n\n # keep pruning so long as the string is prunable and the length is over maximum\n while out.match? @prune_notation and out.delete( '<>' ).size > max\n # what parts of the string can be pruned?\n matches = out.scan( @prune_notation ).map { |match| match[0] }\n # pick a random nth one of these\n idx = rand( matches.size )\n # init at -1 so we can increment at the beginning of the iteration\n i = -1\n # iterate over each match, but only delete the nth match\n out.gsub!( @prune_notation ) do |match|\n i += 1\n if i != idx then match else '' end\n end\n end\n\n out.delete( '<>' )\nend", "def max_concurrent_group_searches(max)\n @hash[:max_concurrent_group_searches] = max\n self\n end", "def minmax(board)\n max = 1000\n min = -1000\n counter = []\n\n if board.valid_move?(\"5\")\n attack = \"5\"\n else\n sampi_one = [2,4,6,8].sample\n if board.valid_move?(sampi_one)\n attack = sampi_one\n else\n sampi_two = [1,3,7,9].sample\n board.valid_move?(sampi_two)\n attack = sampi_two\n end\n end\n\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new parslet atom that is only maybe present in the input. This is synonymous to calling repeat(0,1). Generated tree value will be either nil (if atom is not present in the input) or the matched subtree. Example: str('foo').maybe
def maybe Parslet::Atoms::Repetition.new(self, 0, 1, :maybe) end
[ "def set_if_nil(word, value)\n current = @root\n current_prefix = word\n\n while current_prefix != \"\"\n current, current_prefix = find_canididate_insertion_node(current, current_prefix)\n end\n\n current[:value] ||= value\n return current[:value]\n end", "def any?\n return Repetition.new(self.parser,\"#{self.name}?\", self, 0, 1)\n end", "def maybe(*args, **opts, &block)\n extract_type_spec(*args, nullable: true) do |*predicates, type_spec:, type_rule:|\n append_macro(Macros::Maybe) do |macro|\n macro.call(*predicates, type_spec: type_spec, type_rule: type_rule, **opts, &block)\n end\n end\n end", "def maybe(name, opts)\n new_rule(:maybe, name, opts)\n end", "def maybe\n self\n end", "def first_or_null(sym,val)\n _where(sym, val, 1).first || ChooChoo::NullSegment.new(document_type)\n end", "def find_empty_position(item, position)\n\n if [:arm, :leg, :wield, :wrist, :foot, :ankle, :ring_finger, :ear, :hand].include? position\n return find_empty_position(item, \"left_#{position}\".to_sym) || find_empty_position(item, \"right_#{position}\".to_sym)\n end\n\n if @equipment[position] and @equipment[position][item.layer]\n nil\n else\n position\n end\n end", "def repeat0(term=nil)\n term ? Right { |g| term | self + g } : Right { |g| self + g | NULL }\n end", "def wrap_with_maybe(&block)\n ->(*args) { maybe{ block.call(*args) } }\n end", "def join_empty(yes_no_or_strict)\n one_of [true, false, :strict], :joinempty => yes_no_or_strict\n end", "def get_item_for_placeholder_if_exists_or_create_it _ph\n # Controllo che non mi stiano passando nil come argomento\n raise InvalidNameForPlaceholder.new(\"\") if _ph.blank?\n i = item_for _ph\n return i unless i.nil?\n new_item = Item.new(_ph, '')\n add_item new_item\n new_item\n end", "def absent?\n Parslet::Atoms::Lookahead.new(self, false)\n end", "def create_optional( element )\n return Util::ExpressionForms::Optional.new( element )\n end", "def _XsdOptional\n\n _save = self.pos\n while true # choice\n\n _save1 = self.pos\n while true # sequence\n _tmp = match_string(\"xsd_optional\")\n unless _tmp\n self.pos = _save1\n break\n end\n _tmp = apply(:__hyphen_)\n unless _tmp\n self.pos = _save1\n end\n break\n end # end sequence\n\n break if _tmp\n self.pos = _save\n _tmp = apply(:_nothing)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_XsdOptional unless _tmp\n return _tmp\n end", "def _junk\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_SEPARATOR)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_COMMA)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_JUNK_EXPR)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_junk unless _tmp\n return _tmp\n end", "def find_concatenated(word)\n [].tap { |a| probe_words(0, word, a) }\n end", "def pure(x)\n Some.new(x)\n end", "def repeat1(term=nil)\n term ? Right { |g| self + (term | g) } : self + repeat0\n end", "def get_or_create(char)\n @children[char] ||= Node.new\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests for absence of a parslet atom in the input stream without consuming it. Example: Only proceed the parse if 'a' is absent. str('a').absnt?
def absnt? Parslet::Atoms::Lookahead.new(self, false) end
[ "def absent?\n Parslet::Atoms::Lookahead.new(self, false)\n end", "def assert_doesnt_parse(input, rule=nil, msg=nil)\n msg = \"not able to parse: #{input}\" if msg.nil?\n r = @parser.parse(input, rule)\n assert_nil r, msg\n nil\n rescue Anagram::Parsing::ParseError\n assert true, msg\n end", "def parse_none\n throw_custom(\"This cannot happen\")\n return nil\n end", "def meaningless?(param)\n (param.is_a?(String) and param.to_s.strip.blank?)\n end", "def verify\n if @parsebuf != '' then\n puts \"Unparsed data:\", @parsebuf\n raise \"Parse error: some text still unparsed\"\n end\n end", "def reject\n parser do |input|\n result = self[input]\n\n if result.success?\n Failure(\"Unexpected #{self.to_s}\", result.remaining)\n else\n Success(Empty(), input)\n end\n end.describe(\"!#{self.to_s}\")\n end", "def test_parse_line_empty\r\n input = []\r\n val = 0\r\n assert_output(\"\") {val = @arg_checker.parse_line(input)}\r\n assert_nil val\r\n end", "def parse_real(input)\n return nil\n end", "def gets_non_empty\n until eof?\n line = gets\n return nil if line.nil?\n s = line.strip\n return s unless s.empty?\n end\n end", "def says_nothing?(message)\n message.strip.empty?\n end", "def atom_safe?( str )\n not ATOM_UNSAFE === str\n end", "def is_missing?(value)\n value.nil? or (String===value and value.strip.empty?)\n end", "def check_string(string)\n string.empty? ? nil : string\n end", "def bad_input?(string)\n string.nil? || string.empty?\n end", "def nil_if_unspecified(str)\n str == 'unspecified' ? nil : str\n end", "def atom_safe?(str); end", "def parse_blank_line; end", "def argument?(input)\n !(input =~ /^--?/).nil?\n end", "def test_parser_handles_empty_simple_content\n simple_content_assert nil, nil\n simple_content_assert nil, ''\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Report/raise a parse error with the given message, printing the current position as well. Appends 'at line X char Y.' to the message you give. If +pos+ is given, it is used as the real position the error happened, correcting the io's current position.
def error(io, str, pos=nil) pre = io.string[0..(pos||io.pos)] lines = Array(pre.lines) if lines.empty? formatted_cause = str else pos = lines.last.length formatted_cause = "#{str} at line #{lines.count} char #{pos}." end @last_cause = formatted_cause raise Parslet::ParseFailed, formatted_cause, nil end
[ "def error(message, error_pos=nil)\n real_pos = (error_pos||self.pos) \n \n Cause.format(self, real_pos, message)\n end", "def error(msg)\n raise \"#{msg} :#{@file}:#{@line}\"\n end", "def parse_error(msg)\n crash \"PARSE\", msg\n end", "def raise_error(message, line, col = 0, length = 0)\n line, col, length = line.line_num, line.column, line.length if line.is_a? Token\n\n header = \"#{@file}##{line}: \"\n str = \"Error: #{message}\\n\".red\n str << \"#{@file}##{line - 1}: #{@source.lines[line - 2].chomp}\\n\".light_black if line > 1\n str << \"#{header}#{(@source.lines[line - 1] || \"\").chomp}\\n\"\n str << (' ' * (col + header.length - 1))\n str << '^' << ('~' * (length - 1)) << \"\\n\"\n str << \"#{@file}##{line + 1}: #{@source.lines[line].chomp}\\n\".light_black if @source.lines[line]\n raise str\n end", "def positioned_message msg\n result = [msg]\n result << \"in file #{file}\" if file\n result << \"at line #{line}:#{pos}\" if line\n result.join(\" \")\n end", "def annotate_error_message(message)\n return \"#{$0}: #{message}\" unless @path\n return \"#{$0}: #{message} in file: #{@path}\" unless @line_number\n return \"#{$0}: #{message} in file: #{@path} at line: #{@line_number}\"\n end", "def parse_position(errmsg, arg)\n colon = arg.rindex(':') \n if colon\n # FIXME: Handle double colons, e.g. File::open\n filename = arg[0..colon-1].rstrip\n m, f = lookupmodule(filename)\n if not f\n errmsg.call(\"'%s' not found using sys.path\" % filename)\n return nil, nil, nil\n else\n filename = f\n arg = arg[colon+1..-1].lstrip\n end\n begin\n lineno = Integer(arg)\n rescue \n errmsg.call(\"Bad line number: %s\", arg)\n return nil, filename, nil\n end\n return nil, filename, lineno\n end\n return nil, nil, nil\n end", "def pos2coord(pos)\n # Count the amount of newlines between the beginning of the parsed\n # text and pos. Then, count the column as an offset from the last \n # newline\n #\n num_newlines = @text[0..pos].scan(%r{\\n}).size\n line_offset = @text[0..pos].rindex(\"\\n\")\n line_offset = 0 if line_offset < 0\n \n \"[line #{num_newlines + 1}, column #{pos - line_offset}]\"\n end", "def known_message(pos)\n message = message_with_pre_set_char(pos) || message_with_space(pos)\n OTP.log.warn \"Failed to determine any character for position #{pos}\" if message.nil?\n message\n end", "def pos_out_of_range(position)\n Error \"Position out of range! (#{position}) given, \" \\\n \"but the minefield is #{@num_cells} long.\"\n end", "def token_error(msg)\n crash \"TOKEN\", msg + \" at line \" + @@lineCount.to_s\n end", "def error(exp,index)\n e = \"Sintax Error: cannot match char at index #{index + 1}:\\n#{exp}\\n#{\" \" * index}^\"\n raise e\n end", "def throw_error(msg, cur_tok)\n\t\tif cur_tok == nil\n\t\t\traise \"PARSING ERROR WITH NIL TOKEN (SHOULD NOT HAPPEN) >> \" + msg\n\t\tend\n\t\traise \"PARSING ERROR: At line: #{cur_tok.line}, col: #{cur_tok.col}, token: #{cur_tok} >> \" + msg\n\tend", "def raise_parser_error(msg = 'Unknown')\n print_token_stack\n\n err = \"\nParser Exception!\n-----------------\nState: #{@state}\nCommand State: #{@state_arg || 'None'}\n-----------------\n\nWhile attempting to parse tokenized input, we encountered the following error:\n** #{msg} **\"\n raise ParserError, err\n end", "def output_error(msg, file, line_num)\n loc = file + ', line ' + (line_num + 1).to_s + ': '\n printf \"%-90s %s\\n\", loc, msg\n return true \nend", "def add_pos(pos)\n unless pos.is_a?(Position)\n warn(\"Invalid Position #{pos} for Line #@name\")\n return\n end\n if split?\n @pos.push(pos)\n return split_id(@pos.count)\n else\n @pos = pos\n end\n end", "def error(line_or_token, message)\n if line_or_token.is_a?(Numeric)\n report line_or_token, \"\", message\n elsif line_or_token.is_a?(Token)\n # Call specialized helper method\n error_with_token(line_or_token, message)\n else\n # Don't know chat to do if neither a number nor a Token is passed.\n raise \"Illegal type #{line_or_token.class} given.\"\n end\n end", "def error(message, line, column)\n @report.add(:error, message, line, column) if @report\n end", "def on_parse_error(msg)\n @errors ||= []\n @errors << msg\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if a password reset has expired.
def password_reset_expired? reset_sent_at < 2.hours.ago end
[ "def password_reset_expired?\n reset_sent_at < Settings.timeout_reset_password.hours.ago\n end", "def password_reset_expired?\n reset_sent_at < 2.hours.ago # The password reset was sent earlier than two hours ago.\n end", "def password_reset_expired?\n reset_sent_at < PASSWORD_EXPIRATION.hours.ago\n end", "def password_reset_expired?\n reset_sent_at < 2.hours.ago # reset_sent_at db polje datetime\n end", "def reset_password_key_expired?\n self.reset_password_key_expires_at < Time.now\n end", "def password_expired?\n password_expires_at = FieldType::Timestamp.encode(pwdLastSet) + AD_PASSWORD_EXPIRATION_DURATION\n now = FieldType::Timestamp.encode(Time.now)\n (password_expires_at < now)\n end", "def reset_password_period_valid?\n reset_within = Authenticate.configuration.reset_password_within.ago.utc\n return true if reset_within.nil?\n self.password_reset_sent_at && self.password_reset_sent_at.utc >= reset_within\n end", "def check_expiration\n if @agent.password_reset_expired?\n flash[:danger] = \"Password reset has expired.\"\n redirect_to new_password_reset_url\n end\n end", "def reset_password_period_valid?\n reset_password_sent_at && reset_password_sent_at.utc >= self.class.reset_password_within.ago.utc\n end", "def password_token_valid?\n (self.reset_password_sent_at + 1.hours) > Time.now.utc\n end", "def reset_password_period_valid?\n reset_password_sent_at && Time.at(reset_password_sent_at).to_datetime.utc >= self.class.reset_password_within.ago\n end", "def password_token_valid?\n (self.reset_password_sent_at + 4.hours) > Time.now.utc\n end", "def password_expired?\n self.attempted_record.password_expired?\n end", "def check_password_expired?\n !days_to_password_expiry.nil? && days_to_password_expiry <= 0\n end", "def can_request_password_reset?\n reset_password_key_created_at.nil? || ((Time.now - reset_password_key_created_at) > 1.minute)\n end", "def password_resettable?\n token = password_reset_token\n !!(token && !token.expired? && !token.confirmed?)\n end", "def password_expiring_soon?\n set_default_password_expiration\n return unless password_updated_at < (self.class.expire_password_after - self.class.remind_days_before).days.ago\n\n ((password_updated_at - self.class.expire_password_after.days.ago) / 1.day).to_i\n end", "def recently_reset_password?\n @reset_password\n end", "def confirmation_reset_expired?\n confirmation_sent_at < 48.hours.ago\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /fnf_items GET /fnf_items.json
def index @fnf_items = FnfItem.all end
[ "def index\n @ft_items = FtItem.all\n end", "def show\n @items = Item.find(params[:id])\n render json: @items\n end", "def show\n require 'net/http'\n require 'json'\n\n response = Net::HTTP.get_response( URI.parse( \"http://freeshit.firebaseio.com/items/%s.json\" % [ params[:id] ] ) );\n\n begin\n @fb_item = JSON.parse(response.body)\n rescue\n render :status => 404, :text => 'Item not found.'\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fb_item }\n end\n end", "def getItems()\n return mergeWithAPI(@item_json)['data']\n end", "def show\n json_response(@food_item)\n end", "def query_items(options={}) path = \"/api/v2/items\"\n get(path, options, AvaTax::VERSION) end", "def index\n @foil_items = FoilItem.all\n end", "def index\n json_response(current_restaurant.restaurant_food_items)\n end", "def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end", "def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end", "def show\n @food_item = FoodItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_item }\n end\n end", "def show\n @fooditem = Fooditem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @fooditem }\n end\n end", "def get_items\n if self.get_type != \"array\"\n return {}\n end\n return @payload.get_path(\"items\"){{}}\n \n end", "def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end", "def list_items(params = nil, headers = nil)\n get(\"/api/v2/items\", params, headers)\n end", "def index\n @specific_items = SpecificItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @specific_items }\n end\n end", "def item\n # Url generated from Js script function => getitem() of _form.html.erb file under Views of different controllers\n @item = Report.where(\"user_id = ?\" , current_user.id).pluck(:item_name )\n # send item_names' in form of json\n render json: @item\n end", "def list_items(params = nil, headers = nil)\n get(\"/api/v1/items\", params, headers)\n end", "def index\n render json: RequestItem.all\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /fnf_items POST /fnf_items.json
def create @fnf_item = FnfItem.new(fnf_item_params) respond_to do |format| if @fnf_item.save format.html { redirect_to @fnf_item, notice: 'Fnf item was successfully created.' } format.json { render :show, status: :created, location: @fnf_item } else format.html { render :new } format.json { render json: @fnf_item.errors, status: :unprocessable_entity } end end end
[ "def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end", "def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end", "def create\n @ft_item = FtItem.new(ft_item_params)\n\n respond_to do |format|\n if @ft_item.save\n format.html { redirect_to @ft_item, notice: 'Ft item was successfully created.' }\n format.json { render :show, status: :created, location: @ft_item }\n else\n format.html { render :new }\n format.json { render json: @ft_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @request_item = RequestItem.new(request_item_params)\n @request_item.item = Item.new(name: params[:request_item][:item][:name])\n\n if @request_item.save\n render json: @request_item \n else\n render json: @request_item.errors, status: :bad_request\n end\n end", "def create\n item = Item.new(item_params)\n item.done = \"0\"\n item.trash = \"0\"\n\n if item.save\n render json: {data:item}, status: :created\n else\n render json: {data:item}, status: :unprocessable_entity\n end\n end", "def create_item(params = nil, headers = nil)\n post(\"/api/v1/items\", params, headers)\n end", "def create_item(params = nil, headers = nil)\n post(\"/api/v2/items\", params, headers)\n end", "def create\n @fb_item = FbItem.new(params[:fb_item])\n\n respond_to do |format|\n if @fb_item.save\n format.html { redirect_to @fb_item, notice: 'Fb item was successfully created.' }\n format.json { render json: @fb_item, status: :created, location: @fb_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fb_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @foil_item = FoilItem.new(foil_item_params)\n\n respond_to do |format|\n if @foil_item.save\n format.html { redirect_to @foil_item, notice: 'Foil item was successfully created.' }\n format.json { render :show, status: :created, location: @foil_item }\n else\n format.html { render :new }\n format.json { render json: @foil_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fooditem = Fooditem.new(params[:fooditem])\n\n respond_to do |format|\n if @fooditem.save\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully created.' }\n format.json { render :json => @fooditem, :status => :created, :location => @fooditem }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @food_item = FoodItem.new(params[:food_item])\n\n respond_to do |format|\n if @food_item.save\n format.html { redirect_to @food_item, notice: 'Food item was successfully created.' }\n format.json { render json: @food_item, status: :created, location: @food_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @food_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @fnf_items = FnfItem.all\n end", "def create(params)\n @client.make_request(:post, 'customs_items', MODEL_CLASS, params)\n end", "def create\n @food_item = FoodItem.new(food_item_params)\n\n respond_to do |format|\n if @food_item.save\n format.html { redirect_to @food_item, notice: 'Food item was successfully created.' }\n format.json { render :show, status: :created, location: @food_item }\n else\n format.html { render :new }\n format.json { render json: @food_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_new_item(api, cookie, number, subject, newreq)\n item = nil\n option_hash = { content_type: :json, accept: :json, cookies: cookie }\n newitem = { number: number, clause: newreq['clauseno'], date: newreq['date'], standard: newreq['standard'],\n subject: subject }\n res = api[\"items\"].post newitem.to_json, option_hash unless $dryrun\n if res&.code == 201\n item = JSON.parse(res.body)\n reqres = add_request_to_item(api, cookie, item, newreq)\n end\n item\nend", "def add_item(params)\n # need to store that in state here\n # because listing_format won't be passed to update_item params (it's create-only param)\n params[:state][:listing_format] = params[:data_fields][:listing_format]\n process_response(client.call(:AddItem, item_params(params))).merge(id: params[:id])\n end", "def create\n @items_list = ItemsList.new(params[:items_list])\n\n respond_to do |format|\n if @items_list.save\n format.html { redirect_to @items_list, notice: 'Items list was successfully created.' }\n format.json { render json: @items_list, status: :created, location: @items_list }\n else\n format.html { render action: \"new\" }\n format.json { render json: @items_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.create(items_params)\n redirect_to root_url\n end", "def create\n @itemtipo = Itemtipo.new(itemtipo_params)\n\n if @itemtipo.save\n render json: @itemtipo, status: :created, location: @itemtipo\n else\n render json: @itemtipo.errors, status: :unprocessable_entity\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /fnf_items/1 PATCH/PUT /fnf_items/1.json
def update respond_to do |format| if @fnf_item.update(fnf_item_params) format.html { redirect_to @fnf_item, notice: 'Fnf item was successfully updated.' } format.json { render :show, status: :ok, location: @fnf_item } else format.html { render :edit } format.json { render json: @fnf_item.errors, status: :unprocessable_entity } end end end
[ "def update_item token, item_id, name, description\n uri = URI.parse \"https://#{get_hostname(token)}/sf/v3/Items(#{item_id})\"\n puts uri\n \n http = Net::HTTP.new uri.host, uri.port\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n \n item = {\"Name\"=>name, \"Description\"=>description}\n \n request = Net::HTTP::Patch.new uri.request_uri \n request[\"Content-Type\"] = \"application/json\"\n request[\"Authorization\"] = get_authorization_header(token)\n request.body = item.to_json\n \n response = http.request request\n puts \"#{response.code} #{response.message}\"\n \n if response.kind_of? Net::HTTPSuccess\n updated_item = JSON.parse response.body\n puts \"Updated Item: #{updated_item['Id']}\"\n end \nend", "def update\n json_response(@food_item.update!(food_item_params))\n end", "def _update_item(http, headers, path, body, name)\n resp = retry_request(http, \"PATCH\", path, body, headers)\n if resp.is_a?(Net::HTTPOK)\n Chef::Log.info(\"Updated keystone item '#{name}'\")\n else\n _raise_error(resp, \"Unable to update item '#{name}'\", \"_update_item\")\n end\nend", "def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item][:item].present? ? Item.new(name: params[:request_item][:item][:name]) : @request_item.item\n end\n #update all other parameters\n if @request_item.update(request_item_params)\n render json: @request_item\n else\n render json: @request_item.errors, status: :bad_request\n end\n\n end", "def update_rest\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = 'Item was successfully updated.'\n format.html { redirect_to(@item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ft_item.update(ft_item_params)\n format.html { redirect_to @ft_item, notice: 'Ft item was successfully updated.' }\n format.json { render :show, status: :ok, location: @ft_item }\n else\n format.html { render :edit }\n format.json { render json: @ft_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end", "def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end", "def update\n @request_item = RequestItem.find(params[:id])\n\n respond_to do |format|\n if @request_item.update_attributes(params[:request_item])\n format.html { redirect_to @request_item, notice: 'Request item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fb_item = FbItem.find(params[:id])\n\n respond_to do |format|\n if @fb_item.update_attributes(params[:fb_item])\n format.html { redirect_to @fb_item, notice: 'Fb item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fb_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foil_item.update(foil_item_params)\n format.html { redirect_to @foil_item, notice: 'Foil item was successfully updated.' }\n format.json { render :show, status: :ok, location: @foil_item }\n else\n format.html { render :edit }\n format.json { render json: @foil_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @fooditem = Fooditem.find(params[:id])\n\n respond_to do |format|\n if @fooditem.update_attributes(params[:fooditem])\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @food_item = FoodItem.find(params[:id])\n\n respond_to do |format|\n if @food_item.update_attributes(params[:food_item])\n format.html { redirect_to @food_item, notice: 'Food item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @request_item.update(request_item_params)\n format.html { redirect_to @request_item, notice: 'Request item was successfully updated.' }\n format.json { render :show, status: :ok, location: @request_item }\n else\n format.html { render :edit }\n format.json { render json: @request_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = \"Item has been updated\"\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { render :action => :edit }\n else\n format.json { render :text => \"Could not update item\", :status => :unprocessable_entity } #placeholder\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n format.html { render :action => :edit, :status => :unprocessable_entity }\n end\n end\n end", "def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @apiv1_item.update(apiv1_item_params)\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @apiv1_item }\n else\n format.html { render :edit }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_task_item.update(api_task_item_params)\n format.html { redirect_to @api_task_item, notice: 'Task item was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_task_item }\n else\n format.html { render :edit }\n format.json { render json: @api_task_item.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /fnf_items/1 DELETE /fnf_items/1.json
def destroy @fnf_item.destroy respond_to do |format| format.html { redirect_to fnf_items_url, notice: 'Fnf item was successfully destroyed.' } format.json { head :no_content } end end
[ "def delete_item(id)\n delete_request configure_payload(\"/items/#{id}\")\n end", "def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end", "def destroy\n @fb_item = FbItem.find(params[:id])\n @fb_item.destroy\n\n respond_to do |format|\n format.html { redirect_to fb_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # :id here represents the name so we don't have to change the routes\n @item = Item.find_by_name(params[:id])\n p params\n logger.debug @item.inspect\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content, status: 200 }\n end\n end", "def destroy\n @fooditem = Fooditem.find(params[:id])\n @fooditem.destroy\n\n respond_to do |format|\n format.html { redirect_to fooditems_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @food_item = FoodItem.find(params[:id])\n @food_item.destroy\n\n respond_to do |format|\n format.html { redirect_to food_items_url }\n format.json { head :ok }\n end\n end", "def delete_fs_item\n d \"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\"\n d \"Delete a file or folder\"\n d \"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\"\n \n err_str = ''\n begin # a one time loop to allow break\n \n generic_ty = Integer(params[:sel_kind]) rescue generic_ty = FSTYPE_INVALID\n elem_id = Integer(params[:sel_id]) rescue elem_id = -1\n if ( elem_id <= 0 )\n err_str = 'Invalid index'\n break\n end\n \n if ( generic_ty == FSTYPE_FILE )\n to_upd = Dfile.find_by_id( elem_id )\n if ( to_upd )\n kindname = to_upd.fileType()\n parent_id = to_upd.directory_id\n our_name = to_upd.name\n if to_upd.destroy\n reponse = { action_id: params[:action_id],\n new_id: elem_id,\n new_name: our_name,\n parent_id: parent_id,\n kind_name: kindname\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to delete file'\n break\n end\n else\n err_str = 'File does not exist'\n break\n end\n elsif ( generic_ty == FSTYPE_DIR )\n to_upd = Directory.find_by_id( elem_id )\n if ( to_upd )\n parent_id = to_upd.parent_id\n our_name = to_upd.name\n if to_upd.destroy\n reponse = { action_id: params[:action_id],\n new_id: elem_id,\n new_name: our_name,\n parent_id: parent_id,\n kind_name: 'directory'\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to delete directory'\n break\n end\n else\n err_str = 'Directory does not exist'\n break\n end\n else\n err_str = 'Invalid entry type'\n break\n end\n \n end until true # a one time loop to allow break\n render json: err_str, status: :unprocessable_entity and return\n end", "def delete_item\n item_id = params[\"item_id\"]\n\n item = TextItem.find_by_id(item_id)\n item = Image.find_by_id(item_id) if item.nil?\n item = Collection.find_by_id(item_id) if item.nil?\n render_json :status => :not_found, :messages => \"Could not find the item with id #{item_id}.\" and return if item.nil?\n\n if item.class == Collection\n if params[\"id\"].nil?\n render_json :status => :bad_request, :messages => \"Can't delete a collection reference without providing the parent collection id. Please use the longer url for item deletion.\" and return\n end\n collection = Collection.find_by_id(params[\"id\"])\n else\n collection = Ownership.find_by_item_id(item_id).parent\n end\n;\n render_json :status => :not_found, :messages => \"Could not find parent collection for the item.\" and return if (collection.nil?)\n render_json :status => :forbidden, :messages => \"The user is not allowed to delete from this collection.\" and return if (!collection.delete?(@user, @client))\n\n collection.delete_item(item_id)\n render_json :entry => {} and return\n end", "def destroy\n @api_item.destroy\n end", "def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end", "def destroy\n render status: 200, json: @request_item.destroy\n end", "def destroy\n @apiv1_item.destroy\n respond_to do |format|\n format.html { redirect_to apiv1_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @request_item = RequestItem.find(params[:id])\n @request_item.destroy\n\n respond_to do |format|\n format.html { redirect_to request_items_url }\n format.json { head :no_content }\n end\n end", "def delete\n api_xml(category(target),:delete) if options.data or options.category\n if options.itemdef\n parse_itemdef\n uid=find_definition_uid_by_name(itemdef.name)\n response=admin_xml(\"/itemDefinitions/#{uid}\")\n verbose \"About to delete: #{REXML::XPath.first(response,'//Name/text()').value} item definition.\\n\"\n admin_xml(\"/itemDefinitions/#{uid}\",\n :delete) if itemdef.name\n end\n end", "def delete_request(item, request)\n option_hash = {accept: :json, cookies: @maint_cookie}\n begin\n res = @api[\"items/#{item[\"id\"]}/requests/#{request[\"id\"]}\"].delete option_hash\n rescue => e\n @logger&.error \"delete_request => exception #{e.class.name} : #{e.message}\"\n if (ej = JSON.parse(e.response)) && (eje = ej[\"errors\"])\n eje.each do |k, v|\n @logger&.error \"#{k}: #{v.first}\"\n end\n end\n return nil\n end\n res\n end", "def destroy\n @food_item = @food.food_items.find(params[:id])\n @food_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(food_food_items_url(@food)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @foil_item.destroy\n respond_to do |format|\n format.html { redirect_to foil_items_url, notice: 'Foil item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\tif Rails.env.production?\n\t\t\tRestClient.patch(\"https://lensshift-drive.firebaseio.com/resources_deleted/#{@resource_item.google_doc_id}.json\", @resource_item.to_json)\n\t\t\tRestClient.delete(\"https://lensshift-drive.firebaseio.com/resources/#{@resource_item.google_doc_id}.json\")\n\t\tend\n\t\t@resource_item.destroy\n\t respond_to do |format|\n\t format.html { redirect_to fellow_resource_items_url, notice: 'Resource item was successfully destroyed.' }\n\t format.json { head :no_content }\n\t end\n\tend", "def test_trying_to_delete_non_item\n r = delete \"/groceries\", name: \"not a thing\"\n assert_equal 404, r.status\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
breakpoint.hit_condition = symbol Sets the hit condition of the breakpoint which must be one of the following values: +nil+ if it is an unconditional breakpoint, or :greater_or_equal(:ge), :equal(:eq), :modulo(:mod)
def hit_condition= symbol #This is a stub, used for indexing end
[ "def condition=(expr)\n @condition = expr\n if @condition\n # Convert the breakpoint expression to a valid snippet of Ruby\n eval_str = expr.gsub('#hits', '__hits__')\n # - check if then...end is needed\n if eval_str =~ /^(?:if|unless).+^(?:end)$/\n eval_str << \" then true end\"\n end\n\n # Test expression is valid syntax\n begin\n @condition_eval = eval_str if eval(\"return true; #{eval_str}\")\n rescue Exception => e\n STDERR.puts \"An error occurred while setting the breakpoint condition '#{condition}':\"\n STDERR.puts e.to_s\n STDERR.puts \"Breakpoint condition has been ignored.\"\n @condition = nil\n @condition_eval = nil\n end\n else\n @condition_eval = nil\n end\n end", "def set_breakpoint(source, pos, condition = nil)\n #This is a stub, used for indexing\n end", "def breakpoint_hit?\n exec_oob = oob_records(:exec).first\n exec_oob.results[:reason] == 'breakpoint-hit' &&\n exec_oob.record_class == :stopped\n end", "def trigger?(task)\n @hits += 1\n return true unless @condition_eval\n begin\n # Evaluate the condition in the debug context\n proc = eval(\"Proc.new {|__hits__| #{@condition_eval} }\",\n Binding.setup(task.current_context))\n proc.call(hits)\n rescue Exception => e\n # An exception occurred while processing the breakpoint condition\n STDERR.puts \"An error occurred while processing the breakpoint condition '#{condition}':\"\n STDERR.puts e.to_s\n false\n end\n end", "def set_breakpoint(location:, condition: nil)\n {\n method: \"Debugger.setBreakpoint\",\n params: { location: location, condition: condition }.compact\n }\n end", "def breakpoint?(ip)\n Rubinius.primitive :compiledmethod_is_breakpoint\n raise ArgumentError, \"Unable to retrieve breakpoint status on #{inspect} at bytecode address #{ip}\"\n end", "def breakpoint?\n type == :breakpoint\n end", "def break(breakpoint)\n if ::Thread.current[:breakpoints] &&\n ::Thread.current[:breakpoints].include?(breakpoint)\n ::Thread.current[:breakpoints_reached] << breakpoint\n puts \"breaking on #{breakpoint}\"\n self.main_thread.run\n ::Thread.stop\n end\n end", "def set_breakpoint(ip, obj)\n Rubinius.primitive :compiledmethod_set_breakpoint\n raise ArgumentError, \"Unable to set breakpoint on #{inspect} at invalid bytecode address #{ip}\"\n end", "def __condition(condition)\n @__rule.conditions[condition]\n end", "def check_condition binding\n return true if condition.nil? || condition.empty?\n begin\n Evaluator.eval_condition binding, condition\n rescue\n set_error_state \"Unable to evaluate condition\",\n refers_to: :BREAKPOINT_CONDITION\n false\n end\n end", "def condition\n @condition\n end", "def print_full_breakpoint(breakpoint)\n header = \"Breakpoint #{breakpoint.id}:\"\n status = breakpoint.enabled? ? \"Enabled\" : \"Disabled\"\n code = breakpoint.source_code.with_line_numbers.to_s\n condition = if breakpoint.expr\n \"#{bold('Condition:')} #{breakpoint.expr}\\n\"\n else\n \"\"\n end\n\n output.puts <<-BREAKPOINT.gsub(/ {8}/, \"\")\n\n #{bold(header)} #{breakpoint} (#{status}) #{condition}\n\n #{code}\n\n BREAKPOINT\n end", "def condition=(condition)\n @condition = condition\n end", "def at_breakpoint(breakpoint)\n $LOG.debug(self.class.name) do\n num = Byebug.breakpoints.index(breakpoint) + 1\n \"at_breakpoint #{num}: #{frame.file}:#{frame.line}\"\n end\n end", "def condition=(value)\n @condition = value\n end", "def enable_breakpoint(bp)\n bp.enable\n end", "def breakpoints_hit breakpoints, call_stack_bindings\n breakpoints.each do |breakpoint|\n # Stop evaluating breakpoints if we have quotas and the quotas are\n # met.\n break if agent.quota_manager && !agent.quota_manager.more?\n\n next if breakpoint.nil? || breakpoint.complete?\n\n time_begin = Time.now\n\n agent.breakpoint_manager.breakpoint_hit breakpoint,\n call_stack_bindings\n\n # Report time and resource consumption to quota manager\n if agent.quota_manager.respond_to? :consume\n agent.quota_manager.consume time: Time.now - time_begin\n end\n end\n\n update_breakpoints_cache\n\n # Disable all trace points and tracing if all breakpoints are complete\n disable_traces if @breakpoints_cache.empty?\n end", "def get_breakpoint(cm, ip)\n @global_breakpoints[cm][ip] if @global_breakpoints[cm]\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
breakpoint.hit_count > int Returns the hit count of the breakpoint.
def hit_count() #This is a stub, used for indexing end
[ "def hit_count\n self[:hit_count] && self[:hit_count].to_i\n end", "def hit_count=(hits)\n hits = hits.to_i\n return self[:hit_count] if hits < self[:hit_count]\n self[:hit_count] = (hits >= 0 ? hits : 0)\n end", "def count\n hits.count\n end", "def get_hits(handle)\n raise \"Must be implemented.\"\n return number_of_hits\n end", "def num_hits; @hits.size; end", "def breakpoint_hit?\n exec_oob = oob_records(:exec).first\n exec_oob.results[:reason] == 'breakpoint-hit' &&\n exec_oob.record_class == :stopped\n end", "def count\n return line_points.count\n end", "def count\n\t\t@stack.length\n\tend", "def product_hit_count_increment\n if self.hit_count == nil\n self.hit_count = 1\n else\n self.hit_count += 1\n end\nend", "def hit_percentage\n @hits.to_f / @shots\n end", "def hit_percentage\n @hits.to_f / @shots\n end", "def hit_points\n @hit_points\n end", "def filtered_hits_count\n return @filtered_results.length || 0\n end", "def total_hits_count\n return top_hits_count + all_hits_count\n end", "def top_hits_count\n return @top_results.length || 0\n end", "def matched_count\n @results[MATCHED_COUNT]\n end", "def number_of_occurrences\n return @number_of_occurrences\n end", "def stash_visit_count\n position = @board.position\n board = @board.instance_variable_get(\"@board\")\n keys = board.keys\n key = keys.find{|k| k == position}\n\n visits = key.instance_variable_get(\"@visited\").to_i\n key.instance_variable_set(\"@visited\", visits + 1)\n end", "def click_count\n return @click_count\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
breakpoint.hit_value > int Returns the hit value of the breakpoint.
def hit_value() #This is a stub, used for indexing end
[ "def hit_value= int\n #This is a stub, used for indexing\n end", "def hit_count\n self[:hit_count] && self[:hit_count].to_i\n end", "def set_attack_hit_value(attacker)\n atk_hit = Damage_Algorithm_Type > 1 ? attacker.agi : attacker.dex\n eva = 8 * self.agi / atk_hit + self.eva\n hit = (self.cant_evade? or self.hp <= 0) ? 100 : 100 - eva\n return (rand(100) < hit)\n end", "def breakpoint_hit?\n exec_oob = oob_records(:exec).first\n exec_oob.results[:reason] == 'breakpoint-hit' &&\n exec_oob.record_class == :stopped\n end", "def hit(hit_value)\r\n case hit_value\r\n when 1\r\n @bases.unshift(1)\r\n reset()\r\n when 2\r\n @bases.unshift(0,1)\r\n reset()\r\n when 3\r\n @bases.unshift(0,0,1)\r\n reset()\r\n when 4\r\n @bases.unshift(0,0,0,1)\r\n reset()\r\n end\r\n \r\n # Add home-run if baserunner makes it to home base\r\n until @bases.length < 4\r\n if @bases[-1] == 1\r\n @home_runs += 1\r\n @bases.pop\r\n else\r\n @bases.pop\r\n end\r\n end\r\n end", "def skill_effect_second_hit_result(user, skill)\r\n eva = 8 * self.agi / user.dex + self.eva\r\n hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100\r\n hit = self.cant_evade? ? 100 : hit\r\n return hit, (rand(100) < hit)\r\n end", "def hit_die\n @current_hit_die\n end", "def gt\n\t\t\tif @value > @interpreter.memory.get(@interpreter.memory_position) \n\t\t\t\t@value = 1\n\t\t\telse\n\t\t\t\t@value = 0\n\t\t\tend\n\t\tend", "def hit_points\n @hit_points\n end", "def item_effect_hit_result(item) \r\n return (rand(100) < item.hit)\r\n end", "def skill_effect_first_hit_result(user, skill)\r\n hit = skill.hit\r\n if skill.atk_f > 0\r\n hit *= user.hit / 100\r\n end\r\n return hit, (rand(100) < hit)\r\n end", "def hitMe?\n\treturn hand.value < 14\n end", "def attack_effect_second_hit_result(attacker)\r\n eva = 8 * self.agi / attacker.dex + self.eva\r\n hit = self.damage < 0 ? 100 : 100 - eva\r\n hit = self.cant_evade? ? 100 : hit\r\n return (rand(100) < hit)\r\n end", "def hits=(value)\n @hits = value\n end", "def hit_id\n return @hit_id\n end", "def hit_count=(hits)\n hits = hits.to_i\n return self[:hit_count] if hits < self[:hit_count]\n self[:hit_count] = (hits >= 0 ? hits : 0)\n end", "def hit_percentage\n @hits.to_f / @shots\n end", "def above(result, value)\n status = 2\n status = 0 if result.to_f > value.to_f\n status\n end", "def get_projectile_hit_area(ch)\n pix = $BlizzABS.pixel\n return case ch.direction\n when 2\n Rect.new(ch.real_x / 4 + 8, ch.real_y / 4 + 8, 16, ch.y * 32 / pix - ch.real_y / 4 + 24)\n when 4\n Rect.new(ch.x * 32 / pix + 8, ch.y * 32 / pix + 8, ch.real_x / 4 - ch.x * 32 / pix + 24, 16)\n when 6\n Rect.new(ch.real_x / 4 + 8, ch.real_y / 4 + 8, ch.x * 32 / pix-ch.real_x / 4 + 24, 16)\n when 8\n Rect.new(ch.x * 32 / pix + 8, ch.y * 32 / pix + 8, 16, ch.real_y / 4 - ch.y * 32 / pix + 24)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
breakpoint.hit_value = int Sets the hit value of the breakpoint.
def hit_value= int #This is a stub, used for indexing end
[ "def hit(hit_value)\r\n case hit_value\r\n when 1\r\n @bases.unshift(1)\r\n reset()\r\n when 2\r\n @bases.unshift(0,1)\r\n reset()\r\n when 3\r\n @bases.unshift(0,0,1)\r\n reset()\r\n when 4\r\n @bases.unshift(0,0,0,1)\r\n reset()\r\n end\r\n \r\n # Add home-run if baserunner makes it to home base\r\n until @bases.length < 4\r\n if @bases[-1] == 1\r\n @home_runs += 1\r\n @bases.pop\r\n else\r\n @bases.pop\r\n end\r\n end\r\n end", "def hit_value()\n #This is a stub, used for indexing\n end", "def set_attack_hit_value(attacker)\n atk_hit = Damage_Algorithm_Type > 1 ? attacker.agi : attacker.dex\n eva = 8 * self.agi / atk_hit + self.eva\n hit = (self.cant_evade? or self.hp <= 0) ? 100 : 100 - eva\n return (rand(100) < hit)\n end", "def hits=(value)\n @hits = value\n end", "def hit_id=(value)\n @hit_id = value\n end", "def white_hits=(hits)\n raise TypeError, \"Given white hits must be type of Integer\" unless hits.is_a? Integer\n raise RuleViolationError, \"Cannot override white hits\" unless @white_hits == nil\n \n @white_hits = hits\n return self\n end", "def black_hits=(hits)\n raise TypeError, \"Given black hits must be type of Integer\" unless hits.is_a? Integer\n raise RuleViolationError, \"Cannot override black hits\" unless @black_hits == nil\n \n @black_hits = hits\n return self\n end", "def hit; end", "def set_hit_number(battler)\n battler.current_action.hit_times = action_hits(battler)\n battler.current_action.combo_times = action_combo(battler)\n battler.current_action.action_sequence = action_sequences(battler, battler_action(battler))\n end", "def set_breakpoint(source, pos, condition = nil)\n #This is a stub, used for indexing\n end", "def hit_count=(hits)\n hits = hits.to_i\n return self[:hit_count] if hits < self[:hit_count]\n self[:hit_count] = (hits >= 0 ? hits : 0)\n end", "def hit! damage = 1\n self.hitpoints -= damage\n hit if hitpoints > 0\n respond_to?(:kill!) ? kill! : destroy! if hitpoints < 0\n end", "def hit_points\n @hit_points\n end", "def breakpoint_hit?\n exec_oob = oob_records(:exec).first\n exec_oob.results[:reason] == 'breakpoint-hit' &&\n exec_oob.record_class == :stopped\n end", "def breakpoints_hit breakpoints, call_stack_bindings\n breakpoints.each do |breakpoint|\n # Stop evaluating breakpoints if we have quotas and the quotas are\n # met.\n break if agent.quota_manager && !agent.quota_manager.more?\n\n next if breakpoint.nil? || breakpoint.complete?\n\n time_begin = Time.now\n\n agent.breakpoint_manager.breakpoint_hit breakpoint,\n call_stack_bindings\n\n # Report time and resource consumption to quota manager\n if agent.quota_manager.respond_to? :consume\n agent.quota_manager.consume time: Time.now - time_begin\n end\n end\n\n update_breakpoints_cache\n\n # Disable all trace points and tracing if all breakpoints are complete\n disable_traces if @breakpoints_cache.empty?\n end", "def set_skill_hit(user, skill)\n skill_hit = skill.magic? ? skill.hit : (skill.hit * user.hit / 100.0)\n return (rand(100) < skill_hit)\n end", "def set_skill_damage_value(user, skill)\n power = set_skill_power(user, skill)\n rate = set_skill_rate(user, skill)\n rate = [rate, 0].max\n user.target_damage[self] = power * rate / 20.0\n user.target_damage[self] *= elements_correct(skill.element_set)\n user.target_damage[self] /= 100\n user.target_damage[self] = user.target_damage[self].to_i\n end", "def record_score(number_of_pins_hit)\n @throws << number_of_pins_hit\n end", "def gotAttack(damage)\r\n @hitpoint -= damage\r\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.step(steps, force = false) Stops the current context after a number of +steps+ are made. +force+ parameter (if true) ensures that the cursor moves from the current line.
def step(steps, force = false) #This is a stub, used for indexing end
[ "def step_over(steps, frame = nil, force = false)\n #This is a stub, used for indexing\n end", "def step(steps)\r\n\tdirection = (steps > 0) ? :brighten : :dim\r\n\tnsteps = steps.abs\r\n\twhile nsteps > 0\r\n\t n = (nsteps > 6) ? 6 : nsteps\r\n\t @controller.command(@house, @unit, direction, n)\r\n\t nsteps -= n\r\n\tend\r\n end", "def after_step context\n\t context\n\t end", "def move_forward(next_step_name = next_step,\n save_step_name = Wicked::FINISH_STEP)\n\n if save_button?\n notice_text = @context.id ? 'saved' : 'created'\n if @context.save\n delete_session_key(:context, @context_id)\n redirect_to wizard_path(save_step_name), notice: 'Context was successfully ' + notice_text\n else\n render_wizard\n end\n elsif @context.valid?\n redirect_to wizard_path(next_step_name)\n else\n render_wizard\n end\n end", "def pass(step)\n io.print \".\"\n io.flush\n super(step)\n end", "def step_into(steps, frame = 0)\n #This is a stub, used for indexing\n end", "def forward(steps)\n validate_steps(steps)\n normal_radians = to_rad(flip_turtle_and_normal(@heading))\n new_pt = [@xy[0] + steps * cos(normal_radians),\n @xy[1] + steps * sin(normal_radians)]\n\n add_segment_to_track @xy, new_pt if self.pen_down?\n @xy = new_pt\n end", "def walk(steps)\n steps.times do\n @steps_walked += 1\n end\n end", "def bind(*steps)\n raise ArgumentError, 'At least provide two arguments' if steps.size < 2\n\n @context.start_step = @context.steps.index(steps[0]) if @context.start_step == nil\n\n 0.upto(steps.size - 2) do |i|\n first_index = @context.steps.index(steps[i])\n second_index = @context.steps.index(steps[i+1])\n\n @context.hops[first_index] = second_index\n end\n end", "def set_steps(steps)\n send_request(FUNCTION_SET_STEPS, [steps], 'l', 0, '')\n end", "def wizard_step(steps)\n # yield allows various items to be overridden\n overrides = block_given? ? yield : {}\n\n # First half of the step, optionally clear the wizard cache, then finish (so page can display)\n if request.get?\n wizard_handle_clear_cache(overrides)\n\n # sets up _AFTER_ allowing cache to be cleared\n wizard_setup_step(overrides)\n return\n end\n\n # Second half - when step is submitted\n return if wizard_step_submitted(steps, overrides)\n\n render(status: :unprocessable_entity)\n end", "def forward(steps)\n move(steps)\n end", "def break_dance\n # Write a solution that uses the same code as how_many_steps?, but breaks the\n # loop if steps is equal to 6\n steps = 0 \n loop do \n puts steps\n if steps % 2 == 0 \n puts \"Left\"\n elsif steps % 2 != 0 \n puts \"Right\"\n end\n sleep (0.5)\n steps += 1\n if steps == 6 \n break\nend\nend \nbreak_dance\nend", "def before_step context\n\t context\n\t end", "def step_forward(step=1)\n return nil unless position?\n moving(step) { |pos, step| pos + step }\n @position\n end", "def forward(steps)\n must_be_number(steps, 'distance')\n angle = heading * DEG\n x, y = xy\n self.xy = [x + steps * sin(angle), y + steps * cos(angle)]\n track.last << xy if pen_down?\n end", "def around_step\n current = current_step\n result = yield\n set_step_as current\n result\n end", "def next_step\n self.current_step = steps[steps.index(current_step)+1]\n end", "def stepSystem(theSystem, numSteps)\n\n\tputSystem(theSystem, 0);\n\n\t1.upto(numSteps) do |n|\n\t\tapplyGravity( theSystem);\n\t\tapplyVelocity(theSystem);\n\t\t\n\t\tputSystem(theSystem, n);\n\tend\n\t\n\tputEnergy(theSystem, numSteps);\n\nend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.step_over(steps, frame = nil, force = false) Steps over a +steps+ number of times. Make step over operation on +frame+, by default the current frame. +force+ parameter (if true) ensures that the cursor moves from the current line.
def step_over(steps, frame = nil, force = false) #This is a stub, used for indexing end
[ "def step_over(lines, frame = 0)\n #This is a stub, used for indexing\n end", "def step_into(steps, frame = 0)\n #This is a stub, used for indexing\n end", "def step(symbol = :over)\n raise RuntimeError, \"can only step top frame\" unless @index === 1\n case symbol\n when :into\n @thread.__step_over_in_frame(0)\n when :over\n @thread.__step_over_in_frame(1)\n when Fixnum\n @thread.__step_over_in_frame(arg)\n end\n end", "def step(steps, force = false)\n #This is a stub, used for indexing\n end", "def forward(steps)\n move(steps)\n end", "def forward(steps)\n validate_steps(steps)\n normal_radians = to_rad(flip_turtle_and_normal(@heading))\n new_pt = [@xy[0] + steps * cos(normal_radians),\n @xy[1] + steps * sin(normal_radians)]\n\n add_segment_to_track @xy, new_pt if self.pen_down?\n @xy = new_pt\n end", "def walk(steps)\n steps.times do\n @steps_walked += 1\n end\n end", "def forward(steps)\n must_be_number(steps, 'distance')\n angle = heading * DEG\n x, y = xy\n self.xy = [x + steps * sin(angle), y + steps * cos(angle)]\n track.last << xy if pen_down?\n end", "def step(steps)\r\n\tdirection = (steps > 0) ? :brighten : :dim\r\n\tnsteps = steps.abs\r\n\twhile nsteps > 0\r\n\t n = (nsteps > 6) ? 6 : nsteps\r\n\t @controller.command(@house, @unit, direction, n)\r\n\t nsteps -= n\r\n\tend\r\n end", "def step_out(n_frames = 1, force = false)\n #This is a stub, used for indexing\n end", "def on_step_over(argv, *)\n args = {}\n OptionParser.new do |parser|\n parser.on('-i transaction_id', Integer) { |i| args[:i] = i }\n end.parse(*argv)\n raise OptionParser::MissingArgument unless [:i].all? { |o| args[o] }\n \n @last_continuation_command = {name: 'step_over', transaction_id: args[:i]}\n context.step_over(1, context.frame.pos)\n proceed!\n end", "def step_forward(step=1)\n return nil unless position?\n moving(step) { |pos, step| pos + step }\n @position\n end", "def bind(*steps)\n raise ArgumentError, 'At least provide two arguments' if steps.size < 2\n\n @context.start_step = @context.steps.index(steps[0]) if @context.start_step == nil\n\n 0.upto(steps.size - 2) do |i|\n first_index = @context.steps.index(steps[i])\n second_index = @context.steps.index(steps[i+1])\n\n @context.hops[first_index] = second_index\n end\n end", "def move! step1, step2 = 0\n move step1, step2\n wait\n end", "def pass(step)\n io.print \".\"\n io.flush\n super(step)\n end", "def each_frame &block\n Enumerator.new {\n |frame|\n old_frame_nr = @current_frame\n reset_animation\n if animated?\n start_frame = @current_frame\n frame << self.copy\n animate_step\n while start_frame != @current_frame\n frame << self.copy\n animate_step\n end\n else\n frame << self.copy\n end\n jump_to_frame(old_frame_nr)\n }.each(&block)\n end", "def continue\n\n # FIXME: with the ruby-supported stepping, we might not\n # need the below any more.\n # I'm guessing the stack size can't ever reach this\n @next_level = 32000\n\n @next_thread = nil\n if @settings[:traceprint]\n @core.step_count = 1 # traceprint will avoid stopping\n else\n @core.step_count = -1 # No more event stepping\n end\n @leave_cmd_loop = true # Break out of the processor command loop.\n end", "def draw(animate = false, fps = 2)\n build_steps unless @built\n @steps.each do |step|\n draw_square(*step)\n if animate\n print \"\\033c\" # clear the screen\n puts self\n sleep(1.0 / fps)\n end\n end\n\n puts self unless animate\n end", "def trace_step(&block)\n if @trace_execution_steps_counter > 0\n puts \"Trace: \" + yield.to_s\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.thnum > int Returns the context's number.
def thnum() #This is a stub, used for indexing end
[ "def i_num\n return @i_num\n end", "def context_for_variable_named(name)\n # Current temporary context?\n # (Shouldn't attempt to access contexts higher in the callstack)\n if current_element.temporary_variables.has_key?(name)\n return current_element_index + 1\n else\n # Global\n return 0\n end\n end", "def column_number()\n #This is a stub, used for indexing\n end", "def line_number\n @current_line\n end", "def context_node \n @stack.last\n end", "def num_class\n @num_class\n end", "def argument_number\n @num_args ||= self.info(CL_KERNEL_NUM_ARGS)\n end", "def get_template_line\n @lineno\n end", "def num_ctx_switches\n @proc.num_ctx_switches\n end", "def context_info\n\t\tif self.contexts_enabled?\n\t\t\treturn \"%d contexts\" % [ self.contexts.length ]\n\t\telse\n\t\t\treturn \"contexts disabled\"\n\t\tend\n\tend", "def context_id\n read_property(:context_id) || read_content(:context_id)\n end", "def position_number\n\t\t\t\t\tnum = number_or_nil(instructions[1])\n\t\t\t\t\tnum.present? ? instructions[1].to_i : nil\n\t\t\t\tend", "def row_number_column\n :x_sequel_row_number_x\n end", "def current_page_number\n return 1 if page_is_first_page?\n page_number\n end", "def row_number_column\n :x_sequel_row_number_x\n end", "def row_number_column\n :x_sequel_row_number_x\n end", "def line_no\n backtrace[1][/:(\\d+):/][1...-1].to_i\n end", "def current_column\n line = line_counts[lineno - 1]\n line[column].to_i - line.start\n end", "def integer()\n self.context_node.text_value.strip.to_i\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.stop_reason > sym Returns the reason for the stop. It maybe of the following values: :initial, :step, :breakpoint, :catchpoint, :postmortem
def stop_reason() #This is a stub, used for indexing end
[ "def stop_reason=(value)\n @stop_reason = value\n end", "def stop_symbol\n STOP\n end", "def stop_test(should_stop, str)\n return unless should_stop\n str ||= \"Test stopped for unknown reason\"\n abort str.color(:red).bright\nend", "def stop(event, reason=\"\", bag={})\n step_errors << reason unless reason == \"\"\n r = StepResult.new(false, reason)\n r.bag = bag\n fire_events(event, r)\n r\n end", "def doStop _args\n \"doStop _args;\" \n end", "def cancellation_reason\n read_integer('cancellation_reason')\n end", "def gracefully_stop!(reason='unknown reason')\n return if @emergency_brake\n warn \"Setting the deployment to gracefully stop. Reason: #{reason}\"\n @emergency_brake = true\n end", "def reason\n @reason\n end", "def restart_stop_code\n return @restart_stop_code\n end", "def cancellation_reason_string\n CANCELATION_REASONS[cancellation_reason]\n end", "def stop(message = nil)\r\n @assert = false\r\n end", "def stop(message=\"\")\n step_errors << message unless message.nil? || message.empty?\n StepResult.new(false, message)\n end", "def stop_action\n action(:stop)\n end", "def stop=(value)\n @stop = value\n end", "def commandStop _args\n \"commandStop _args;\" \n end", "def drop_stop_name\n drop_stop.try(:name)\n end", "def stop_id\n id\n end", "def onStop(reason = '')\n\t\t\treason = 'Unexpected' unless @state != StreamConsumer::STATE_STOPPING and reason.length == 0\n\t\t\t@state = StreamConsumer::STATE_STOPPED\n\t\t\t@stop_reason = reason\n\t\t\tonStopped.call(reason) unless onStopped.nil?\n\t\tend", "def static_stop_link\n return \"\\nStop: Svar STOP #{self.sms_keyword}\"\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.suspended? > bool Returns +true+ if the thread is suspended by debugger.
def suspended?() #This is a stub, used for indexing end
[ "def suspended?\n status.suspended?\n end", "def is_suspended?\n current_teacher && current_teacher.suspended == true\n end", "def async_suspended?\n synchronize do\n async_state == :suspended\n end\n end", "def suspended\n return @suspended\n end", "def suspended?\n self.user_flag && self.user_flag.value == UserFlag::SUSPENDED\n end", "def debug?\n\t\t!!@debuggable_status\n\tend", "def debug_activated?\n return @DebugMode\n end", "def is_msg_handler_suspended?\n return @srv_msg_handler_susp\n end", "def teacher_is_suspended?( teacher)\n teacher.suspended\n end", "def waiting_for_breakpoint?\n @breakpoint_listener.status == 'sleep'\n end", "def waiting_for_breakpoint?\n @breakpoint_listener.status == 'sleep'\n end", "def debug?\n get_context_value( :debug ).truthy?\n end", "def debug?\n debugging || !ENV['DEBUG'].nil?\n end", "def paused?\n\n get_expression_pool.is_paused?(self)\n end", "def debugging?\n defined? @debugging and @debugging\n end", "def is_suspended?\n if current_user\n if current_user.suspended?\n flash[:danger] = \"You have been suspended!\"\n sign_out(current_user)\n end\n end\n end", "def in_driver_context?\n Thread.current == @thread\n end", "def run_if_waiting_for_debugger\n {\n method: \"Runtime.runIfWaitingForDebugger\"\n }\n end", "def debug_mode?\n @@debug_mode\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.tracing = bool Controls the tracing for this context.
def tracing= bool #This is a stub, used for indexing end
[ "def tracing_enabled?\n state.tracing_enabled?\n end", "def tracing?\n # The non-nil value of this instance variable\n # indicates if we are currently tracing\n # in this thread or not.\n self.current_trace ? true : false\n end", "def toggle_tracing!\n enabled? ? disable! : enable!\n end", "def trace(bool)\n Options[:trace] = bool\n end", "def tracing=(use_tracing)\n @tracing = use_tracing\n\n if @source && @source.respond_to?(:tracing=)\n @source.tracing = use_tracing\n end\n end", "def trace=(boolean)\n $TRACE = !!boolean\n end", "def trace_context\n TraceContextData.new trace_id, @span_id, trace_options\n end", "def trace_context\n ensure_exists!\n trace.trace_context.with span_id: span_id\n end", "def trace=(_trace)\n @trace =\n case _trace\n when \"true\", true then true\n else false end\n LoggerFactory.define_methods(self)\n Logger.log_internal {\"Logger '#{@fullname}' is tracing\"} if @trace\n @trace\n end", "def record(context)\n context = context.context if context.is_a?(Datadog::Span)\n return if context.nil?\n trace, sampled = context.get\n\n # If context flushing is configured...\n if @context_flush\n if sampled\n if trace.nil? || trace.empty?\n @context_flush.each_partial_trace(context) do |t|\n write(t)\n end\n else\n write(trace)\n end\n end\n # Default behavior\n else\n ready = !trace.nil? && !trace.empty? && sampled\n write(trace) if ready\n end\n end", "def tracing?\n\n\t\tseverity_logged? :trace\n\tend", "def context\n return nil unless tracing?\n self.current_trace.current_span.context\n end", "def distributed_tracing_enabled?\n NewRelic::Agent.config[:'distributed_tracing.enabled']\n end", "def toggle_trace!\n if level == ::Logging.level_num(Adhearsion.config.core.logging['level'])\n logger.warn \"Turning TRACE logging ON.\"\n self.level = :trace\n else\n logger.warn \"Turning TRACE logging OFF.\"\n self.level = Adhearsion.config.core.logging['level']\n end\n end", "def caller_tracing=( val )\n @caller_tracing =\n case val\n when true, 'true'; true\n when false, 'false'; false\n when nil; @caller_tracing\n else raise ArgumentError, 'expecting a boolean' end\n end", "def trace?\n Options[:trace]\n end", "def tracing_options\n extension_options[TracingMethods] ||= {}\n end", "def push_trace_execution_flag(should_trace = false) # THREAD_LOCAL_ACCESS\n Tracer.state.push_traced(should_trace)\n end", "def trace?; request_method == \"TRACE\" end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.frame_args(frame_position=0) > list Returns frame's argument parameters
def frame_args(frame_position=0) #This is a stub, used for indexing end
[ "def frame_args_info(frame_position=0)\n #This is a stub, used for indexing\n end", "def frame_locals(frame)\n #This is a stub, used for indexing\n end", "def args\n @function.args\n end", "def arguments\n return @arguments\n end", "def args\n return @args\n end", "def arglists\n if @call_seq then\n @call_seq\n elsif @params then\n \"#{name}#{param_seq}\"\n end\n end", "def args\n @payload['args']\n end", "def get_args(namespace); end", "def positional_parameters; end", "def return_to_args; end", "def argument_names\n @argument_names ||= @function.parameters.map(&:last)\n end", "def current_params\n stack[\"Parameters\"].inject({}, &extract_params)\n end", "def arguments\n @arguments ||= from_superclass(:arguments, [])\n end", "def argument_names\n @arguments.map { |a| a[:name] }\n end", "def expanded_args; end", "def args\n source.push :args\n grab_method.push :shift\n end", "def arguments_description \n @arguments_description\n end", "def all_arguments\n return [\n arguments,\n optional_arguments,\n [rest_argument],\n more_arguments,\n [block_argument]\n ]\n end", "def argument_values\n @arguments.map { |arg| arg.value }\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.frame_args_info(frame_position=0) > list if track_frame_args or nil otherwise Returns info saved about call arguments (if any saved).
def frame_args_info(frame_position=0) #This is a stub, used for indexing end
[ "def frame_args(frame_position=0)\n #This is a stub, used for indexing\n end", "def frame_locals(frame)\n #This is a stub, used for indexing\n end", "def track_args(args)\n case args\n when Hash\n timestamp, identity, values = args.values_at(:timestamp, :identity, :values)\n when Array\n values = args\n when Numeric\n values = [args]\n end\n identity ||= begin\n Vanity.context.vanity_identity\n rescue StandardError\n nil\n end\n [timestamp || Time.now, identity, values || [1]]\n end", "def current_frame\n @callstack.top\n end", "def context_from_proc\n frame = self.env.proc_environment.home_block.dup\n\n first_line = self.env.proc_environment.method.first_line\n frame.ip = frame.method.first_ip_on_line(first_line) + 1\n\n return frame\n end", "def asset_getframe(args = { }, opts = { })\n\n end", "def c_frame?; end", "def frame_description; end", "def get_frame_flag(frame, options, name)\n rval = frame.fetch(\"@#{name}\", [options[name]]).first\n rval = rval.values.first if value?(rval)\n if name == :embed\n rval = case rval\n when true then '@last'\n when false then '@never'\n when '@always', '@never', '@link' then rval\n else '@last'\n end\n end\n rval\n end", "def display_signature(frame)\n return nil unless frame\n frame.iseq.object_id\nend", "def stacktrace_includes=(_arg0); end", "def frame_description\n @frame_description\n end", "def camCommitted _args\n \"camCommitted _args;\" \n end", "def frame_count\n Rubinius::VM.backtrace(1).count\n end", "def cmdarg_stack; end", "def context_info()\n return @root_position.branch_info\n end", "def run(args)\n if args.size == 1\n # Form is: \"frame\" which means \"frame 0\"\n position_str = '0'\n elsif args.size == 2\n # Form is: \"frame position\"\n position_str = args[1]\n elsif args.size == 3\n # Form is: frame <position> <thread> \n name_or_id = args[1]\n thread_str = args[2]\n th = @proc.get_thread_from_string(thread_str)\n if th\n @proc.frame_setup(th.threadframe)\n return\n else\n # FIXME: Give suitable error message was given\n end\n else\n # Form should be: \"frame thread\" which means\n # \"frame thread 0\"\n position_str = '0'\n ## FIXME:\n ## @proc.find_and_set_debugged_frame(frame, thread_id)\n end\n one_arg_run(position_str)\n end", "def frame_managers(_pry_)\n frame_hash[_pry_]\n end", "def get_frame_flag(frame, options, name)\n rval = frame.fetch(\"@#{name}\", [options[name]]).first\n rval = rval.values.first if value?(rval)\n if name == :embed\n rval = case rval\n when true then '@once'\n when false then '@never'\n when '@always', '@first', '@last', '@link', '@once', '@never' then rval\n else\n raise JsonLdError::InvalidEmbedValue,\n \"Invalid JSON-LD frame syntax; invalid value of @embed: #{rval}\"\n end\n end\n rval\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.frame_binding(frame_position=0) > binding Returns frame's binding.
def frame_binding(frame_position=0) #This is a stub, used for indexing end
[ "def frame_binding(frame_position = 0)\n #This is a stub, used for indexing\n end", "def get_binding\n return binding\n end", "def get_binding\n return binding\n end", "def current_binding\n binding_stack.last\n end", "def getBinding\r\n\t\treturn binding()\r\n\tend", "def binding\n Kernel.binding\n end", "def binding\n @binding ||= {}\n end", "def binding_n(n = 0)\n Debugger.current_context.frame_binding[n+1]\n end", "def binding_n(n = 0)\n Debugger.current_context.frame_binding[n+1]\n end", "def binding\n self[:binding] ||= instance.instance_eval{ binding }\n end", "def binding?\n @object.type == :binding\n end", "def new_binding; binding; end", "def binds line, number\n return binding\nend", "def binding_stack; end", "def stored_binding\n require 'rails/backtrace_cleaner'\n BindingDumper::UniversalDumper.flush_memories!\n data = read_attribute(column_with_binding)\n Binding.load(data)\n end", "def c_frame?\n _binding.nil?\n end", "def binding?\n !bind_stack.empty?\n end", "def ctx\n binding\n end", "def empty_binding # :nodoc:\n binding\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.frame_class(frame_position) > obj Returns the real class of the frame. It could be different than context.frame_self(frame).class
def frame_class(frame_position) #This is a stub, used for indexing end
[ "def frame_class(frame_position = 0)\n #This is a stub, used for indexing\n end", "def frame_type\n if compiled_code.for_module_body?\n :class\n elsif compiled_code.for_eval?\n :eval\n elsif compiled_code.is_block?\n :block\n else\n :method\n end\n end", "def frame_type\n @callable.frame_type\n end", "def frame_type; end", "def get_class()\n l = get_layout()\n #puts \"Layout #{l.class} in #{self.class} , #{self}\"\n l.object_class()\n end", "def class_name(obj)\n obj.class.name.split('::').last || obj.class.name\n end", "def inspect\n \"<#{@java_object._classname}>\"\n end", "def current_frame\n @current_frame\n end", "def class?; end", "def class_for(yard_object)\n class_name = yard_object.class.to_s.split('::').last\n const_get(class_name)\n rescue NameError\n Base\n end", "def current_class_name\n @klass.to_s\n end", "def class\n <<-CODE\n t1 = stack_pop();\n stack_push(object_class(state, t1));\n CODE\n end", "def c_frame?; end", "def class_name\n if :class == node_type\n self[1]\n end\n end", "def class_for(code_object)\n class_name = code_object.class.to_s.split('::').last\n const_get(class_name)\n end", "def class_name\n if @class_stack.any?\n @class_stack.reverse\n else\n :main\n end\n end", "def ruby_class\n attributes[\"ruby_class\"]\n end", "def is? frame_type\n return true if frame_type == :all\n detection = \"is_#{frame_type.to_s.sub(/frames$/, 'frame')}?\"\n begin \n self.send detection\n rescue NoMethodError => e\n false\n end\n end", "def observed_class\n if observed_class_name\n observed_class_name.constantize\n else\n nil\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.frame_file(frame_position) > string Returns the name of the file.
def frame_file(frame_position) #This is a stub, used for indexing end
[ "def frame_filename(frame)\n frame_exists?(frame) ? @frame_filename[frame] : nil\n end", "def frame_file(frame_position = 0)\n #This is a stub, used for indexing\n end", "def file_name\n return @file_name\n end", "def name() @filename end", "def file_name\n @file_name ||= File.basename tree\n end", "def frame_output_filename(frame)\n \"#{Dir.tmpdir}/frame_#{Time.now.to_i}_#{frame}.png\"\n end", "def file_name\n if source\n source.is_a?(File) ? File.basename(source.path) : File.basename(source)\n else\n object.original_name.nil? ? \"original_file\" : object.original_name\n end\n end", "def file_name\n @info['name']\n end", "def file_name\n File.join(path, name)\n end", "def filename\n @metadata[:filename] || pathname.basename.to_s\n end", "def original_filename\n instance_read(:file_name)\n end", "def file_name(token)\n FileHelper.file_cache_name(file_cache_dir, token)\n end", "def filename\n File.basename(self.source, File.extname(self.source))\n end", "def display_filename\n original_name || file_file_name\n end", "def caller_filename\n path = caller_locations(2, 1).first.path\n return File.basename(path)\n end", "def get_filename (file)\n\t\tif file.is_a? File\n\t\t\tfile = file.path\n\t\tend\n\t\treturn file\n\tend", "def filename\n @metadata[:filename] || uri.path.split('/')[-1]\n end", "def filename\n # just checking the first file (which is the file where an object\n # is first declared)\n files.first && files.first.filename\n end", "def filename\n # just checking the first file (which is the file where an\n # object is first declared)\n files.first && files.first.filename\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.frame_line(frame_position) > int Returns the line number in the file.
def frame_line(frame_position) #This is a stub, used for indexing end
[ "def frame_line(frame_position = 0)\n #This is a stub, used for indexing\n end", "def line_number\n @current_line\n end", "def file_position\n @line_count\n end", "def line_number\n return unless backtrace and backtrace[0]\n\n backtrace[0].split(\":\")[1].to_i\n end", "def line_number(node)\n node.loc.line\n end", "def line_number\n comment.loc.expression.line\n end", "def line_no\n backtrace[1][/:(\\d+):/][1...-1].to_i\n end", "def start_line\n @line_number\n end", "def line_number\n if active?\n window = @session.request(:vim_get_current_window)\n @session.request(:window_get_cursor, window)[0]\n end\n end", "def lineno\n ensure_open\n\n @lineno\n end", "def source_line_number\n @source_line_number ||= proc_info[1]\n end", "def line_id\n @line_number - 1\n end", "def line_number\n if active?\n @session.request(:nvim_get_current_win).get_cursor[0]\n end\n end", "def from_line_index\n from_line - 1\n end", "def line\n @line || (backtrace!; @line)\n end", "def linenumber\n return @cmd.nil? ? 0 : @cmd.linenumber\n end", "def start_line_number; end", "def current_line_pos\n pos - col\n end", "def current_position\n send_command(\"info line\").scan(/Line\\s(\\d+).*\"(.*)\"/).map{|line,file| [file,line.to_i]} rescue []\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.frame_locals(frame) > hash Returns frame's local variables.
def frame_locals(frame) #This is a stub, used for indexing end
[ "def thread_variables\n _locals.keys\n end", "def locals; end", "def __locals__\n\t\t\treturn @locals\n\t\tend", "def local_variables()\n eval( 'local_variables', self )\n end", "def globals\n @context.globals\n end", "def attributes\n\t\treturn self.scope.__locals__\n\tend", "def local_vars\n self[@cfunction][:local_vars]\n end", "def locals\n @locals ||= get_locals\n end", "def local_variables() end", "def var_names\n @var_names ||= eval \"local_variables\", get_binding\n end", "def scoped_variables_hash\n scoped_variables.to_hash\n end", "def active_locals\n @local_forwarded_ports.keys\n end", "def locals\n if strict_locals?\n nil\n else\n @locals\n end\n end", "def context_from_proc\n frame = self.env.proc_environment.home_block.dup\n\n first_line = self.env.proc_environment.method.first_line\n frame.ip = frame.method.first_ip_on_line(first_line) + 1\n\n return frame\n end", "def locals( args )\n params[:locals] ||= {}\n params[:locals].merge! args\n end", "def render_locals\n locals = super\n if @_view_locals\n locals = Hash[locals].merge!(@_view_locals)\n end\n locals\n end", "def properties\n return eval('local_variables', @context_binding).map{|var| var.to_s}\n end", "def locals(&blk)\n @stack_usage ||= 0\n num_locals = blk.arity\n\n # Allocate stack space\n locals = (0...num_locals).map do |i|\n offset = -(@stack_usage+i+1)\n PlusRegister.new j, (offset & 0xFFFF)\n end\n @stack_usage += num_locals\n SUB sp, num_locals\n\n yield *locals\n\n # Deallocate stack space\n ADD sp, num_locals\n @stack_usage -= num_locals\n end", "def locals_at l_block\n used =[]\n # call assigns the return register, but as it is in l_block, it is not asked.\n assigned = [ Register::RegisterReference.new(Virtual::RegisterMachine.instance.return_register) ]\n l_block.reachable.each do |b|\n b.uses.each {|u|\n (used << u) unless assigned.include?(u)\n }\n assigned += b.assigns\n end\n used.uniq\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.frame_self(frame_postion=0) > obj Returns self object of the frame.
def frame_self(frame_postion=0) #This is a stub, used for indexing end
[ "def frame_self(frame_postion = 0)\n #This is a stub, used for indexing\n end", "def current_frame\n @current_frame\n end", "def current_frame\n @callstack.top\n end", "def framing\n previous, klass.current_frame = klass.current_frame, self unless @delegate_to_klass\n yield\n ensure\n klass.current_frame = previous unless @delegate_to_klass\n end", "def c_frame?; end", "def what_is_self\n self\n end", "def parent_frame\n @bridge.switch_to_parent_frame\n end", "def get_current_object\n if @current_object.nil?\n @parent.get_current_object\n else\n @current_object\n end\n end", "def frame_class(frame_position = 0)\n #This is a stub, used for indexing\n end", "def get_frame(frame_nr = @current_frame)\n remembered_frame_nr = @current_frame\n jump_to_frame(frame_nr)\n frame_image = self.copy\n jump_to_frame(remembered_frame_nr)\n return frame_image\n end", "def frame( frameName)\n @frame = frameName\n return self\n end", "def get_frame\n next_frame\n rescue StopIteration => e\n return nil\n end", "def frame\n (@frame || 1).to_f\n end", "def find_current_frame\n if open_frame? || final_frame_with_bonus?\n @frame = player.frames.last\n end\n @frame\n end", "def this\n # RefThis.new\n @@this.call\n end", "def frame_class(frame_position)\n #This is a stub, used for indexing\n end", "def content_frame\n node_info = client.command(\n Protocol::DOM.describe_node(object_id: remote_object[\"objectId\"])\n ).value\n return unless node_info.dig(\"node\", \"frameId\").is_a? String\n\n frame_manager.frame node_info.dig(\"node\", \"frameId\")\n end", "def push_self\n \"stack_push(c->self);\"\n end", "def frame\n\t\traise \"No frame_name has been set for this unit!\" unless self.frame_name\n\t\treturn @frame ||= FrameNet[ self.frame_name ]\n\tend" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.breakpoint > breakpoint Returns a contextspecific temporary Breakpoint object.
def breakpoint() #This is a stub, used for indexing end
[ "def breakpoint?\n type == :breakpoint\n end", "def break(breakpoint)\n if ::Thread.current[:breakpoints] &&\n ::Thread.current[:breakpoints].include?(breakpoint)\n ::Thread.current[:breakpoints_reached] << breakpoint\n puts \"breaking on #{breakpoint}\"\n self.main_thread.run\n ::Thread.stop\n end\n end", "def get_breakpoint_by_id(id)\n global_breakpoints.each do |bp|\n return bp if bp.id == id\n end\n nil\n end", "def get_breakpoint(cm, ip)\n @breakpoint_tracker.get_breakpoint(cm, ip)\n end", "def print_full_breakpoint(breakpoint); end", "def print_short_breakpoint(breakpoint); end", "def set_breakpoint(source, pos, condition = nil)\n #This is a stub, used for indexing\n end", "def add_breakpoint(bp)\n # apply breakpoint to process\n end", "def get_breakpoint(cm, ip)\n @global_breakpoints[cm][ip] if @global_breakpoints[cm]\n end", "def breakpoints\n @breakpoint_tracker.global_breakpoints\n end", "def wait_for_breakpoint\n if @thread = @debug_channel.receive\n task = @thread.task\n ctx = task.current_context\n cm = ctx.method\n ctx.reload_method # Reset context bytecodes to those on CM\n ctx.ip -= 1 unless ctx.ip == 0 # Need to reset IP to original instruction\n ip = ctx.ip\n do_yield = false\n\n Rubinius.compile_if($DEBUG) { puts \"Breakpoint hit at #{ip}\" }\n\n @bp_list = find_breakpoints(task, cm, ip)\n unless @bp_list.size > 0\n raise \"Unable to find breakpoint for #{ctx.inspect}\"\n end\n\n @bp_list.each do |bp|\n if bp.kind_of? StepBreakpoint and bp.steps == 0\n # Delete expired task breakpoints\n @task_breakpoints[task].delete(bp)\n do_yield = true unless bp.kind_of? BreakpointRestorer\n end\n end\n\n if (bp = @bp_list.last) and bp.kind_of? GlobalBreakpoint and bp.enabled?\n do_yield = true\n bp.hits += 1\n # Create a BreakpointRestorer breakpoint to restore the globabl\n # breakpoint on the current context\n @task_breakpoints[task] << BreakpointRestorer.new(task)\n end\n\n begin\n @callback.call(@thread, ctx, @bp_list.first) if do_yield\n rescue RuntimeError => e\n puts \"An exception occured in a breakpoint handler:\"\n puts e\n end\n end\n @thread\n end", "def print_full_breakpoint(breakpoint)\n header = \"Breakpoint #{breakpoint.id}:\"\n status = breakpoint.enabled? ? \"Enabled\" : \"Disabled\"\n code = breakpoint.source_code.with_line_numbers.to_s\n condition = if breakpoint.expr\n \"#{bold('Condition:')} #{breakpoint.expr}\\n\"\n else\n \"\"\n end\n\n output.puts <<-BREAKPOINT.gsub(/ {8}/, \"\")\n\n #{bold(header)} #{breakpoint} (#{status}) #{condition}\n\n #{code}\n\n BREAKPOINT\n end", "def set_breakpoint(breakpoint)\n breakpoint.package = determine_top_level_package(breakpoint)\n @process.input(\"#{self.class::Break} #{breakpoint.package}:#{breakpoint.line}\")\n end", "def breakpoints\n @breakpoint_tracker.global_breakpoints\n end", "def wait_for_breakpoint\n if @thread = @debug_channel.receive\n task = @thread.task\n ctx = task.current_context\n cm = ctx.method\n ctx.reload_method # Reset context bytecodes to those on CM\n ctx.ip -= 1 unless ctx.ip == 0 # Need to reset IP to original instruction\n ip = ctx.ip\n\n Rubinius.compile_if($DEBUG) { STDOUT.puts \"Breakpoint hit at #{ip}\" }\n\n @bp_list = find_breakpoints(task, cm, ip)\n unless @bp_list.size > 0\n raise \"Unable to find any managed breakpoint for #{ctx.inspect} at IP:#{ctx.ip}\"\n end\n\n do_yield = false\n @bp_list.each do |bp|\n case bp\n when StepBreakpoint\n if bp.steps.nil? or bp.steps == 0 then\n # Delete expired task breakpoints\n @task_breakpoints[task].delete(bp)\n do_yield = true unless bp.kind_of? BreakpointRestorer\n end\n when GlobalBreakpoint\n do_yield = true if bp.trigger?(task)\n end\n # Call any breakpoint specific handler\n bp.call_handler(@thread, ctx)\n end\n\n begin\n @callback.call(@thread, ctx, @bp_list) if do_yield\n rescue Exception => e\n STDERR.puts \"An exception occured in a breakpoint handler:\"\n STDERR.puts e.to_s\n STDERR.puts e.awesome_backtrace\n end\n end\n @thread\n end", "def breakpoint binding; IRB.start_with_binding binding end", "def context\n Byebug.current_context\n end", "def breakpoints; end", "def set_next_breakpoint(bc=nil)\n # Record location of last step position\n @context = @task.current_context\n\n if @step_type == :target # Stepping to a fixed location\n calculate_target_breakpoint\n else\n # Locate the IP at n steps past the current IP/line\n calculate_next_breakpoint bc\n end\n\n if @break_type == :opcode_replacement\n # Set new breakpoint\n @method = @context.method\n @original_instruction = Breakpoint.encoder.decode_instruction(@method.bytecodes, @ip)\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.set_breakpoint(source, pos, condition = nil) > breakpoint Sets a contextspecific temporary breakpoint, which can be used to implement 'Run to Cursor' debugger function. When this breakpoint is reached, it will be cleared out. source is a name of a file or a class. pos is a line number or a method name if source is a class name. condition is a string which is evaluated to +true+ when this breakpoint is activated.
def set_breakpoint(source, pos, condition = nil) #This is a stub, used for indexing end
[ "def set_breakpoint(location:, condition: nil)\n {\n method: \"Debugger.setBreakpoint\",\n params: { location: location, condition: condition }.compact\n }\n end", "def set_breakpoint(ip, obj)\n Rubinius.primitive :compiledmethod_set_breakpoint\n raise ArgumentError, \"Unable to set breakpoint on #{inspect} at invalid bytecode address #{ip}\"\n end", "def install(bytecodes)\n if @break_type == :opcode_replacement\n # Set new breakpoint\n super(@context, bytecodes)\n elsif @break_type == :context_change\n # Stepping into method, so set breakpoint on context change\n @task.debug_context_change = true\n end\n end", "def set_breakpoint(breakpoint)\n breakpoint.package = determine_top_level_package(breakpoint)\n @process.input(\"#{self.class::Break} #{breakpoint.package}:#{breakpoint.line}\")\n end", "def breakpoint()\n #This is a stub, used for indexing\n end", "def set_next_breakpoint(bc=nil)\n # Record location of last step position\n @context = @task.current_context\n\n if @step_type == :target # Stepping to a fixed location\n calculate_target_breakpoint\n else\n # Locate the IP at n steps past the current IP/line\n calculate_next_breakpoint bc\n end\n\n if @break_type == :opcode_replacement\n # Set new breakpoint\n @method = @context.method\n @original_instruction = Breakpoint.encoder.decode_instruction(@method.bytecodes, @ip)\n end\n end", "def breakpoint binding; IRB.start_with_binding binding end", "def context=(context)\n @context = context\n @source.context = context\n end", "def add_breakpoint(bp)\n # apply breakpoint to process\n end", "def set_breakpoints_between(meth, start_ip, fin_ip)\n opts = {:event => 'line', :temp => true}\n ips = ISeq.goto_between(meth, start_ip, fin_ip)\n bps = []\n \n if ips.kind_of? Fixnum\n if ips == -1\n errmsg \"No place to step to\"\n return nil\n elsif ips == -2\n bps << step_to_parent(event='line')\n ips = []\n else\n ips = [ips]\n end\n end\n\n msg \"temp ips: #{ips.inspect}\" if settings[:debugstep]\n ips.each do |ip|\n bp = Breakpoint.for_ip(meth, ip, opts)\n bp.scoped!(@frame.scope)\n bp.activate\n bps << bp\n end\n @step_brkpts += bps\n first_bp = bps[0]\n bps[1..-1].each do |bp| \n first_bp.related_with(bp) \n end\n return first_bp\n end", "def set_breakpoint_on_function_call(object_id:, condition: nil)\n {\n method: \"Debugger.setBreakpointOnFunctionCall\",\n params: { objectId: object_id, condition: condition }.compact\n }\n end", "def breakpoint_set(ip, name=\"\", callable=nil, &block)\n if not callable and block_given?\n callable = block\n end\n @breakpoints[ip] << Breakpoint.new(self, ip, callable, @pid, name)\n end", "def find_and_set_debugged_frame(th, position)\n\n thread = threading._active[thread_id]\n thread_name = thread.getName()\n if (!@settings['dbg_pydbgr'] &&\n thread_name == Mthread.current_thread_name())\n # The frame we came in on ('current_thread_name') is\n # the same as the one we want to switch to. In this case\n # we need to some debugger frames are in this stack so\n # we need to remove them.\n newframe = Mthread.find_debugged_frame(frame)\n frame = newframe unless newframe\n end\n ## FIXME: else: we might be blocked on other threads which are\n # about to go into the debugger it not for the fact this one got there\n # first. Possibly in the future we want\n # to hide the blocks into threading of that locking code as well.\n\n # Set stack to new frame\n @frame, @curindex = Mcmdproc.get_stack(frame, nil, self.proc)\n @proc.stack, @proc.curindex = self.stack, self.curindex\n\n # @frame_thread_name = thread_name\n end", "def condition=(expr)\n @condition = expr\n if @condition\n # Convert the breakpoint expression to a valid snippet of Ruby\n eval_str = expr.gsub('#hits', '__hits__')\n # - check if then...end is needed\n if eval_str =~ /^(?:if|unless).+^(?:end)$/\n eval_str << \" then true end\"\n end\n\n # Test expression is valid syntax\n begin\n @condition_eval = eval_str if eval(\"return true; #{eval_str}\")\n rescue Exception => e\n STDERR.puts \"An error occurred while setting the breakpoint condition '#{condition}':\"\n STDERR.puts e.to_s\n STDERR.puts \"Breakpoint condition has been ignored.\"\n @condition = nil\n @condition_eval = nil\n end\n else\n @condition_eval = nil\n end\n end", "def activate_debugger(thread, ctxt, bp)\n puts \"[Debugger activated]\" unless bp.kind_of? StepBreakpoint\n @debug_thread = thread\n @eval_context = @debug_context = ctxt\n\n # Load debugger commands if we haven't already\n load_commands unless @commands\n\n file = @debug_context.file.to_s\n line = @debug_context.line\n\n puts \"\"\n puts \"#{file}:#{line} (#{@debug_context.method.name}) [IP:#{@debug_context.ip}]\"\n output = Output.new\n output.set_line_marker\n output.set_color :cyan\n if bp.kind_of? StepBreakpoint and bp.step_by == :ip\n bc = @debug_context.method.decode\n inst = bc[bc.ip_to_index(@debug_context.ip)]\n output.set_columns([\"%04d:\", \"%-s \", \"%-s\"])\n output << [inst.ip, inst.opcode, inst.args.map{|a| a.inspect}.join(', ')]\n else\n lines = source_for(file)\n unless lines.nil?\n output.set_columns(['%d:', '%-s'])\n output << [line, lines[line-1].chomp]\n end\n end\n output.set_color :clear\n puts output\n\n @prompt = \"\\nrbx:debug> \"\n until @done do\n inp = Readline.readline(@prompt)\n inp.strip!\n if inp.length > 0\n process_command(inp)\n @last_inp = inp\n elsif @last_inp\n process_command(@last_inp)\n end\n end\n\n # Clear any references to the debuggee thread and context\n @debug_thread = nil\n @debug_context = nil\n @eval_context = nil\n end", "def setContext(context)\n @context = context\n end", "def set_breakpoint(addr)\n addr = addr.upcase.to_s if addr.respond_to? :upcase\n if @labels.include? addr\n @io.puts \"break set #{addr}\"\n else\n @io.puts \"break set #{normalize_to_s(addr)}\"\n end\n\n sleep(0.01)\n\n while @io.ready?\n msg = @io.readline\n parse_msg msg.strip\n end\n\n self\n end", "def enable_breakpoint(bp)\n bp.enable\n end", "def at_breakpoint(breakpoint)\n $LOG.debug(self.class.name) do\n num = Byebug.breakpoints.index(breakpoint) + 1\n \"at_breakpoint #{num}: #{frame.file}:#{frame.line}\"\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
context.jump(line, file) > bool Returns +true+ if jump to +line+ in filename +file+ was successful.
def jump(line, file) #This is a stub, used for indexing end
[ "def jump?; @is_jump end", "def jump_statement\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 66)\n jump_statement_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 456:3: ( 'goto' IDENTIFIER ';' | 'continue' ';' | 'break' ';' | 'return' ';' | 'return' expression ';' )\n alt_72 = 5\n alt_72 = @dfa72.predict(@input)\n case alt_72\n when 1\n # at line 456:5: 'goto' IDENTIFIER ';'\n match(T__97, TOKENS_FOLLOWING_T__97_IN_jump_statement_2208)\n match(IDENTIFIER, TOKENS_FOLLOWING_IDENTIFIER_IN_jump_statement_2210)\n match(T__24, TOKENS_FOLLOWING_T__24_IN_jump_statement_2212)\n\n when 2\n # at line 457:5: 'continue' ';'\n match(T__98, TOKENS_FOLLOWING_T__98_IN_jump_statement_2218)\n match(T__24, TOKENS_FOLLOWING_T__24_IN_jump_statement_2220)\n\n when 3\n # at line 458:5: 'break' ';'\n match(T__99, TOKENS_FOLLOWING_T__99_IN_jump_statement_2226)\n match(T__24, TOKENS_FOLLOWING_T__24_IN_jump_statement_2228)\n\n when 4\n # at line 459:5: 'return' ';'\n match(T__100, TOKENS_FOLLOWING_T__100_IN_jump_statement_2234)\n match(T__24, TOKENS_FOLLOWING_T__24_IN_jump_statement_2236)\n\n when 5\n # at line 460:5: 'return' expression ';'\n match(T__100, TOKENS_FOLLOWING_T__100_IN_jump_statement_2242)\n @state.following.push(TOKENS_FOLLOWING_expression_IN_jump_statement_2244)\n expression\n @state.following.pop\n match(T__24, TOKENS_FOLLOWING_T__24_IN_jump_statement_2246)\n\n end\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 66)\n memoize(__method__, jump_statement_start_index, success) if @state.backtracking > 0\n\n end\n \n return \n end", "def _jump # jump ?(label)\r\n offset = sint16 @operands[0]\r\n\r\n jump @pc + offset - 2\r\n end", "def is_jumping?\r\n return @jump > 0\r\n end", "def jump\n return \"000\" unless jump = line.match(/;(.*)/)\n\n JUMPS[jump[1].to_sym]\n end", "def jump(x)\n @memory_position = x\n end", "def jumping?\n return @jump_count > 0\n end", "def perform_jump(end_pos)\n return false unless valid_jump?(end_pos)\n\n move!(end_pos)\n true\n end", "def jump\n puts \"Jump on Kevin\"\n end", "def patch_jump at:, to:, type: :jmp\n pos = self.pos\n write_jump(to: to, at: at, type: type)\n seek pos, IO::SEEK_SET\n end", "def goto_line(num)\n\t\t\tgoto buffer.line_index(num)\n\t\tend", "def potential_line?(filename, lineno); end", "def jump_to(pc)\n # allow pc = nil to clear exist @jump_to\n unless pc.nil? || instruction.destinations.include?(pc)\n raise EVM::InvalidJumpError.new(\"invalid jump in runtime, pc: #{pc}\")\n end\n @jump_to = pc\n end", "def jump(loc)\n @ip = loc\n end", "def jmp(args)\n address = fetch_value(args[0])\n @pc = address - 1 if address\n @jump = true\nend", "def jmp(pos=0)\n @pos = pos\n end", "def jump?\n properties.include? 'jump'\n end", "def goto_true_step\n if goto_true\n return FlowStep.job_flow_step(job_id: self.job_id, flow_step: self.goto_true)\n end\n nil\n end", "def write_jump to:, at: self.pos, type: :jmp\n rel_jump = 0xCAFE\n 2.times do\n seek at, IO::SEEK_SET\n Fisk.new { |__| __.public_send(type, __.rel32(rel_jump)) }.write_to(self)\n rel_jump = to - address\n end\n self.pos\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /oeuvres POST /oeuvres.json
def create @oeuvre = Oeuvre.new(oeuvre_params) respond_to do |format| if @oeuvre.save format.html { redirect_to oeuvres_url, notice: 'Oeuvre was successfully created.' } format.json { render :show, status: :created, location: @oeuvre } else format.html { render :new } format.json { render json: @oeuvre.errors, status: :unprocessable_entity } end end end
[ "def create\n @oeuvre = Oeuvre.new(oeuvre_params)\n\n respond_to do |format|\n if @oeuvre.save\n format.html { redirect_to @oeuvre, notice: \"Oeuvre was successfully created.\" }\n format.json { render :show, status: :created, location: @oeuvre }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @oeuvre.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @oeuvre = Oeuvre.new(oeuvre_params)\n\n respond_to do |format|\n if @oeuvre.save\n format.html { redirect_to @oeuvre, notice: 'Oeuvre was successfully created.' }\n format.json { render :show, status: :created, location: @oeuvre }\n else\n format.html { render :new }\n format.json { render json: @oeuvre.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @eou = Eou.new(params[:eou])\n\n respond_to do |format|\n if @eou.save\n format.html { redirect_to @eou, :notice => 'Eou was successfully created.' }\n format.json { render :json => @eou, :status => :created, :location => @eou }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @eou.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @egreso = Egreso.new(params[:egreso])\n\n respond_to do |format|\n if @egreso.save\n format.html { redirect_to @egreso, notice: 'Egreso was successfully created.' }\n format.json { render json: @egreso, status: :created, location: @egreso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @egreso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @egreso = Egreso.new(egreso_params)\n\n respond_to do |format|\n if @egreso.save\n format.html { redirect_to @egreso, notice: 'Egreso was successfully created.' }\n format.json { render :show, status: :created, location: @egreso }\n else\n format.html { render :new }\n format.json { render json: @egreso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reo = Reo.new(reo_params)\n\n respond_to do |format|\n if @reo.save\n format.html { redirect_to @reo, notice: 'Reo was successfully created.' }\n format.json { render :show, status: :created, location: @reo }\n else\n format.html { render :new }\n format.json { render json: @reo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uev = Uev.new(uev_params)\n\n respond_to do |format|\n if @uev.save\n format.html { redirect_to @uev, notice: 'Uev was successfully created.' }\n format.json { render :show, status: :created, location: @uev }\n else\n format.html { render :new }\n format.json { render json: @uev.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uesr = Uesr.new(uesr_params)\n\n respond_to do |format|\n if @uesr.save\n format.html { redirect_to @uesr, notice: 'Uesr was successfully created.' }\n format.json { render :show, status: :created, location: @uesr }\n else\n format.html { render :new }\n format.json { render json: @uesr.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def create\n @residuo = Residuo.new(residuo_params)\n\n respond_to do |format|\n if @residuo.save\n format.html { redirect_to @residuo, notice: 'Residuo was successfully created.' }\n format.json { render :show, status: :created, location: @residuo }\n else\n format.html { render :new }\n format.json { render json: @residuo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n @ouvrage = Ouvrage.new(ouvrage_params)\n\n respond_to do |format|\n if @ouvrage.save\n format.html { redirect_to @ouvrage, notice: 'Ouvrage was successfully created.' }\n format.json { render :show, status: :created, location: @ouvrage }\n else\n format.html { render :new }\n format.json { render json: @ouvrage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @toriaezu = Toriaezu.new(params[:toriaezu])\n\n respond_to do |format|\n if @toriaezu.save\n format.html { redirect_to @toriaezu, notice: 'Toriaezu was successfully created.' }\n format.json { render json: @toriaezu, status: :created, location: @toriaezu }\n else\n format.html { render action: \"new\" }\n format.json { render json: @toriaezu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @otu = Otu.new(params[:otu])\n\n respond_to do |format|\n if @otu.save\n format.html { redirect_to @otu, notice: 'Otu was successfully created.' }\n format.json { render json: @otu, status: :created, location: @otu }\n else\n format.html { render action: \"new\" }\n format.json { render json: @otu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ruolo = Ruolo.new(ruolo_params)\n\n respond_to do |format|\n if @ruolo.save\n format.html { redirect_to @ruolo, notice: 'Ruolo was successfully created.' }\n format.json { render :show, status: :created, location: @ruolo }\n else\n format.html { render :new }\n format.json { render json: @ruolo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @votos_urna = VotosUrna.new(params[:votos_urna])\n\n respond_to do |format|\n if @votos_urna.save\n format.html { redirect_to @votos_urna, notice: 'Votos urna was successfully created.' }\n format.json { render json: @votos_urna, status: :created, location: @votos_urna }\n else\n format.html { render action: \"new\" }\n format.json { render json: @votos_urna.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def create\n @estudiante = Estudiante.new(params[:estudiante])\n\n if @estudiante.save\n render json: @estudiante, status: :created, location: @estudiante\n else\n render json: @estudiante.errors, status: :unprocessable_entity\n end\n end", "def create\n @pessoa = Pessoa.new(pessoa_params)\n if @pessoa.save\n render json: @pessoa\n else\n render json: @pessoa.errors, status: :unprocessable_entity\n end\n end", "def create\n @videeoo = Videeoo.new(videeoo_params)\n\n respond_to do |format|\n if @videeoo.save\n format.html { redirect_to @videeoo, notice: 'Videeoo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @videeoo }\n else\n format.html { render action: 'new' }\n format.json { render json: @videeoo.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /oeuvres/1 PATCH/PUT /oeuvres/1.json
def update respond_to do |format| if @oeuvre.update(oeuvre_params) format.html { redirect_to oeuvres_url, notice: 'Oeuvre was successfully updated.' } format.json { render :show, status: :ok, location: @oeuvre } else format.html { render :edit } format.json { render json: @oeuvre.errors, status: :unprocessable_entity } end end 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 @oeuvre.update(oeuvre_params)\n format.html { redirect_to @oeuvre, notice: 'Oeuvre was successfully updated.' }\n format.json { render :show, status: :ok, location: @oeuvre }\n else\n format.html { render :edit }\n format.json { render json: @oeuvre.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @egreso = Egreso.find(params[:id])\n\n respond_to do |format|\n if @egreso.update_attributes(params[:egreso])\n format.html { redirect_to @egreso, notice: 'Egreso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @egreso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ore = Ore.find(params[:id])\n \n respond_to do |format|\n if @ore.update_attributes(params[:ore])\n format.html { redirect_to @ore, notice: 'Ore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ore.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @objeto = Objeto.find(params[:id])\n\n respond_to do |format|\n if @objeto.update_attributes(params[:objeto])\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @productos_json.update(productos_json_params)\n format.html { redirect_to @productos_json, notice: 'Productos json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @productos_json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_aos_version(args = {}) \n put(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(*a) route 'PUT', *a end", "def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def update\n @pelicula = Pelicula.find(params[:id])\n @pelicula.update(update_params)\n render json: @pelicula, status: :ok\n end", "def patch *args\n make_request :patch, *args\n end", "def update\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @receipe = Receipe.find(params[:id])\n\n if @receipe.update(receipe_params)\n head :no_content\n else\n render json: @receipe.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @restroom.update(restroom_params)\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @soiree = Soiree.find(params[:id])\n\n respond_to do |format|\n if @soiree.update_attributes(params[:soiree])\n format.html { redirect_to @soiree, notice: 'Soiree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_egreso = TipoEgreso.find(params[:id])\n\n respond_to do |format|\n if @tipo_egreso.update_attributes(params[:tipo_egreso])\n format.html { redirect_to @tipo_egreso, notice: 'Tipo egreso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_egreso.errors, status: :unprocessable_entity }\n end\n end\n end", "def put\n request_method('PUT')\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end" ]
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }